mirror of https://github.com/Icinga/icinga2.git
parent
9ecfd9c830
commit
db8b4afa58
|
@ -26,7 +26,7 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_PRIMITIVE_TYPE(Array, Array::GetPrototype());
|
||||
REGISTER_PRIMITIVE_TYPE(Array, Object, Array::GetPrototype());
|
||||
|
||||
/**
|
||||
* Restrieves a value from an array.
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_PRIMITIVE_TYPE(Dictionary, Dictionary::GetPrototype());
|
||||
REGISTER_PRIMITIVE_TYPE(Dictionary, Object, Dictionary::GetPrototype());
|
||||
|
||||
/**
|
||||
* Retrieves a value from a dictionary.
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_PRIMITIVE_TYPE_NOINST(Function, Function::GetPrototype());
|
||||
REGISTER_PRIMITIVE_TYPE_NOINST(Function, Object, Function::GetPrototype());
|
||||
|
||||
Function::Function(const Callback& function, bool side_effect_free)
|
||||
: m_Callback(function), m_SideEffectFree(side_effect_free)
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_PRIMITIVE_TYPE(Object, Object::GetPrototype());
|
||||
REGISTER_PRIMITIVE_TYPE(Object, None, Object::GetPrototype());
|
||||
|
||||
/**
|
||||
* Default constructor for the Object class.
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
PrimitiveType::PrimitiveType(const String& name, const ObjectFactory& factory)
|
||||
: m_Name(name), m_Factory(factory)
|
||||
PrimitiveType::PrimitiveType(const String& name, const String& base, const ObjectFactory& factory)
|
||||
: m_Name(name), m_Base(base), m_Factory(factory)
|
||||
{ }
|
||||
|
||||
String PrimitiveType::GetName(void) const
|
||||
|
@ -33,7 +33,10 @@ String PrimitiveType::GetName(void) const
|
|||
|
||||
Type::Ptr PrimitiveType::GetBaseType(void) const
|
||||
{
|
||||
return Type::Ptr();
|
||||
if (m_Base == "None")
|
||||
return Type::Ptr();
|
||||
else
|
||||
return Type::GetByName(m_Base);
|
||||
}
|
||||
|
||||
int PrimitiveType::GetAttributes(void) const
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace icinga
|
|||
class I2_BASE_API PrimitiveType : public Type
|
||||
{
|
||||
public:
|
||||
PrimitiveType(const String& name, const ObjectFactory& factory = ObjectFactory());
|
||||
PrimitiveType(const String& name, const String& base, const ObjectFactory& factory = ObjectFactory());
|
||||
|
||||
virtual String GetName(void) const;
|
||||
virtual Type::Ptr GetBaseType(void) const;
|
||||
|
@ -44,6 +44,7 @@ protected:
|
|||
|
||||
private:
|
||||
String m_Name;
|
||||
String m_Base;
|
||||
ObjectFactory m_Factory;
|
||||
};
|
||||
|
||||
|
@ -51,18 +52,18 @@ private:
|
|||
namespace { namespace UNIQUE_NAME(prt) { namespace prt ## type { \
|
||||
void RegisterBuiltinType(void) \
|
||||
{ \
|
||||
icinga::Type::Ptr t = new PrimitiveType(#type); \
|
||||
icinga::Type::Ptr t = new PrimitiveType(#type, "None"); \
|
||||
t->SetPrototype(prototype); \
|
||||
icinga::Type::Register(t); \
|
||||
} \
|
||||
INITIALIZE_ONCE_WITH_PRIORITY(RegisterBuiltinType, 15); \
|
||||
} } }
|
||||
|
||||
#define REGISTER_PRIMITIVE_TYPE_FACTORY(type, prototype, factory) \
|
||||
#define REGISTER_PRIMITIVE_TYPE_FACTORY(type, base, prototype, factory) \
|
||||
namespace { namespace UNIQUE_NAME(prt) { namespace prt ## type { \
|
||||
void RegisterPrimitiveType(void) \
|
||||
{ \
|
||||
icinga::Type::Ptr t = new PrimitiveType(#type, factory);\
|
||||
icinga::Type::Ptr t = new PrimitiveType(#type, #base, factory);\
|
||||
t->SetPrototype(prototype); \
|
||||
icinga::Type::Register(t); \
|
||||
type::TypeInstance = t; \
|
||||
|
@ -71,11 +72,11 @@ private:
|
|||
} } } \
|
||||
DEFINE_TYPE_INSTANCE(type)
|
||||
|
||||
#define REGISTER_PRIMITIVE_TYPE(type, prototype) \
|
||||
REGISTER_PRIMITIVE_TYPE_FACTORY(type, prototype, DefaultObjectFactory<type>)
|
||||
#define REGISTER_PRIMITIVE_TYPE(type, base, prototype) \
|
||||
REGISTER_PRIMITIVE_TYPE_FACTORY(type, base, prototype, DefaultObjectFactory<type>)
|
||||
|
||||
#define REGISTER_PRIMITIVE_TYPE_NOINST(type, prototype) \
|
||||
REGISTER_PRIMITIVE_TYPE_FACTORY(type, prototype, NULL)
|
||||
#define REGISTER_PRIMITIVE_TYPE_NOINST(type, base, prototype) \
|
||||
REGISTER_PRIMITIVE_TYPE_FACTORY(type, base, prototype, NULL)
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue