mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-26 15:14:07 +02:00
parent
9c36f40656
commit
688e64ce40
@ -22,6 +22,15 @@
|
|||||||
|
|
||||||
using namespace icinga;
|
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
|
String Type::ToString(void) const
|
||||||
{
|
{
|
||||||
return "type '" + GetName() + "'";
|
return "type '" + GetName() + "'";
|
||||||
@ -79,3 +88,52 @@ void Type::SetPrototype(const Object::Ptr& object)
|
|||||||
m_Prototype = object;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -81,6 +81,8 @@ public:
|
|||||||
static void Register(const Type::Ptr& type);
|
static void Register(const Type::Ptr& type);
|
||||||
static Type::Ptr GetByName(const String& name);
|
static Type::Ptr GetByName(const String& name);
|
||||||
|
|
||||||
|
virtual Value GetField(int id) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ObjectFactory GetFactory(void) const = 0;
|
virtual ObjectFactory GetFactory(void) const = 0;
|
||||||
|
|
||||||
@ -88,6 +90,22 @@ private:
|
|||||||
Object::Ptr m_Prototype;
|
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>
|
template<typename T>
|
||||||
class TypeImpl
|
class TypeImpl
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user