using namespace icinga;
+static void RegisterTypeType(void)
+{
+ Type::Ptr type = new TypeType();
+ Type::TypeInstance = type;
+ Type::Register(type);
+}
+
+INITIALIZE_ONCE(RegisterTypeType);
+
String Type::ToString(void) const
{
return "type '" + GetName() + "'";
m_Prototype = object;
}
+Value Type::GetField(int id) const
+{
+ if (id == 0)
+ return GetPrototype();
+
+ return Object::GetField(id);
+}
+
+String TypeType::GetName(void) const
+{
+ return "Type";
+}
+
+Type::Ptr TypeType::GetBaseType(void) const
+{
+ return Type::Ptr();
+}
+
+int TypeType::GetAttributes(void) const
+{
+ return 0;
+}
+
+int TypeType::GetFieldId(const String& name) const
+{
+ if (name == "prototype")
+ return 0;
+
+ return -1;
+}
+
+Field TypeType::GetFieldInfo(int id) const
+{
+ if (id == 0)
+ return Field(0, "Object", "prototype", 0);
+
+ throw std::runtime_error("Invalid field ID.");
+}
+
+int TypeType::GetFieldCount(void) const
+{
+ return 1;
+}
+
+ObjectFactory TypeType::GetFactory(void) const
+{
+ return NULL;
+}
+
static void Register(const Type::Ptr& type);
static Type::Ptr GetByName(const String& name);
+ virtual Value GetField(int id) const;
+
protected:
virtual ObjectFactory GetFactory(void) const = 0;
Object::Ptr m_Prototype;
};
+class I2_BASE_API TypeType : public Type
+{
+public:
+ DECLARE_PTR_TYPEDEFS(Type);
+
+ virtual String GetName(void) const;
+ virtual Type::Ptr GetBaseType(void) const;
+ virtual int GetAttributes(void) const;
+ virtual int GetFieldId(const String& name) const;
+ virtual Field GetFieldInfo(int id) const;
+ virtual int GetFieldCount(void) const;
+
+protected:
+ virtual ObjectFactory GetFactory(void) const;
+};
+
template<typename T>
class TypeImpl
{