]> granicus.if.org Git - icinga2/commitdiff
Merge ReflectionObject methods into the Object class.
authorGunnar Beutner <gunnar@beutner.name>
Mon, 4 Nov 2013 22:14:34 +0000 (23:14 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Tue, 5 Nov 2013 07:56:30 +0000 (08:56 +0100)
Refs #4996

45 files changed:
components/cluster/clusterlistener.h
components/cluster/endpoint.h
components/compat/checkresultreader.h
components/compat/compatlogger.h
components/compat/externalcommandlistener.h
components/compat/statusdatawriter.h
components/db_ido_mysql/idomysqlconnection.h
components/db_ido_pgsql/idopgsqlconnection.h
components/demo/demo.h
components/livestatus/listener.h
components/notification/notificationcomponent.h
components/perfdata/graphitewriter.h
components/perfdata/perfdatawriter.h
lib/base/CMakeLists.txt
lib/base/application.h
lib/base/consolelogger.h
lib/base/dynamicobject.cpp
lib/base/dynamicobject.h
lib/base/dynamictype.cpp
lib/base/filelogger.h
lib/base/logger.h
lib/base/object.cpp
lib/base/object.h
lib/base/script.h
lib/base/serializer.cpp [new file with mode: 0644]
lib/base/serializer.h [moved from lib/base/reflectionobject.cpp with 61% similarity]
lib/base/streamlogger.h
lib/base/sysloglogger.h
lib/base/type.h [moved from lib/base/reflectionobject.h with 65% similarity]
lib/db_ido/dbconnection.h
lib/icinga/checkcommand.h
lib/icinga/command.h
lib/icinga/domain.h
lib/icinga/eventcommand.h
lib/icinga/host.h
lib/icinga/hostgroup.h
lib/icinga/icingaapplication.h
lib/icinga/notification.h
lib/icinga/notificationcommand.h
lib/icinga/service.h
lib/icinga/servicegroup.h
lib/icinga/timeperiod.h
lib/icinga/user.h
lib/icinga/usergroup.h
tools/mkclass/classcompiler.cpp

index a5abcb4bf4dc067455f905ab047e577398592953..ea6fc628949dba43e337c24c4380ecb5e0ed9299 100644 (file)
@@ -39,7 +39,7 @@ namespace icinga
 /**
  * @ingroup cluster
  */
-class ClusterListener : public ReflectionObjectImpl<ClusterListener>
+class ClusterListener : public ObjectImpl<ClusterListener>
 {
 public:
        DECLARE_PTR_TYPEDEFS(ClusterListener);
index 50807b4a840096d75a77424ca7ef0dc1824b8523..299223af0642336605ea99227aa9eb2c9ba1bd49 100644 (file)
@@ -35,7 +35,7 @@ class EndpointManager;
  *
  * @ingroup cluster
  */
-class Endpoint : public ReflectionObjectImpl<Endpoint>
+class Endpoint : public ObjectImpl<Endpoint>
 {
 public:
        DECLARE_PTR_TYPEDEFS(Endpoint);
index 939f7afcb8e595a7520b1d2539456a3d56a73edb..dd89d9ef8cd357824b7615d5e562f2c7ecdd0ea9 100644 (file)
@@ -32,7 +32,7 @@ namespace icinga
  *
  * @ingroup compat
  */
-class CheckResultReader : public ReflectionObjectImpl<CheckResultReader>
+class CheckResultReader : public ObjectImpl<CheckResultReader>
 {
 public:
        DECLARE_PTR_TYPEDEFS(CheckResultReader);
index 3dd72a821da67b4ecfcb94d2a2b49f87bdce169d..b6595a8df9b4fdfffb45e31c04f3ea3b14c6768f 100644 (file)
@@ -33,7 +33,7 @@ namespace icinga
  *
  * @ingroup compat
  */
-class CompatLogger : public ReflectionObjectImpl<CompatLogger>
+class CompatLogger : public ObjectImpl<CompatLogger>
 {
 public:
        DECLARE_PTR_TYPEDEFS(CompatLogger);
index e07b332b2ee45d59358a9ce81ba88f8079ee2403..83a4f9568ddc0e10f7fc4cd56fbd6209a7876068 100644 (file)
@@ -33,7 +33,7 @@ namespace icinga
 /**
  * @ingroup compat
  */
-class ExternalCommandListener : public ReflectionObjectImpl<ExternalCommandListener>
+class ExternalCommandListener : public ObjectImpl<ExternalCommandListener>
 {
 public:
        DECLARE_PTR_TYPEDEFS(ExternalCommandListener);
index ba9e8c922e12b1fd4999f4db6629e73b076c659c..5ffd0340b2c24be24e825eb8f50777737f691414 100644 (file)
@@ -37,7 +37,7 @@ namespace icinga
 /**
  * @ingroup compat
  */
-class StatusDataWriter : public ReflectionObjectImpl<StatusDataWriter>
+class StatusDataWriter : public ObjectImpl<StatusDataWriter>
 {
 public:
        DECLARE_PTR_TYPEDEFS(StatusDataWriter);
index c9e36ccff63d32c4a545ae64102e34c0800df903..3ac475152b6959b27753df68aef60ef74029f8a4 100644 (file)
@@ -34,7 +34,7 @@ namespace icinga
  *
  * @ingroup ido
  */
-class IdoMysqlConnection : public ReflectionObjectImpl<IdoMysqlConnection>
+class IdoMysqlConnection : public ObjectImpl<IdoMysqlConnection>
 {
 public:
        DECLARE_PTR_TYPEDEFS(IdoMysqlConnection);
index 61583ce898742b2dde1be1a09333965c7d8f7539..353517d72369ea31d302a3da837ef2d43e3002ad 100644 (file)
@@ -34,7 +34,7 @@ namespace icinga
  *
  * @ingroup ido
  */
-class IdoPgsqlConnection : public ReflectionObjectImpl<IdoPgsqlConnection>
+class IdoPgsqlConnection : public ObjectImpl<IdoPgsqlConnection>
 {
 public:
        DECLARE_PTR_TYPEDEFS(IdoPgsqlConnection);
index 11537961c28002bd84b235914c994f5fb71e1fd9..390183a21e88c15b01fbc11bd2f1db32d90e8c47 100644 (file)
@@ -29,7 +29,7 @@ namespace icinga
 /**
  * @ingroup demo
  */
-class Demo : public ReflectionObjectImpl<Demo>
+class Demo : public ObjectImpl<Demo>
 {
 public:
        DECLARE_PTR_TYPEDEFS(Demo);
index e348f226fa19106af50a45a791a7ca7900940723..a534bdeba45b76e009fa4859f41bdca99260791a 100644 (file)
@@ -33,7 +33,7 @@ namespace livestatus
 /**
  * @ingroup livestatus
  */
-class LivestatusListener : public ReflectionObjectImpl<LivestatusListener>
+class LivestatusListener : public ObjectImpl<LivestatusListener>
 {
 public:
        DECLARE_PTR_TYPEDEFS(LivestatusListener);
index 1bb1ea6f0df635a0ce3f61bf7ac5a0575a3946d4..c2217da852dc1657fe604ed51ab13bcebc0c6f32 100644 (file)
@@ -31,7 +31,7 @@ namespace icinga
 /**
  * @ingroup notification
  */
-class NotificationComponent : public ReflectionObjectImpl<NotificationComponent>
+class NotificationComponent : public ObjectImpl<NotificationComponent>
 {
 public:
        DECLARE_PTR_TYPEDEFS(NotificationComponent);
index a17e8ed65ad0d0b3e41eaca2a19d315c33c97069..b99736338009c46a897444c257a8f265af564a4f 100644 (file)
@@ -35,7 +35,7 @@ namespace icinga
  *
  * @ingroup perfdata
  */
-class GraphiteWriter : public ReflectionObjectImpl<GraphiteWriter>
+class GraphiteWriter : public ObjectImpl<GraphiteWriter>
 {
 public:
        DECLARE_PTR_TYPEDEFS(GraphiteWriter);
index 8ae295fdb38890e6ee7f8a968a2417925ba2b48c..00246c06b06320deba14d0f38c0bb3ca7337d6f7 100644 (file)
@@ -34,7 +34,7 @@ namespace icinga
  *
  * @ingroup icinga
  */
-class PerfdataWriter : public ReflectionObjectImpl<PerfdataWriter>
+class PerfdataWriter : public ObjectImpl<PerfdataWriter>
 {
 public:
        DECLARE_PTR_TYPEDEFS(PerfdataWriter);
index f95b095aee31d99d50e20b7531d59ef08df197f0..7a73a4b098982412122b7853fba33f30f6c99b7a 100644 (file)
@@ -30,12 +30,12 @@ add_library(base SHARED
   dynamicobject.th dynamictype.cpp exception.cpp fifo.cpp filelogger.cpp
   filelogger.th logger.cpp logger.th netstring.cpp networkstream.cpp object.cpp
   objectlock.cpp process.cpp process-unix.cpp process-windows.cpp qstring.cpp
-  reflectionobject.cpp ringbuffer.cpp script.cpp script.th scriptfunction.cpp
-  scriptfunctionwrapper.cpp scriptinterpreter.cpp scriptlanguage.cpp
-  scriptvariable.cpp socket.cpp stacktrace.cpp stdiostream.cpp stream_bio.cpp
-  stream.cpp streamlogger.cpp streamlogger.th sysloglogger.cpp sysloglogger.th
-  tcpsocket.cpp threadpool.cpp timer.cpp tlsstream.cpp tlsutility.cpp
-  unixsocket.cpp utility.cpp value.cpp workqueue.cpp zlibstream.cpp
+  ringbuffer.cpp script.cpp script.th scriptfunction.cpp scriptfunctionwrapper.cpp
+  scriptinterpreter.cpp scriptlanguage.cpp scriptvariable.cpp serializer.cpp
+  socket.cpp stacktrace.cpp stdiostream.cpp stream_bio.cpp stream.cpp
+  streamlogger.cpp streamlogger.th sysloglogger.cpp sysloglogger.th tcpsocket.cpp
+  threadpool.cpp timer.cpp tlsstream.cpp tlsutility.cpp unixsocket.cpp
+  utility.cpp value.cpp workqueue.cpp zlibstream.cpp
 )
 
 target_link_libraries(base ${CMAKE_DL_LIBS} ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} cJSON mmatch)
index 7f6c483a5733a1578956b233c62a96d9291a6568..19b64fb58824f4a7ef65ab4e8f7d27ee98ea4ee7 100644 (file)
@@ -34,7 +34,7 @@ class Component;
  *
  * @ingroup base
  */
-class I2_BASE_API Application : public ReflectionObjectImpl<Application> {
+class I2_BASE_API Application : public ObjectImpl<Application> {
 public:
        DECLARE_PTR_TYPEDEFS(Application);
 
index 6fd7a7ff0390fce7eef5844c3bf6d7ded63c6098..8e8306dcab028da4f8dd08ea2a07af2f5050a826 100644 (file)
@@ -31,7 +31,7 @@ namespace icinga
  *
  * @ingroup base
  */
-class I2_BASE_API ConsoleLogger : public ReflectionObjectImpl<ConsoleLogger>
+class I2_BASE_API ConsoleLogger : public ObjectImpl<ConsoleLogger>
 {
 public:
        DECLARE_PTR_TYPEDEFS(ConsoleLogger);
index f1ec498c5fa702016d7d04c90466509312231f6a..46bdfe1fc779ba4f9a10ff6a60b605ececf1ca27 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "base/dynamicobject.h"
 #include "base/dynamictype.h"
+#include "base/serializer.h"
 #include "base/netstring.h"
 #include "base/registry.h"
 #include "base/stdiostream.h"
@@ -220,7 +221,7 @@ void DynamicObject::DumpObjects(const String& filename, int attributeTypes)
                        persistentObject->Set("type", type->GetName());
                        persistentObject->Set("name", object->GetName());
 
-                       Dictionary::Ptr update = object->Serialize(attributeTypes);
+                       Dictionary::Ptr update = Serializer::Serialize(object, attributeTypes);
 
                        if (!update)
                                continue;
@@ -279,7 +280,7 @@ void DynamicObject::RestoreObjects(const String& filename, int attributeTypes)
                if (object) {
                        ASSERT(!object->IsActive());
                        Log(LogDebug, "base", "Restoring object '" + name + "' of type '" + type + "'.");
-                       object->Deserialize(update, attributeTypes);
+                       Serializer::Deserialize(object, update, attributeTypes);
                        object->OnStateLoaded();
                }
 
index a2dcb4c26c6f1b3817797eca2d3114d024b41b73..df3baf72465c2a9ec539c79c132a8eda3ac828bb 100644 (file)
@@ -34,17 +34,6 @@ namespace icinga
 
 class DynamicType;
 
-/**
- * The type of an attribute for a DynamicObject.
- *
- * @ingroup base
- */
-enum AttributeType
-{
-       Attribute_State = FAState,
-       Attribute_Config = FAConfig
-};
-
 enum DomainPriv
 {
        DomainPrivRead = (1<<0),
@@ -58,7 +47,7 @@ enum DomainPriv
  *
  * @ingroup base
  */
-class I2_BASE_API DynamicObject : public ReflectionObjectImpl<DynamicObject>
+class I2_BASE_API DynamicObject : public ObjectImpl<DynamicObject>
 {
 public:
        DECLARE_PTR_TYPEDEFS(DynamicObject);
@@ -105,8 +94,8 @@ public:
                return dynamic_pointer_cast<T>(object);
        }
 
-       static void DumpObjects(const String& filename, int attributeTypes = Attribute_State);
-       static void RestoreObjects(const String& filename, int attributeTypes = Attribute_State);
+       static void DumpObjects(const String& filename, int attributeTypes = FAState);
+       static void RestoreObjects(const String& filename, int attributeTypes = FAState);
        static void StopObjects(void);
 
 protected:
index 6059d8d31ceb922dd705eb23482ec6f5628fc3bc..f077de95cf37491dc7de8dde422a17d17cb38b58 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "base/dynamictype.h"
+#include "base/serializer.h"
 #include "base/debug.h"
 #include "base/objectlock.h"
 
@@ -138,7 +139,7 @@ DynamicObject::Ptr DynamicType::CreateObject(const Dictionary::Ptr& serializedUp
 
        DynamicObject::Ptr object = factory();
 
-       object->Deserialize(serializedUpdate, Attribute_Config);
+       Serializer::Deserialize(object, serializedUpdate, FAConfig);
 
        return object;
 }
index e1d138a0d6f3b6c44e045b3dac17c7b3b7145073..3e961f2497a315c6cf4a0be96fe34564ab1f07a7 100644 (file)
@@ -31,7 +31,7 @@ namespace icinga
  *
  * @ingroup base
  */
-class I2_BASE_API FileLogger : public ReflectionObjectImpl<FileLogger>
+class I2_BASE_API FileLogger : public ObjectImpl<FileLogger>
 {
 public:
        DECLARE_PTR_TYPEDEFS(FileLogger);
index 4098870c2ef14768b5e51810f668b3bd5e4c1f39..9f61dda5e79ca5530b7aa355d171799b49f669bf 100644 (file)
@@ -46,7 +46,7 @@ struct LogEntry {
  *
  * @ingroup base
  */
-class I2_BASE_API Logger : public ReflectionObjectImpl<Logger>
+class I2_BASE_API Logger : public ObjectImpl<Logger>
 {
 public:
        DECLARE_PTR_TYPEDEFS(Logger);
index ad3d2b7db8f0e5d2c127a7526f067df784b6cfc6..c232a07f2cea0b514a3c07acd6e75b82664c39bd 100644 (file)
@@ -69,3 +69,18 @@ Object::SharedPtrHolder::operator Value(void) const
 {
        return m_Object;
 }
+
+const Type *Object::GetReflectionType(void) const
+{
+       return NULL;
+}
+
+void Object::SetField(int id, const Value& value)
+{
+       throw std::runtime_error("Invalid field ID.");
+}
+
+Value Object::GetField(int id) const
+{
+       throw std::runtime_error("Invalid field ID.");
+}
index e4156c9b080e08cd428d974890f836fcb5003149..7dd38e71874ad4d01a6516bc2efc9a800729ff1a 100644 (file)
@@ -48,6 +48,8 @@ class Value;
        typedef shared_ptr<klass> Ptr; \
        typedef weak_ptr<klass> WeakPtr
 
+class Type;
+
 /**
  * Base class for all heap-allocated objects. At least one of its methods
  * has to be virtual for RTTI to work.
@@ -62,6 +64,10 @@ public:
        Object(void);
        virtual ~Object(void);
 
+       virtual const Type *GetReflectionType(void) const;
+       virtual void SetField(int id, const Value& value);
+       virtual Value GetField(int id) const;
+
        /**
         * Holds a shared pointer and provides support for implicit upcasts.
         *
@@ -175,6 +181,16 @@ public:
        }
 };
 
+template<typename T>
+class TypeImpl
+{
+};
+
+template<typename T>
+class ObjectImpl
+{
+};
+
 }
 
 #endif /* OBJECT_H */
index 4243a71ee785936ad5696f16514e80c79aabce8a..d14966863ff3d0a312346f62391b758d6a2d93d2 100644 (file)
@@ -33,7 +33,7 @@ class ScriptInterpreter;
  *
  * @ingroup base
  */
-class I2_BASE_API Script : public ReflectionObjectImpl<Script>
+class I2_BASE_API Script : public ObjectImpl<Script>
 {
 public:
        DECLARE_PTR_TYPEDEFS(Script);
diff --git a/lib/base/serializer.cpp b/lib/base/serializer.cpp
new file mode 100644 (file)
index 0000000..77126db
--- /dev/null
@@ -0,0 +1,59 @@
+/******************************************************************************
+* Icinga 2                                                                   *
+* Copyright (C) 2012-2013 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                *
+* as published by the Free Software Foundation; either version 2             *
+* of the License, or (at your option) any later version.                     *
+*                                                                            *
+* This program is distributed in the hope that it will be useful,            *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
+* GNU General Public License for more details.                               *
+*                                                                            *
+* You should have received a copy of the GNU General Public License          *
+* along with this program; if not, write to the Free Software Foundation     *
+* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
+******************************************************************************/
+
+#include "base/serializer.h"
+#include "base/type.h"
+#include <boost/smart_ptr/make_shared.hpp>
+
+using namespace icinga;
+
+Dictionary::Ptr Serializer::Serialize(const Object::Ptr& object, int attributeTypes)
+{
+       const Type *type = object->GetReflectionType();
+
+       Dictionary::Ptr update = boost::make_shared<Dictionary>();
+
+       for (int i = 0; i < type->GetFieldCount(); i++) {
+               Field field = type->GetFieldInfo(i);
+
+               if ((field.Attributes & attributeTypes) == 0)
+                       continue;
+
+               update->Set(field.Name, object->GetField(i));
+       }
+
+       return update;
+}
+
+void Serializer::Deserialize(const Object::Ptr& object, const Dictionary::Ptr& update, int attributeTypes)
+{
+       const Type *type = object->GetReflectionType();
+
+       for (int i = 0; i < type->GetFieldCount(); i++) {
+               Field field = type->GetFieldInfo(i);
+
+               if ((field.Attributes & attributeTypes) == 0)
+                       continue;
+
+               if (!update->Contains(field.Name))
+                       continue;
+
+               object->SetField(i, update->Get(field.Name));
+       }
+}
similarity index 61%
rename from lib/base/reflectionobject.cpp
rename to lib/base/serializer.h
index b39eabe39c6f304b00add19b9ae29df574b88175..7dfdc730f61554ccdc5243d7d7d6f50aed89d683 100644 (file)
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
  ******************************************************************************/
 
-#include "base/reflectionobject.h"
-#include <boost/smart_ptr/make_shared.hpp>
+#ifndef SERIALIZER_H
+#define SERIALIZER_H
 
-using namespace icinga;
+#include "base/i2-base.h"
+#include "base/dictionary.h"
 
-Dictionary::Ptr ReflectionObject::Serialize(int attributeTypes) const
+namespace icinga
 {
-       const ReflectionType *type = GetReflectionType();
 
-       Dictionary::Ptr update = boost::make_shared<Dictionary>();
-
-       for (int i = 0; i < type->GetFieldCount(); i++) {
-               ReflectionField field = type->GetFieldInfo(i);
-
-               if ((field.Attributes & attributeTypes) == 0)
-                       continue;
-
-               update->Set(field.Name, GetField(i));
-       }
-
-       return update;
-}
-
-void ReflectionObject::Deserialize(const Dictionary::Ptr& update, int attributeTypes)
+/**
+ * Serializer utilities.
+ *
+ * @ingroup base
+ */
+class I2_BASE_API Serializer
 {
-       const ReflectionType *type = GetReflectionType();
-
-       for (int i = 0; i < type->GetFieldCount(); i++) {
-               ReflectionField field = type->GetFieldInfo(i);
+public:
+       static Dictionary::Ptr Serialize(const Object::Ptr& object, int attributeTypes);
+       static void Deserialize(const Object::Ptr& object, const Dictionary::Ptr& update, int attributeTypes);
 
-               if ((field.Attributes & attributeTypes) == 0)
-                       continue;
+private:
+       Serializer(void);
+};
 
-               if (!update->Contains(field.Name))
-                       continue;
-
-               SetField(i, update->Get(field.Name));
-       }
 }
+
+#endif /* SERIALIZER_H */
index 3fec2af991f5fa144d22bdc9d1fc559c6fc05509..8839159071b4853d243576672e3cf15c08eaf3f1 100644 (file)
@@ -33,7 +33,7 @@ namespace icinga
  *
  * @ingroup base
  */
-class I2_BASE_API StreamLogger : public ReflectionObjectImpl<StreamLogger>
+class I2_BASE_API StreamLogger : public ObjectImpl<StreamLogger>
 {
 public:
        DECLARE_PTR_TYPEDEFS(StreamLogger);
index c1678ef6761e1e22098e745b133fcd339ea89405..e8828bae853f9fe819991598952548d48485d40c 100644 (file)
@@ -32,7 +32,7 @@ namespace icinga
  *
  * @ingroup base
  */
-class I2_BASE_API SyslogLogger : public ReflectionObjectImpl<SyslogLogger>
+class I2_BASE_API SyslogLogger : public ObjectImpl<SyslogLogger>
 {
 public:
        DECLARE_PTR_TYPEDEFS(SyslogLogger);
similarity index 65%
rename from lib/base/reflectionobject.h
rename to lib/base/type.h
index 7429a6ff9214f71e8a23f1c328fe308348b9410c..80bf242a70ac13a05ef48283ada488957deef3ba 100644 (file)
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
  ******************************************************************************/
 
-#ifndef REFLECTIONOBJECT_H
-#define REFLECTIONOBJECT_H
+#ifndef TYPE_H
+#define TYPE_H
 
-#include "base/object.h"
-#include "base/dictionary.h"
-#include <vector>
+#include "base/i2-base.h"
+#include "base/qstring.h"
 
 namespace icinga
 {
 
-enum ReflectionFieldAttribute
+enum FieldAttribute
 {
        FAConfig = 1,
        FAState = 2
 };
 
-struct ReflectionField
+struct Field
 {
        int ID;
        String Name;
        int Attributes;
 
-       ReflectionField(int id, const String& name, int attributes)
+       Field(int id, const String& name, int attributes)
                : ID(id), Name(name), Attributes(attributes)
        { }
 };
 
-enum InvokationType
-{
-       ITGet,
-       ITSet
-};
-
-class I2_BASE_API ReflectionType
+class I2_BASE_API Type
 {
 public:
        virtual int GetFieldId(const String& name) const = 0;
-       virtual ReflectionField GetFieldInfo(int id) const = 0;
+       virtual Field GetFieldInfo(int id) const = 0;
        virtual int GetFieldCount(void) const = 0;
 };
 
-class I2_BASE_API ReflectionObject : public Object
-{
-public:
-       DECLARE_PTR_TYPEDEFS(ReflectionObject);
-
-       virtual const ReflectionType *GetReflectionType(void) const = 0;
-       virtual void SetField(int id, const Value& value) = 0;
-       virtual Value GetField(int id) const = 0;
-
-       Dictionary::Ptr Serialize(int attributeTypes) const;
-       void Deserialize(const Dictionary::Ptr& update, int attributeTypes);
-};
-
-template<typename T>
-class ReflectionTypeImpl
-{
-};
-
-template<typename T>
-class ReflectionObjectImpl
-{
-};
-
 }
 
-#endif /* REFLECTIONOBJECT_H */
+#endif /* TYPE_H */
index 193f93ccd00156efee882c08b55e929c0a63d745..2881048597f0367a182a1352866e76a549e65118 100644 (file)
@@ -34,7 +34,7 @@ namespace icinga
  *
  * @ingroup db_ido
  */
-class I2_DB_IDO_API DbConnection : public ReflectionObjectImpl<DbConnection>
+class I2_DB_IDO_API DbConnection : public ObjectImpl<DbConnection>
 {
 public:
        DECLARE_PTR_TYPEDEFS(DbConnection);
index 4063187d1f32a761cc3d1f8b80196799073c3747..7c0e14a5fee578c18f9049cdaa74b8c1c56fa48e 100644 (file)
@@ -31,7 +31,7 @@ namespace icinga
  *
  * @ingroup icinga
  */
-class I2_ICINGA_API CheckCommand : public ReflectionObjectImpl<CheckCommand>
+class I2_ICINGA_API CheckCommand : public ObjectImpl<CheckCommand>
 {
 public:
        DECLARE_PTR_TYPEDEFS(CheckCommand);
index 236279425f8c95c709bfcf2121533cd9b5be1197..a0c8c1073d4acaad7ca84081f85bf3faa5892754 100644 (file)
@@ -35,7 +35,7 @@ namespace icinga
  *
  * @ingroup icinga
  */
-class I2_ICINGA_API Command : public ReflectionObjectImpl<Command>, public MacroResolver
+class I2_ICINGA_API Command : public ObjectImpl<Command>, public MacroResolver
 {
 public:
        DECLARE_PTR_TYPEDEFS(Command);
index cdee0746c1d506b7dbaf19c8eabd5404b9953585..05d71c00f7fe2694f2ea2af5b0930f5545022083 100644 (file)
@@ -32,7 +32,7 @@ namespace icinga
  *
  * @ingroup icinga
  */
-class I2_ICINGA_API Domain : public ReflectionObjectImpl<Domain>
+class I2_ICINGA_API Domain : public ObjectImpl<Domain>
 {
 public:
        DECLARE_PTR_TYPEDEFS(Domain);
index baf27c699b908c5a3f413486aaea9a75d9d60de2..98288c864903dbd1c66db15eedacbdf56b4e7a35 100644 (file)
@@ -31,7 +31,7 @@ namespace icinga
  *
  * @ingroup icinga
  */
-class I2_ICINGA_API EventCommand : public ReflectionObjectImpl<EventCommand>
+class I2_ICINGA_API EventCommand : public ObjectImpl<EventCommand>
 {
 public:
        DECLARE_PTR_TYPEDEFS(EventCommand);
index 2ad52131d2db6b90a6a8c90e87faa05fecf3ea6a..0dad2891e807d3fe06ec99c391ffaf238a550a76 100644 (file)
@@ -48,7 +48,7 @@ enum HostState
  *
  * @ingroup icinga
  */
-class I2_ICINGA_API Host : public ReflectionObjectImpl<Host>, public MacroResolver
+class I2_ICINGA_API Host : public ObjectImpl<Host>, public MacroResolver
 {
 public:
        DECLARE_PTR_TYPEDEFS(Host);
index 1374a123083a4eb99abaed9a83ee9d59dc9ea827..be9e4425d549f56463f57f48f3a89213948762f8 100644 (file)
@@ -32,7 +32,7 @@ namespace icinga
  *
  * @ingroup icinga
  */
-class I2_ICINGA_API HostGroup : public ReflectionObjectImpl<HostGroup>
+class I2_ICINGA_API HostGroup : public ObjectImpl<HostGroup>
 {
 public:
        DECLARE_PTR_TYPEDEFS(HostGroup);
index 657c562392aedb4f26177127139ebd355d4b9c93..120b54825aab6fcbe3869b37b7a43bf10784316d 100644 (file)
@@ -32,7 +32,7 @@ namespace icinga
  *
  * @ingroup icinga
  */
-class I2_ICINGA_API IcingaApplication : public ReflectionObjectImpl<IcingaApplication>, public MacroResolver
+class I2_ICINGA_API IcingaApplication : public ObjectImpl<IcingaApplication>, public MacroResolver
 {
 public:
        DECLARE_PTR_TYPEDEFS(IcingaApplication);
index 3e75fa3ce0a16457fa45668b1e4be8fe4f1620ad..5875825f284fa0122f7f8d7f53a86ea266ced66e 100644 (file)
@@ -56,7 +56,7 @@ class NotificationCommand;
  *
  * @ingroup icinga
  */
-class I2_ICINGA_API Notification : public ReflectionObjectImpl<Notification>, public MacroResolver
+class I2_ICINGA_API Notification : public ObjectImpl<Notification>, public MacroResolver
 {
 public:
        DECLARE_PTR_TYPEDEFS(Notification);
index 3ef99f26cdabec1d6c843a7785d8ef1b903691b2..1dbdafb0c42e44ea7ebd36ca9199f53c561f7ce1 100644 (file)
@@ -33,7 +33,7 @@ class Notification;
  *
  * @ingroup icinga
  */
-class I2_ICINGA_API NotificationCommand : public ReflectionObjectImpl<NotificationCommand>
+class I2_ICINGA_API NotificationCommand : public ObjectImpl<NotificationCommand>
 {
 public:
        DECLARE_PTR_TYPEDEFS(NotificationCommand);
index b2eb4541f53b1748e2e1c8bb5216136645a51496..26e151b19f8ec96b9678ecd7517a78059bacecd7 100644 (file)
@@ -118,7 +118,7 @@ class EventCommand;
  *
  * @ingroup icinga
  */
-class I2_ICINGA_API Service : public ReflectionObjectImpl<Service>, public MacroResolver
+class I2_ICINGA_API Service : public ObjectImpl<Service>, public MacroResolver
 {
 public:
        DECLARE_PTR_TYPEDEFS(Service);
index e36b1a3316b618b0c741c245b3dad0ea3bf11ac3..8bc7034c3a2582fdabb120ad631aa723ebf2cae9 100644 (file)
@@ -32,7 +32,7 @@ namespace icinga
  *
  * @ingroup icinga
  */
-class I2_ICINGA_API ServiceGroup : public ReflectionObjectImpl<ServiceGroup>
+class I2_ICINGA_API ServiceGroup : public ObjectImpl<ServiceGroup>
 {
 public:
        DECLARE_PTR_TYPEDEFS(ServiceGroup);
index 921b4b5e3142d80a576914759b834937aeb05418..a4712c36833f0f3981bdfc36bc4ad335f7e2bd04 100644 (file)
@@ -32,7 +32,7 @@ namespace icinga
  *
  * @ingroup icinga
  */
-class I2_ICINGA_API TimePeriod : public ReflectionObjectImpl<TimePeriod>
+class I2_ICINGA_API TimePeriod : public ObjectImpl<TimePeriod>
 {
 public:
        DECLARE_PTR_TYPEDEFS(TimePeriod);
index a458b4d1f4526e76063f8ae17672831b635c0ff6..97b34905c3400cee25d87a14b5aa4587455b2f21 100644 (file)
@@ -34,7 +34,7 @@ namespace icinga
  *
  * @ingroup icinga
  */
-class I2_ICINGA_API User : public ReflectionObjectImpl<User>, public MacroResolver
+class I2_ICINGA_API User : public ObjectImpl<User>, public MacroResolver
 {
 public:
        DECLARE_PTR_TYPEDEFS(User);
index 5b02dd0eb24e18d39206b844a5657c5b06dc87d3..56de30664fbca2769834a987e34a5e6ebf7b706b 100644 (file)
@@ -32,7 +32,7 @@ namespace icinga
  *
  * @ingroup icinga
  */
-class I2_ICINGA_API UserGroup : public ReflectionObjectImpl<UserGroup>
+class I2_ICINGA_API UserGroup : public ObjectImpl<UserGroup>
 {
 public:
        DECLARE_PTR_TYPEDEFS(UserGroup);
index 24ddd4f72e2f8770541b18615cba1e38ce590fb3..5ed6f5bfbacddc555904eb24abed242c2d18835e 100644 (file)
@@ -85,10 +85,10 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo& locp)
        if (klass.Name.find_first_of(':') == std::string::npos)
                std::cout << "class " << klass.Name << ";" << std::endl << std::endl;
 
-       /* ReflectionTypeImpl */
+       /* TypeImpl */
        std::cout << "template<>" << std::endl
-               << "class ReflectionTypeImpl<" << klass.Name << ">"
-               << " : public ReflectionType, public Singleton<ReflectionTypeImpl<" << klass.Name << "> >" << std::endl
+               << "class TypeImpl<" << klass.Name << ">"
+               << " : public Type, public Singleton<TypeImpl<" << klass.Name << "> >" << std::endl
                << "{" << std::endl
                << "public:" << std::endl;
 
@@ -104,7 +104,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo& locp)
                << "\t\t" << "int offset = ";
 
        if (!klass.Parent.empty())
-               std::cout << "ReflectionTypeImpl<" << klass.Parent << ">::StaticGetFieldCount()";
+               std::cout << "TypeImpl<" << klass.Parent << ">::StaticGetFieldCount()";
        else
                std::cout << "0";
 
@@ -121,7 +121,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo& locp)
                << "\t\t" << "return ";
 
        if (!klass.Parent.empty())
-               std::cout << "ReflectionTypeImpl<" << klass.Parent << ">::StaticGetFieldId(name)";
+               std::cout << "TypeImpl<" << klass.Parent << ">::StaticGetFieldId(name)";
        else
                std::cout << "-1";
 
@@ -129,18 +129,18 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo& locp)
                << "\t" << "}" << std::endl << std::endl;
 
        /* GetFieldInfo */
-       std::cout << "\t" << "virtual ReflectionField GetFieldInfo(int id) const" << std::endl
+       std::cout << "\t" << "virtual Field GetFieldInfo(int id) const" << std::endl
                << "\t" << "{" << std::endl
                << "\t\t" << "return StaticGetFieldInfo(id);" << std::endl
                << "\t" << "}" << std::endl << std::endl;
 
        /* StaticGetFieldInfo */
-       std::cout << "\t" << "static ReflectionField StaticGetFieldInfo(int id)" << std::endl
+       std::cout << "\t" << "static Field StaticGetFieldInfo(int id)" << std::endl
                << "\t" << "{" << std::endl;
 
        if (!klass.Parent.empty())
-               std::cout << "\t\t" << "int real_id = id - " << "ReflectionTypeImpl<" << klass.Parent << ">::StaticGetFieldCount();" << std::endl
-               << "\t\t" << "if (real_id < 0) { return " << "ReflectionTypeImpl<" << klass.Parent << ">::StaticGetFieldInfo(id); }" << std::endl;
+               std::cout << "\t\t" << "int real_id = id - " << "TypeImpl<" << klass.Parent << ">::StaticGetFieldCount();" << std::endl
+               << "\t\t" << "if (real_id < 0) { return " << "TypeImpl<" << klass.Parent << ">::StaticGetFieldInfo(id); }" << std::endl;
 
        std::cout << "\t\t" << "switch (";
 
@@ -154,7 +154,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo& locp)
        num = 0;
        for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
                std::cout << "\t\t\t" << "case " << num << ":" << std::endl
-                       << "\t\t\t\t" << "return ReflectionField(" << num << ", \"" << it->Name << "\", " << it->Attributes << ");" << std::endl;
+                       << "\t\t\t\t" << "return Field(" << num << ", \"" << it->Name << "\", " << it->Attributes << ");" << std::endl;
                num++;
        }
 
@@ -176,31 +176,31 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo& locp)
                << "\t\t" << "return " << klass.Fields.size();
 
        if (!klass.Parent.empty())
-               std::cout << " + " << "ReflectionTypeImpl<" << klass.Parent << ">::StaticGetFieldCount()";
+               std::cout << " + " << "TypeImpl<" << klass.Parent << ">::StaticGetFieldCount()";
 
        std::cout << ";" << std::endl
                << "\t" << "}" << std::endl << std::endl;
 
        std::cout << "};" << std::endl << std::endl;
 
-       /* ReflectionObjectImpl */
+       /* ObjectImpl */
        std::cout << "template<>" << std::endl
-                 << "class ReflectionObjectImpl<" << klass.Name << ">"
-                 << " : public " << (klass.Parent.empty() ? "ReflectionObject" : klass.Parent) << std::endl
+                 << "class ObjectImpl<" << klass.Name << ">"
+                 << " : public " << (klass.Parent.empty() ? "Object" : klass.Parent) << std::endl
                  << "{" << std::endl
                  << "public:" << std::endl
-                 << "\t" << "DECLARE_PTR_TYPEDEFS(ReflectionObjectImpl<" << klass.Name << ">);" << std::endl << std::endl;
+                 << "\t" << "DECLARE_PTR_TYPEDEFS(ObjectImpl<" << klass.Name << ">);" << std::endl << std::endl;
 
-       /* GetType */
-       std::cout << "\t" << "virtual const ReflectionType *GetReflectionType(void) const" << std::endl
+       /* GetReflectionType */
+       std::cout << "\t" << "virtual const Type *GetReflectionType(void) const" << std::endl
                          << "\t" << "{" << std::endl
-                         << "\t\t" << "return ReflectionTypeImpl<" << klass.Name << ">::GetInstance();" << std::endl
+                         << "\t\t" << "return TypeImpl<" << klass.Name << ">::GetInstance();" << std::endl
                          << "\t" << "}" << std::endl << std::endl;
 
        if (!klass.Fields.empty()) {
                /* constructor */
                std::cout << "public:" << std::endl
-                         << "\t" << "ReflectionObjectImpl<" << klass.Name << ">(void)" << std::endl
+                         << "\t" << "ObjectImpl<" << klass.Name << ">(void)" << std::endl
                          << "\t" << "{" << std::endl;
 
                for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
@@ -215,7 +215,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo& locp)
                                  << "\t" << "{" << std::endl;
 
                if (!klass.Parent.empty())
-                       std::cout << "\t\t" << "int real_id = id - ReflectionTypeImpl<" << klass.Parent << ">::StaticGetFieldCount(); " << std::endl
+                       std::cout << "\t\t" << "int real_id = id - TypeImpl<" << klass.Parent << ">::StaticGetFieldCount(); " << std::endl
                                  << "\t\t" << "if (real_id < 0) { " << klass.Parent << "::SetField(id, value); return; }" << std::endl;
 
                std::cout << "\t\t" << "switch (";
@@ -257,7 +257,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo& locp)
                                  << "\t" << "{" << std::endl;
 
                if (!klass.Parent.empty())
-                       std::cout << "\t\t" << "int real_id = id - ReflectionTypeImpl<" << klass.Parent << ">::StaticGetFieldCount(); " << std::endl
+                       std::cout << "\t\t" << "int real_id = id - TypeImpl<" << klass.Parent << ">::StaticGetFieldCount(); " << std::endl
                                          << "\t\t" << "if (real_id < 0) { return " << klass.Parent << "::GetField(id); }" << std::endl;
 
                std::cout << "\t\t" << "switch (";
@@ -368,7 +368,8 @@ void ClassCompiler::CompileStream(const std::string& path, std::istream *stream)
 {
        stream->exceptions(std::istream::badbit);
 
-       std::cout << "#include \"base/reflectionobject.h\"" << std::endl
+       std::cout << "#include \"base/object.h\"" << std::endl
+                         << "#include \"base/type.h\"" << std::endl
                          << "#include \"base/singleton.h\"" << std::endl
                          << "#include \"base/debug.h\"" << std::endl
                          << "#include \"base/value.h\"" << std::endl