00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #pragma once
00023
00024 #include <ostream>
00025 #include <string>
00026 #include "TypeDef.h"
00027 #include "Util.h"
00028 #include "util/string_piece.hh"
00029
00030 namespace Moses
00031 {
00032
00033 struct FactorFriend;
00034 class FactorCollection;
00035
00039 class Factor
00040 {
00041 friend std::ostream& operator<<(std::ostream&, const Factor&);
00042
00043
00044 friend class FactorCollection;
00045 friend struct FactorFriend;
00046
00047
00048
00049 mutable StringPiece m_string;
00050 size_t m_id;
00051
00053 Factor() {}
00054
00055
00056 Factor(const Factor &factor) : m_string(factor.m_string), m_id(factor.m_id) {}
00057
00058
00059 Factor &operator=(const Factor &factor);
00060
00061 public:
00063 StringPiece GetString() const {
00064 return m_string;
00065 }
00067 inline size_t GetId() const {
00068 return m_id;
00069 }
00070
00076 inline int Compare(const Factor &compare) const {
00077 if (this < &compare)
00078 return -1;
00079 if (this > &compare)
00080 return 1;
00081 return 0;
00082 }
00084 inline bool operator<(const Factor &compare) const {
00085 return this < &compare;
00086 }
00087
00088
00089 inline bool operator==(const Factor &compare) const {
00090 return this == &compare;
00091 }
00092
00093 TO_STRING();
00094
00095 };
00096
00097 size_t hash_value(const Factor &f);
00098
00099 }
00100