/******************************************************************************
* Icinga 2 *
- * Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org) *
+ * Copyright (C) 2012-2015 Icinga Development Team (http://www.icinga.org) *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
#include "base/string.hpp"
#include "base/object.hpp"
#include "base/initialize.hpp"
-#include <boost/function.hpp>
+#include <vector>
namespace icinga
{
+/* keep this in sync with tools/mkclass/classcompiler.hpp */
enum FieldAttribute
{
- FAConfig = 1,
- FAState = 2,
- FAInternal = 32
+ FAEphemeral = 1,
+ FAConfig = 2,
+ FAState = 4,
+ FAInternal = 64,
+ FARequired = 512
};
class Type;
int ID;
const char *TypeName;
const char *Name;
+ const char *RefTypeName;
int Attributes;
- Field(int id, const char *type, const char *name, int attributes)
- : ID(id), TypeName(type), Name(name), Attributes(attributes)
+ Field(int id, const char *type, const char *name, const char *reftype, int attributes)
+ : ID(id), TypeName(type), Name(name), RefTypeName(reftype), Attributes(attributes)
{ }
};
TAAbstract = 1
};
+class ValidationUtils
+{
+public:
+ virtual bool ValidateName(const String& type, const String& name) const = 0;
+};
+
class I2_BASE_API Type : public Object
{
public:
bool IsAbstract(void) const;
+ Object::Ptr GetPrototype(void) const;
+ void SetPrototype(const Object::Ptr& object);
+
static void Register(const Type::Ptr& type);
static Type::Ptr GetByName(const String& name);
+ virtual void SetField(int id, const Value& value);
+ virtual Value GetField(int id) const;
+
+ virtual std::vector<String> GetLoadDependencies(void) const;
+
protected:
virtual ObjectFactory GetFactory(void) const = 0;
+
+private:
+ 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>
icinga::Type::Register(t); \
} \
\
- INITIALIZE_ONCE(RegisterType ## type); \
+ INITIALIZE_ONCE_WITH_PRIORITY(RegisterType ## type, 10); \
} } \
DEFINE_TYPE_INSTANCE(type)