OSDN Git Service

utakataの標準となる例外クラス及びマクロを定義した。
[simplecms/utakata.git] / src / type.h
index d30967c..b572438 100755 (executable)
@@ -1,16 +1,10 @@
-#ifndef _TYPE_H_
-#define _TYPE_H_
+#ifndef _UTAKATA_SRC_TYPE_H_
+#define _UTAKATA_SRC_TYPE_H_
 
 #include <string>
-#include "smart_ptr.h"
 
 namespace utakata {
 
-namespace data {
-class DataEntity;
-class Object;
-};
-
 namespace type {
 
 class Type {
@@ -18,25 +12,28 @@ class Type {
   // するクラスです。このクラスはInterpreterからのみ生成される
   // ため、各値の変更は不可能となっています。
  public:
-  explicit Type(const std::string& name);
+  explicit Type(const std::string& name) : hash_(0), hash_string_(name) {
+    MakeHash();
+  }
   Type(const Type& type);
-  virtual ~Type(){}
+  virtual ~Type() {}
 
   // 渡されたTypeをコピーします。
   Type& operator=(const Type& type);
 
-  unsigned long hash() const {return hash_;}
-
-  // 自身のコピーを作成します。
-  Type clone();
+  // 内部で生成されたハッシュ数を返します。
+  unsigned int hash() const {return hash_;}
 
  private:
 
   // 渡された文字列から、型単位で一意なhashを生成します。
-  void makeHash();
+  void MakeHash();
+
+  // 渡されたtypeとそれぞれの値を交換します。
+  void Swap(Type& type);
 
   // 生成されたハッシュ値
-  unsigned long hash_;
+  unsigned int hash_;
   // ハッシュ値の生成元となる文字列
   std::string hash_string_;
 };
@@ -50,35 +47,7 @@ bool operator==(const Type& lh, const Type& rh) {
 bool operator!=(const Type& lh, const Type& rh) {
   return !(lh.hash() == rh.hash());
 }
-
-class TypeDescripter : private utility::Uncopyable {
-  // TypeとIObject派生クラスとを関連付けるためのクラスです。
-  // TypeDescripterは、以下の情報を保持/提供します。
-  // ・保持しているオブジェクトを一意に表すType
-  // ・実体への直接アクセス
-  // Type、及び保持するオブジェクトは、生成時にのみ提供されます。
-  // TypeDescripterは、GC以外からは生成されないことを意図している
-  // ため、通常の方法では生成することができません。
-  //
-  // 各オブジェクトの実体毎に割り当てられるため、TypeDescripter自体はコ
-  // ピー不能です。
-
- public:
-  TypeDescripter(const Type& type,
-                 smart_ptr<interpreter::IObject> object);
-  virtual ~TypeDescripter() {}
-
-  const Type& type() const;
-  interpreter::IObject* object();
-
- private:
-
-  // 各オブジェクトを表す一意な型
-  Type type_;
-  // オブジェクトへの実体を保持するポインタ
-  smart_ptr<interpreter::IObject> object_;
-};
 };
 };
 
-#endif /* _TYPE_H_ */
+#endif /* _UTAKATA_SRC_TYPE_H_ */