1 #ifndef _UTAKATA_SRC_TYPE_H_
2 #define _UTAKATA_SRC_TYPE_H_
11 // IObject派生クラスに1:1で対応する型のハッシュとして機能
12 // するクラスです。このクラスはInterpreterからのみ生成される
13 // ため、各値の変更は不可能となっています。
15 explicit Type(const std::string& name) : hash_(0), hash_string_(name) {
18 Type(const Type& type);
22 Type& operator=(const Type& type);
24 // 内部で生成されたハッシュ数を返します。
25 unsigned int hash() const {return hash_;}
29 // 渡された文字列から、型単位で一意なhashを生成します。
32 // 渡されたtypeとそれぞれの値を交換します。
33 void Swap(Type& type);
38 std::string hash_string_;
41 // Typeのhashが等しい場合、trueを返します。
42 bool operator==(const Type& lh, const Type& rh) {
43 return lh.hash() == rh.hash();
46 // Typeのhashが異なる場合、trueを返します。
47 bool operator!=(const Type& lh, const Type& rh) {
48 return !(lh.hash() == rh.hash());
53 #endif /* _UTAKATA_SRC_TYPE_H_ */