]> granicus.if.org Git - icinga2/commitdiff
Implement class compiler.
authorGunnar Beutner <gunnar@beutner.name>
Sat, 26 Oct 2013 07:41:45 +0000 (09:41 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Mon, 28 Oct 2013 13:27:36 +0000 (14:27 +0100)
Refs #4963

153 files changed:
.gitignore
components/checker/Makefile.am
components/checker/checkercomponent.ti [new file with mode: 0644]
components/cluster/Makefile.am
components/cluster/clusterlistener.cpp
components/cluster/clusterlistener.h
components/cluster/clusterlistener.ti [new file with mode: 0644]
components/cluster/endpoint.cpp
components/cluster/endpoint.h
components/cluster/endpoint.ti [new file with mode: 0644]
components/compat/Makefile.am
components/compat/checkresultreader.cpp
components/compat/checkresultreader.h
components/compat/checkresultreader.ti [new file with mode: 0644]
components/compat/compatlogger.cpp
components/compat/compatlogger.h
components/compat/compatlogger.ti [new file with mode: 0644]
components/compat/externalcommandlistener.cpp
components/compat/externalcommandlistener.h
components/compat/externalcommandlistener.ti [new file with mode: 0644]
components/compat/statusdatawriter.cpp
components/compat/statusdatawriter.h
components/compat/statusdatawriter.ti [new file with mode: 0644]
components/db_ido_mysql/Makefile.am
components/db_ido_mysql/idomysqlconnection.cpp
components/db_ido_mysql/idomysqlconnection.h
components/db_ido_mysql/idomysqlconnection.ti [new file with mode: 0644]
components/demo/Makefile.am
components/demo/demo.h
components/demo/demo.ti [new file with mode: 0644]
components/livestatus/Makefile.am
components/livestatus/commentstable.cpp
components/livestatus/downtimestable.cpp
components/livestatus/hoststable.cpp
components/livestatus/listener.cpp
components/livestatus/listener.h
components/livestatus/listener.ti [new file with mode: 0644]
components/livestatus/servicestable.cpp
components/livestatus/statustable.cpp
components/notification/Makefile.am
components/notification/notificationcomponent.h
components/notification/notificationcomponent.ti [new file with mode: 0644]
components/perfdata/Makefile.am
components/perfdata/graphitewriter.cpp
components/perfdata/graphitewriter.h
components/perfdata/graphitewriter.ti [new file with mode: 0644]
components/perfdata/perfdatawriter.cpp
components/perfdata/perfdatawriter.h
components/perfdata/perfdatawriter.ti [new file with mode: 0644]
configure.ac
doc/4.3-object-types.md
icinga-app/icinga.cpp
icinga2.sln
lib/base/Makefile.am
lib/base/application.cpp
lib/base/application.h
lib/base/application.ti [new file with mode: 0644]
lib/base/base.vcxproj
lib/base/base.vcxproj.filters
lib/base/consolelogger.h
lib/base/consolelogger.ti [new file with mode: 0644]
lib/base/debug.h
lib/base/dynamicobject.cpp
lib/base/dynamicobject.h
lib/base/dynamicobject.ti [new file with mode: 0644]
lib/base/filelogger.cpp
lib/base/filelogger.h
lib/base/filelogger.ti [new file with mode: 0644]
lib/base/logger.cpp
lib/base/logger.h
lib/base/logger.ti [new file with mode: 0644]
lib/base/process-unix.cpp
lib/base/reflectionobject.cpp [new file with mode: 0644]
lib/base/reflectionobject.h [new file with mode: 0644]
lib/base/script.cpp
lib/base/script.h
lib/base/script.ti [new file with mode: 0644]
lib/base/streamlogger.h
lib/base/streamlogger.ti [new file with mode: 0644]
lib/base/sysloglogger.h
lib/base/sysloglogger.ti [new file with mode: 0644]
lib/db_ido/Makefile.am
lib/db_ido/db_ido.vcxproj
lib/db_ido/db_ido.vcxproj.filters
lib/db_ido/dbconnection.cpp
lib/db_ido/dbconnection.h
lib/db_ido/dbconnection.ti [new file with mode: 0644]
lib/db_ido/servicedbobject.cpp
lib/icinga/Makefile.am
lib/icinga/checkcommand.h
lib/icinga/checkcommand.ti [new file with mode: 0644]
lib/icinga/command.cpp
lib/icinga/command.h
lib/icinga/command.ti [new file with mode: 0644]
lib/icinga/compatutility.cpp
lib/icinga/domain.cpp
lib/icinga/domain.h
lib/icinga/domain.ti [new file with mode: 0644]
lib/icinga/eventcommand.h
lib/icinga/eventcommand.ti [new file with mode: 0644]
lib/icinga/host.cpp
lib/icinga/host.h
lib/icinga/host.ti [new file with mode: 0644]
lib/icinga/hostgroup.cpp
lib/icinga/hostgroup.h
lib/icinga/hostgroup.ti [new file with mode: 0644]
lib/icinga/icinga.vcxproj
lib/icinga/icinga.vcxproj.filters
lib/icinga/icingaapplication.cpp
lib/icinga/icingaapplication.h
lib/icinga/icingaapplication.ti [new file with mode: 0644]
lib/icinga/notification.cpp
lib/icinga/notification.h
lib/icinga/notification.ti [new file with mode: 0644]
lib/icinga/notificationcommand.h
lib/icinga/notificationcommand.ti [new file with mode: 0644]
lib/icinga/pluginnotificationtask.cpp
lib/icinga/service-check.cpp
lib/icinga/service-comment.cpp
lib/icinga/service-downtime.cpp
lib/icinga/service-event.cpp
lib/icinga/service-flapping.cpp
lib/icinga/service-notification.cpp
lib/icinga/service.cpp
lib/icinga/service.h
lib/icinga/service.ti [new file with mode: 0644]
lib/icinga/servicegroup.cpp
lib/icinga/servicegroup.h
lib/icinga/servicegroup.ti [new file with mode: 0644]
lib/icinga/timeperiod.cpp
lib/icinga/timeperiod.h
lib/icinga/timeperiod.ti [new file with mode: 0644]
lib/icinga/user.cpp
lib/icinga/user.h
lib/icinga/user.ti [new file with mode: 0644]
lib/icinga/usergroup.cpp
lib/icinga/usergroup.h
lib/icinga/usergroup.ti [new file with mode: 0644]
third-party/execvpe/execvpe.c
third-party/execvpe/execvpe.h
tools/Makefile.am
tools/mkclass/.gitignore [new file with mode: 0644]
tools/mkclass/Makefile.am [new file with mode: 0644]
tools/mkclass/base.int [new file with mode: 0644]
tools/mkclass/class_lexer.ll [new file with mode: 0644]
tools/mkclass/class_parser.yy [new file with mode: 0644]
tools/mkclass/classcompiler.cpp [new file with mode: 0644]
tools/mkclass/classcompiler.h [new file with mode: 0644]
tools/mkclass/icinga.int [new file with mode: 0644]
tools/mkclass/mkclass.cpp [new file with mode: 0644]
tools/mkclass/mkclass.filters [new file with mode: 0644]
tools/mkclass/mkclass.vcxproj [new file with mode: 0644]
tools/mkclass/packages.config [new file with mode: 0644]

index a70e3e9fab7d7f16ee16f1b054ca10cb89b01d54..d0804d04d420eafa492a84f7a440a295a4bc592f 100644 (file)
@@ -11,6 +11,7 @@ ipch
 *.gcda
 *.o
 *.a
+*.th
 .deps
 *.in
 Makefile
index 600edef7016a32e05111f8a557598759ada0fda9..22945b025a13b8819df885ea3a544c0aa27e31ea 100644 (file)
@@ -3,15 +3,22 @@
 pkglib_LTLIBRARIES = \
        libchecker.la
 
+BUILT_SOURCES = \
+       checkercomponent.th
+
 CLEANFILES = \
        checker-type.cpp
 
 .conf.cpp: $(top_builddir)/tools/mkembedconfig/mkembedconfig
        $(top_builddir)/tools/mkembedconfig/mkembedconfig $< $@
 
+.ti.th: $(top_builddir)/tools/mkclass/mkclass
+       $(top_builddir)/tools/mkclass/mkclass $< > $@
+
 libchecker_la_SOURCES = \
        checkercomponent.cpp \
        checkercomponent.h \
+       checkercomponent.th \
        checker-type.conf
 
 libchecker_la_CPPFLAGS = \
diff --git a/components/checker/checkercomponent.ti b/components/checker/checkercomponent.ti
new file mode 100644 (file)
index 0000000..38d38bd
--- /dev/null
@@ -0,0 +1,10 @@
+#include "base/dynamicobject.h"
+
+namespace icinga
+{
+
+class CheckerComponent : DynamicObject
+{
+};
+
+}
index f8a0cceb23f3c5fba1277bc2c00e0f3756e4206d..89eec5be8884fb4419ecf06634ddb6eb548a9b5a 100644 (file)
@@ -3,18 +3,27 @@
 pkglib_LTLIBRARIES = \
        libcluster.la
 
+BUILT_SOURCES = \
+       clusterlistener.th \
+       endpoint.th
+
 CLEANFILES = \
        cluster-type.cpp
 
 .conf.cpp: $(top_builddir)/tools/mkembedconfig/mkembedconfig
        $(top_builddir)/tools/mkembedconfig/mkembedconfig $< $@
 
+.ti.th: $(top_builddir)/tools/mkclass/mkclass
+       $(top_builddir)/tools/mkclass/mkclass $< > $@
+
 libcluster_la_SOURCES = \
        clusterlistener.cpp \
        clusterlistener.h \
+       clusterlistener.ti \
        cluster-type.conf \
        endpoint.cpp \
        endpoint.h \
+       endpoint.ti \
        jsonrpc.cpp \
        jsonrpc.h
 
index 32828005bde54422f04814b3b37d4a7e3319ffd0..9ece96ae54066afc4d0a027040752a863acea90e 100644 (file)
@@ -51,16 +51,16 @@ void ClusterListener::Start(void)
        }
 
        /* set up SSL context */
-       shared_ptr<X509> cert = GetX509Certificate(GetCertificateFile());
-       m_Identity = GetCertificateCN(cert);
-       Log(LogInformation, "cluster", "My identity: " + m_Identity);
+       shared_ptr<X509> cert = GetX509Certificate(GetCertPath());
+       SetIdentity(GetCertificateCN(cert));
+       Log(LogInformation, "cluster", "My identity: " + GetIdentity());
 
        Endpoint::Ptr self = Endpoint::GetByName(GetIdentity());
 
        if (!self)
                BOOST_THROW_EXCEPTION(std::invalid_argument("No configuration available for the local endpoint."));
 
-       m_SSLContext = MakeSSLContext(GetCertificateFile(), GetKeyFile(), GetCAFile());
+       m_SSLContext = MakeSSLContext(GetCertPath(), GetKeyPath(), GetCaPath());
 
        /* create the primary JSON-RPC listener */
        if (!GetBindPort().IsEmpty())
@@ -127,62 +127,11 @@ void ClusterListener::Stop(void)
        RotateLogFile();
 }
 
-String ClusterListener::GetCertificateFile(void) const
-{
-       ObjectLock olock(this);
-
-       return m_CertPath;
-}
-
-String ClusterListener::GetKeyFile(void) const
-{
-       ObjectLock olock(this);
-
-       return m_KeyPath;
-}
-
-String ClusterListener::GetCAFile(void) const
-{
-       ObjectLock olock(this);
-
-       return m_CAPath;
-}
-
-String ClusterListener::GetBindHost(void) const
-{
-       ObjectLock olock(this);
-
-       return m_BindHost;
-}
-
-String ClusterListener::GetBindPort(void) const
-{
-       ObjectLock olock(this);
-
-       return m_BindPort;
-}
-
-Array::Ptr ClusterListener::GetPeers(void) const
-{
-       ObjectLock olock(this);
-
-       return m_Peers;
-}
-
 shared_ptr<SSL_CTX> ClusterListener::GetSSLContext(void) const
 {
-       ObjectLock olock(this);
-
        return m_SSLContext;
 }
 
-String ClusterListener::GetIdentity(void) const
-{
-       ObjectLock olock(this);
-
-       return m_Identity;
-}
-
 /**
  * Creates a new JSON-RPC listener on the specified port.
  *
@@ -270,7 +219,7 @@ void ClusterListener::PersistMessage(const Endpoint::Ptr& source, const Dictiona
                String json = Value(pmessage).Serialize();
                NetString::WriteStringToStream(m_LogFile, json);
                m_LogMessageCount++;
-               m_LogMessageTimestamp = ts;
+               SetLogMessageTimestamp(ts);
 
                if (m_LogMessageCount > 50000) {
                        CloseLogFile();
@@ -330,7 +279,7 @@ void ClusterListener::RelayMessage(const Endpoint::Ptr& source, const Dictionary
                {
                        ObjectLock olock(endpoint);
 
-                       if (!endpoint->IsSyncing())
+                       if (!endpoint->GetSyncing())
                                endpoint->SendMessage(message);
                }
        }
@@ -361,7 +310,7 @@ void ClusterListener::OpenLogFile(void)
        m_LogFile = logStream;
 #endif /* HAVE_BIOZLIB */
        m_LogMessageCount = 0;
-       m_LogMessageTimestamp = 0;
+       SetLogMessageTimestamp(0);
 }
 
 void ClusterListener::CloseLogFile(void)
@@ -380,7 +329,7 @@ void ClusterListener::RotateLogFile(void)
 {
        ASSERT(OwnsLock());
 
-       double ts = m_LogMessageTimestamp;
+       double ts = GetLogMessageTimestamp();
 
        if (ts == 0)
                ts = Utility::GetTime();
@@ -1579,37 +1528,3 @@ bool ClusterListener::SupportsNotifications(void)
 
        return !type->GetObjects().empty() && IcingaApplication::GetInstance()->GetEnableNotifications();
 }
-
-void ClusterListener::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
-{
-       DynamicObject::InternalSerialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               bag->Set("cert_path", m_CertPath);
-               bag->Set("key_path", m_KeyPath);
-               bag->Set("ca_path", m_CAPath);
-               bag->Set("bind_host", m_BindHost);
-               bag->Set("bind_port", m_BindPort);
-               bag->Set("peers", m_Peers);
-       }
-
-       if (attributeTypes & Attribute_State)
-               bag->Set("log_message_timestamp", m_LogMessageTimestamp);
-}
-
-void ClusterListener::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
-{
-       DynamicObject::InternalDeserialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               m_CertPath = bag->Get("cert_path");
-               m_KeyPath = bag->Get("key_path");
-               m_CAPath = bag->Get("ca_path");
-               m_BindHost = bag->Get("bind_host");
-               m_BindPort = bag->Get("bind_port");
-               m_Peers = bag->Get("peers");
-       }
-
-       if (attributeTypes & Attribute_State)
-               m_LogMessageTimestamp = bag->Get("log_message_timestamp");
-}
index a057880c698aea786088b41c66a6de7ce239e4cb..a5abcb4bf4dc067455f905ab047e577398592953 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef CLUSTERLISTENER_H
 #define CLUSTERLISTENER_H
 
+#include "cluster/clusterlistener.th"
 #include "base/dynamicobject.h"
 #include "base/timer.h"
 #include "base/array.h"
@@ -38,7 +39,7 @@ namespace icinga
 /**
  * @ingroup cluster
  */
-class ClusterListener : public DynamicObject
+class ClusterListener : public ReflectionObjectImpl<ClusterListener>
 {
 public:
        DECLARE_PTR_TYPEDEFS(ClusterListener);
@@ -47,31 +48,11 @@ public:
        virtual void Start(void);
        virtual void Stop(void);
 
-       String GetCertificateFile(void) const;
-       String GetKeyFile(void) const;
-       String GetCAFile(void) const;
-       String GetBindHost(void) const;
-       String GetBindPort(void) const;
-       Array::Ptr GetPeers(void) const;
-       String GetClusterDir(void) const;
-
        shared_ptr<SSL_CTX> GetSSLContext(void) const;
-       String GetIdentity(void) const;
-
-protected:
-       virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
-       virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
+       String GetClusterDir(void) const;
 
 private:
-       String m_CertPath;
-       String m_KeyPath;
-       String m_CAPath;
-       String m_BindHost;
-       String m_BindPort;
-       Array::Ptr m_Peers;
-
        shared_ptr<SSL_CTX> m_SSLContext;
-       String m_Identity;
 
        WorkQueue m_RelayQueue;
        WorkQueue m_MessageQueue;
@@ -100,7 +81,6 @@ private:
        void ReplayLog(const Endpoint::Ptr& endpoint, const Stream::Ptr& stream);
 
        Stream::Ptr m_LogFile;
-       double m_LogMessageTimestamp;
        size_t m_LogMessageCount;
 
        void CheckResultHandler(const Service::Ptr& service, const Dictionary::Ptr& cr, const String& authority);
diff --git a/components/cluster/clusterlistener.ti b/components/cluster/clusterlistener.ti
new file mode 100644 (file)
index 0000000..420a39e
--- /dev/null
@@ -0,0 +1,18 @@
+#include "base/dynamicobject.h"
+
+namespace icinga
+{
+
+class ClusterListener : DynamicObject
+{
+       [config] String cert_path;
+       [config] String key_path;
+       [config] String ca_path;
+       [config] String bind_host;
+       [config] String bind_port;
+       [config] Array::Ptr peers;
+       [state] double log_message_timestamp;
+       String identity;
+};
+
+}
index 8ba326c798c92e954b28a542c025b7016d6c08a5..18bf6ea432527aeeb76c005f3e443fe4470095f4 100644 (file)
@@ -34,10 +34,6 @@ REGISTER_TYPE(Endpoint);
 boost::signals2::signal<void (const Endpoint::Ptr&)> Endpoint::OnConnected;
 boost::signals2::signal<void (const Endpoint::Ptr&, const Dictionary::Ptr&)> Endpoint::OnMessageReceived;
 
-Endpoint::Endpoint(void)
-       : m_Syncing(false)
-{ }
-
 /**
  * Checks whether this endpoint is connected.
  *
@@ -107,86 +103,6 @@ void Endpoint::MessageThreadProc(const Stream::Ptr& stream)
        }
 }
 
-/**
- * Gets the node address for this endpoint.
- *
- * @returns The node address (hostname).
- */
-String Endpoint::GetHost(void) const
-{
-       return m_Host;
-}
-
-/**
- * Gets the service name for this endpoint.
- *
- * @returns The service name (port).
- */
-String Endpoint::GetPort(void) const
-{
-       return m_Port;
-}
-
-Array::Ptr Endpoint::GetConfigFiles(void) const
-{
-       return m_ConfigFiles;
-}
-
-Array::Ptr Endpoint::GetAcceptConfig(void) const
-{
-       return m_AcceptConfig;
-}
-
-double Endpoint::GetSeen(void) const
-{
-       return m_Seen;
-}
-
-void Endpoint::SetSeen(double ts)
-{
-       m_Seen = ts;
-}
-
-double Endpoint::GetLocalLogPosition(void) const
-{
-       return m_LocalLogPosition;
-}
-
-void Endpoint::SetLocalLogPosition(double ts)
-{
-       m_LocalLogPosition = ts;
-}
-
-double Endpoint::GetRemoteLogPosition(void) const
-{
-       return m_RemoteLogPosition;
-}
-
-void Endpoint::SetRemoteLogPosition(double ts)
-{
-       m_RemoteLogPosition = ts;
-}
-
-bool Endpoint::IsSyncing(void) const
-{
-       return m_Syncing;
-}
-
-void Endpoint::SetSyncing(bool syncing)
-{
-       m_Syncing = syncing;
-}
-
-Dictionary::Ptr Endpoint::GetFeatures(void) const
-{
-       return m_Features;
-}
-
-void Endpoint::SetFeatures(const Dictionary::Ptr& features)
-{
-       m_Features = features;
-}
-
 bool Endpoint::HasFeature(const String& type) const
 {
        Dictionary::Ptr features = GetFeatures();
@@ -197,40 +113,3 @@ bool Endpoint::HasFeature(const String& type) const
        return features->Get(type);
 }
 
-void Endpoint::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
-{
-       DynamicObject::InternalSerialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               bag->Set("host", m_Host);
-               bag->Set("port", m_Port);
-               bag->Set("config_files", m_ConfigFiles);
-               bag->Set("accept_config", m_AcceptConfig);
-       }
-
-       if (attributeTypes & Attribute_State) {
-               bag->Set("seen", m_Seen);
-               bag->Set("local_log_position", m_LocalLogPosition);
-               bag->Set("remote_log_position", m_RemoteLogPosition);
-               bag->Set("features", m_Features);
-       }
-}
-
-void Endpoint::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
-{
-       DynamicObject::InternalDeserialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               m_Host = bag->Get("host");
-               m_Port = bag->Get("port");
-               m_ConfigFiles = bag->Get("config_files");
-               m_AcceptConfig = bag->Get("accept_config");
-       }
-
-       if (attributeTypes & Attribute_State) {
-               m_Seen = bag->Get("seen");
-               m_LocalLogPosition = bag->Get("local_log_position");
-               m_RemoteLogPosition = bag->Get("remote_log_position");
-               m_Features = bag->Get("features");
-       }
-}
index 04e3a7490d1e20020bd9659c5cf4bd27d80c6c21..50807b4a840096d75a77424ca7ef0dc1824b8523 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef ENDPOINT_H
 #define ENDPOINT_H
 
-#include "base/dynamicobject.h"
+#include "cluster/endpoint.th"
 #include "base/stream.h"
 #include "base/array.h"
 #include <boost/signals2.hpp>
@@ -35,14 +35,12 @@ class EndpointManager;
  *
  * @ingroup cluster
  */
-class Endpoint : public DynamicObject
+class Endpoint : public ReflectionObjectImpl<Endpoint>
 {
 public:
        DECLARE_PTR_TYPEDEFS(Endpoint);
        DECLARE_TYPENAME(Endpoint);
 
-       Endpoint(void);
-
        static boost::signals2::signal<void (const Endpoint::Ptr&)> OnConnected;
        static boost::signals2::signal<void (const Endpoint::Ptr&, const Dictionary::Ptr&)> OnMessageReceived;
 
@@ -53,46 +51,10 @@ public:
 
        void SendMessage(const Dictionary::Ptr& request);
 
-       String GetHost(void) const;
-       String GetPort(void) const;
-       Array::Ptr GetConfigFiles(void) const;
-       Array::Ptr GetAcceptConfig(void) const;
-
-       double GetSeen(void) const;
-       void SetSeen(double ts);
-
-       double GetLocalLogPosition(void) const;
-       void SetLocalLogPosition(double ts);
-
-       double GetRemoteLogPosition(void) const;
-       void SetRemoteLogPosition(double ts);
-
-       Dictionary::Ptr GetFeatures(void) const;
-       void SetFeatures(const Dictionary::Ptr& features);
-
        bool HasFeature(const String& type) const;
 
-       bool IsSyncing(void) const;
-       void SetSyncing(bool syncing);
-
-protected:
-       virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
-       virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
-
 private:
-       Dictionary::Ptr m_Subscriptions;
-       String m_Host;
-       String m_Port;
-       Array::Ptr m_ConfigFiles;
-       Array::Ptr m_AcceptConfig;
-
        Stream::Ptr m_Client;
-       double m_Seen;
-       double m_LocalLogPosition;
-       double m_RemoteLogPosition;
-       Dictionary::Ptr m_Features;
-       bool m_Syncing;
-
        boost::thread m_Thread;
 
        void MessageThreadProc(const Stream::Ptr& stream);
diff --git a/components/cluster/endpoint.ti b/components/cluster/endpoint.ti
new file mode 100644 (file)
index 0000000..b54b464
--- /dev/null
@@ -0,0 +1,23 @@
+#include "base/dynamicobject.h"
+
+namespace icinga
+{
+
+class Endpoint : DynamicObject
+{
+       [config] String host;
+       [config] String port;
+       [config] Array::Ptr config_files;
+       [config] Array::Ptr accept_config;
+
+       [state] double seen;
+       [state] double local_log_position;
+       [state] double remote_log_position;
+       [state] Dictionary::Ptr features;
+
+       bool syncing {
+               default {{{ return false; }}}
+       };
+};
+
+}
index 030ca3c4755d6c9497f4b49a5d2fa147c17b92ea..279689fe6eb146f11d71980de58c4485bfca4e49 100644 (file)
@@ -3,21 +3,34 @@
 pkglib_LTLIBRARIES = \
        libcompat.la
 
+BUILT_SOURCES = \
+       checkresultreader.th \
+       externalcommandlistener.th \
+       statusdatawriter.th \
+       compatlogger.th
+
 CLEANFILES = \
        compat-type.cpp
 
 .conf.cpp: $(top_builddir)/tools/mkembedconfig/mkembedconfig
        $(top_builddir)/tools/mkembedconfig/mkembedconfig $< $@
 
+.ti.th: $(top_builddir)/tools/mkclass/mkclass
+       $(top_builddir)/tools/mkclass/mkclass $< > $@
+
 libcompat_la_SOURCES = \
        checkresultreader.cpp \
        checkresultreader.h \
+       checkresultreader.th \
        externalcommandlistener.cpp \
        externalcommandlistener.h \
+       externalcommandlistener.th \
        statusdatawriter.cpp \
        statusdatawriter.h \
+       statusdatawriter.th \
        compatlogger.cpp \
        compatlogger.h \
+       compatlogger.th \
        compat-type.conf
 
 libcompat_la_CPPFLAGS = \
index 55d680c6e8c9a4d72e7b525f3a91cb227165ef85..03df0211c59d005728b5abb81c2dc30002b041d3 100644 (file)
@@ -44,17 +44,6 @@ void CheckResultReader::Start(void)
        m_ReadTimer->Start();
 }
 
-/**
- * @threadsafety Always.
- */
-String CheckResultReader::GetSpoolDir(void) const
-{
-       if (!m_SpoolDir.IsEmpty())
-               return m_SpoolDir;
-       else
-               return Application::GetLocalStateDir() + "/lib/icinga2/spool/checkresults/";
-}
-
 /**
  * @threadsafety Always.
  */
@@ -134,18 +123,3 @@ void CheckResultReader::ProcessCheckResultFile(const String& path) const
        }
 }
 
-void CheckResultReader::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
-{
-       DynamicObject::InternalSerialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config)
-               bag->Set("spool_dir", m_SpoolDir);
-}
-
-void CheckResultReader::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
-{
-       DynamicObject::InternalDeserialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config)
-               m_SpoolDir = bag->Get("spool_dir");
-}
index a66aa4b445502833bd63ff1a9424f7eab8d97606..939f7afcb8e595a7520b1d2539456a3d56a73edb 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef CHECKRESULTREADER_H
 #define CHECKRESULTREADER_H
 
-#include "base/dynamicobject.h"
+#include "compat/checkresultreader.th"
 #include "base/timer.h"
 #include <fstream>
 
@@ -32,23 +32,16 @@ namespace icinga
  *
  * @ingroup compat
  */
-class CheckResultReader : public DynamicObject
+class CheckResultReader : public ReflectionObjectImpl<CheckResultReader>
 {
 public:
        DECLARE_PTR_TYPEDEFS(CheckResultReader);
        DECLARE_TYPENAME(CheckResultReader);
 
-       String GetSpoolDir(void) const;
-
 protected:
        virtual void Start(void);
 
-       virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
-       virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
-
 private:
-       String m_SpoolDir;
-
        Timer::Ptr m_ReadTimer;
        void ReadTimerHandler(void) const;
        void ProcessCheckResultFile(const String& path) const;
diff --git a/components/compat/checkresultreader.ti b/components/compat/checkresultreader.ti
new file mode 100644 (file)
index 0000000..6daee2d
--- /dev/null
@@ -0,0 +1,14 @@
+#include "base/dynamicobject.h"
+#include "base/application.h"
+
+namespace icinga
+{
+
+class CheckResultReader : DynamicObject
+{
+       [config] String spool_dir {
+               default {{{ return Application::GetLocalStateDir() + "/lib/icinga2/spool/checkresults/"; }}}
+       };
+};
+
+}
index 7ce65879ce0df16ecc4e02ce0c663d86cf00d0a5..82d0dbadc4db03cb2af9dd817692dd0961628e2d 100644 (file)
@@ -67,28 +67,6 @@ void CompatLogger::Start(void)
        ScheduleNextRotation();
 }
 
-/**
- * @threadsafety Always.
- */
-String CompatLogger::GetLogDir(void) const
-{
-       if (!m_LogDir.IsEmpty())
-               return m_LogDir;
-       else
-               return Application::GetLocalStateDir() + "/log/icinga2/compat";
-}
-
-/**
- * @threadsafety Always.
- */
-String CompatLogger::GetRotationMethod(void) const
-{
-       if (!m_RotationMethod.IsEmpty())
-               return m_RotationMethod;
-       else
-               return "HOURLY";
-}
-
 /**
  * @threadsafety Always.
  */
@@ -412,10 +390,8 @@ void CompatLogger::FlappingHandler(const Service::Ptr& service, FlappingState fl
                 ObjectLock oLock(this);
                 Flush();
         }
-
 }
 
-
 void CompatLogger::ExternalCommandHandler(const String& command, const std::vector<String>& arguments)
 {
         std::ostringstream msgbuf;
@@ -496,7 +472,7 @@ void CompatLogger::ReopenFile(bool rotate)
                       << host->GetName() << ";"
                       << Host::StateToString(Host::CalculateState(hc->GetState(), reachable)) << ";"
                       << Service::StateTypeToString(hc->GetStateType()) << ";"
-                      << hc->GetCurrentCheckAttempt() << ";"
+                      << hc->GetCheckAttempt() << ";"
                       << "";
 
                WriteLine(msgbuf.str());
@@ -514,7 +490,7 @@ void CompatLogger::ReopenFile(bool rotate)
                       << service->GetShortName() << ";"
                       << Service::StateToString(service->GetState()) << ";"
                       << Service::StateTypeToString(service->GetStateType()) << ";"
-                      << service->GetCurrentCheckAttempt() << ";"
+                      << service->GetCheckAttempt() << ";"
                       << "";
 
                WriteLine(msgbuf.str());
@@ -599,22 +575,3 @@ void CompatLogger::ValidateRotationMethod(const String& location, const Dictiona
        }
 }
 
-void CompatLogger::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
-{
-       DynamicObject::InternalSerialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               bag->Set("log_dir", m_LogDir);
-               bag->Set("rotation_method", m_RotationMethod);
-       }
-}
-
-void CompatLogger::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
-{
-       DynamicObject::InternalDeserialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               m_LogDir = bag->Get("log_dir");
-               m_RotationMethod = bag->Get("rotation_method");
-       }
-}
index 8b84ed3906cb61d5afd0e35cefc524bb026b42b9..5374e0982465aa2863fc801d0c9d2fb30efec4cf 100644 (file)
@@ -20,8 +20,8 @@
 #ifndef COMPATLOGGER_H
 #define COMPATLOGGER_H
 
+#include "compat/compatlogger.th"
 #include "icinga/service.h"
-#include "base/dynamicobject.h"
 #include "base/timer.h"
 #include <fstream>
 
@@ -33,7 +33,7 @@ namespace icinga
  *
  * @ingroup compat
  */
-class CompatLogger : public DynamicObject
+class CompatLogger : public ReflectionObjectImpl<CompatLogger>
 {
 public:
        DECLARE_PTR_TYPEDEFS(CompatLogger);
@@ -41,21 +41,12 @@ public:
 
        CompatLogger(void);
 
-       String GetLogDir(void) const;
-       String GetRotationMethod(void) const;
-
        static void ValidateRotationMethod(const String& location, const Dictionary::Ptr& attrs);
 
 protected:
        virtual void Start(void);
 
-       virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
-       virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
-
 private:
-       String m_LogDir;
-       String m_RotationMethod;
-
        double m_LastRotation;
 
        void WriteLine(const String& line);
diff --git a/components/compat/compatlogger.ti b/components/compat/compatlogger.ti
new file mode 100644 (file)
index 0000000..957ec3f
--- /dev/null
@@ -0,0 +1,17 @@
+#include "base/dynamicobject.h"
+#include "base/application.h"
+
+namespace icinga
+{
+
+class CompatLogger : DynamicObject
+{
+       [config] String log_dir {
+               default {{{ return Application::GetLocalStateDir() + "/log/icinga2/compat"; }}}
+       };
+       [config] String rotation_method {
+               default {{{ return "HOURLY"; }}}
+       };
+};
+
+}
index 22e62c735b3949e4a133cabf0d509234c5025e59..59901058813a634422a2a5e6b0c557228132c21c 100644 (file)
@@ -42,20 +42,6 @@ void ExternalCommandListener::Start(void)
 #endif /* _WIN32 */
 }
 
-/**
- * Retrieves the icinga.cmd path.
- *
- * @returns icinga.cmd path
- */
-String ExternalCommandListener::GetCommandPath(void) const
-{
-       if (m_CommandPath.IsEmpty())
-               return Application::GetLocalStateDir() + "/run/icinga2/cmd/icinga2.cmd";
-       else
-               return m_CommandPath;
-}
-
-
 #ifndef _WIN32
 void ExternalCommandListener::CommandPipeThread(const String& commandPath)
 {
@@ -143,19 +129,3 @@ void ExternalCommandListener::CommandPipeThread(const String& commandPath)
        }
 }
 #endif /* _WIN32 */
-
-void ExternalCommandListener::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
-{
-       DynamicObject::InternalSerialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config)
-               bag->Set("command_path", m_CommandPath);
-}
-
-void ExternalCommandListener::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
-{
-       DynamicObject::InternalDeserialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config)
-               m_CommandPath = bag->Get("command_path");
-}
index e4b468e900ca7bc89e03d7663a815b1a18581322..e07b332b2ee45d59358a9ce81ba88f8079ee2403 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef EXTERNALCOMMANDLISTENER_H
 #define EXTERNALCOMMANDLISTENER_H
 
-#include "base/dynamicobject.h"
+#include "compat/externalcommandlistener.th"
 #include "base/objectlock.h"
 #include "base/timer.h"
 #include "base/utility.h"
@@ -33,7 +33,7 @@ namespace icinga
 /**
  * @ingroup compat
  */
-class ExternalCommandListener : public DynamicObject
+class ExternalCommandListener : public ReflectionObjectImpl<ExternalCommandListener>
 {
 public:
        DECLARE_PTR_TYPEDEFS(ExternalCommandListener);
@@ -41,19 +41,12 @@ public:
 protected:
        virtual void Start(void);
 
-       virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
-       virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
-
 private:
-       String m_CommandPath;
-
 #ifndef _WIN32
        boost::thread m_CommandThread;
 
        void CommandPipeThread(const String& commandPath);
 #endif /* _WIN32 */
-
-       String GetCommandPath(void) const;
 };
 
 }
diff --git a/components/compat/externalcommandlistener.ti b/components/compat/externalcommandlistener.ti
new file mode 100644 (file)
index 0000000..70f9fd0
--- /dev/null
@@ -0,0 +1,14 @@
+#include "base/dynamicobject.h"
+#include "base/application.h"
+
+namespace icinga
+{
+
+class ExternalCommandListener : DynamicObject
+{
+       [config] String command_path {
+               default {{{ return Application::GetLocalStateDir() + "/run/icinga2/cmd/icinga2.cmd"; }}}
+       };
+};
+
+}
index 4e0b1c8c6b9b6685f8eac1dc8e1a48cd78664e41..72725b940bff91717c42170925a1e621ab763395 100644 (file)
@@ -64,40 +64,11 @@ void StatusDataWriter::Start(void)
        m_StatusTimer->Reschedule(0);
 }
 
-/**
- * Retrieves the status.dat path.
- *
- * @returns statuspath from config, or static default
- */
-String StatusDataWriter::GetStatusPath(void) const
-{
-       if (m_StatusPath.IsEmpty())
-               return Application::GetLocalStateDir() + "/cache/icinga2/status.dat";
-       else
-               return m_StatusPath;
-}
-
-/**
- * Retrieves the objects.cache path.
- *
- * @returns objectspath from config, or static default
- */
-String StatusDataWriter::GetObjectsPath(void) const
-{
-       if (m_ObjectsPath.IsEmpty())
-               return Application::GetLocalStateDir() + "/cache/icinga2/objects.cache";
-       else
-               return m_ObjectsPath;
-}
-
 void StatusDataWriter::DumpComments(std::ostream& fp, const Service::Ptr& owner, CompatObjectType type)
 {
        Service::Ptr service;
        Dictionary::Ptr comments = owner->GetComments();
 
-       if (!comments)
-               return;
-
        Host::Ptr host = owner->GetHost();
 
        if (!host)
@@ -202,9 +173,6 @@ void StatusDataWriter::DumpDowntimes(std::ostream& fp, const Service::Ptr& owner
 
        Dictionary::Ptr downtimes = owner->GetDowntimes();
 
-       if (!downtimes)
-               return;
-
        ObjectLock olock(downtimes);
 
        String id;
@@ -474,7 +442,7 @@ void StatusDataWriter::DumpServiceObject(std::ostream& fp, const Service::Ptr& s
                   << "\t" << "active_checks_enabled" << "\t" << (service->GetEnableActiveChecks() ? 1 : 0) << "\n"
                   << "\t" << "passive_checks_enabled" << "\t" << (service->GetEnablePassiveChecks() ? 1 : 0) << "\n"
                   << "\t" << "flap_detection_enabled" << "\t" << (service->GetEnableFlapping() ? 1 : 0) << "\n"
-                  << "\t" << "is_volatile" << "\t" << (service->IsVolatile() ? 1 : 0) << "\n"
+                  << "\t" << "is_volatile" << "\t" << (service->GetVolatile() ? 1 : 0) << "\n"
                   << "\t" << "notifications_enabled" << "\t" << (service->GetEnableNotifications() ? 1 : 0) << "\n"
                   << "\t" << "notification_options" << "\t" << "u,w,c,r" << "\n"
                   << "\t" << "notification_interval" << "\t" << notification_interval / 60.0 << "\n"
@@ -610,7 +578,7 @@ void StatusDataWriter::StatusTimerHandler(void)
        statusfp << "programstatus {" << "\n"
                 << "\t" << "icinga_pid=" << Utility::GetPid() << "\n"
                 << "\t" << "daemon_mode=1" << "\n"
-                << "\t" << "program_start=" << static_cast<long>(IcingaApplication::GetInstance()->GetStartTime()) << "\n"
+                << "\t" << "program_start=" << static_cast<long>(Application::GetStartTime()) << "\n"
                 << "\t" << "active_service_checks_enabled=" << (IcingaApplication::GetInstance()->GetEnableChecks() ? 1 : 0) << "\n"
                 << "\t" << "passive_service_checks_enabled=1" << "\n"
                 << "\t" << "active_host_checks_enabled=1" << "\n"
@@ -782,22 +750,3 @@ void StatusDataWriter::StatusTimerHandler(void)
        }
 }
 
-void StatusDataWriter::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
-{
-       DynamicObject::InternalSerialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               bag->Set("status_path", m_StatusPath);
-               bag->Set("objects_path", m_ObjectsPath);
-       }
-}
-
-void StatusDataWriter::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
-{
-       DynamicObject::InternalDeserialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               m_StatusPath = bag->Get("status_path");
-               m_ObjectsPath = bag->Get("objects_path");
-       }
-}
index 2f63b12eb557c291bce0671f0c25c1c77fa1ccf1..ba9e8c922e12b1fd4999f4db6629e73b076c659c 100644 (file)
 #ifndef STATUSDATAWRITER_H
 #define STATUSDATAWRITER_H
 
+#include "compat/statusdatawriter.th"
 #include "icinga/host.h"
 #include "icinga/service.h"
 #include "icinga/command.h"
 #include "icinga/compatutility.h"
-#include "base/dynamicobject.h"
 #include "base/objectlock.h"
 #include "base/timer.h"
 #include "base/utility.h"
@@ -37,7 +37,7 @@ namespace icinga
 /**
  * @ingroup compat
  */
-class StatusDataWriter : public DynamicObject
+class StatusDataWriter : public ReflectionObjectImpl<StatusDataWriter>
 {
 public:
        DECLARE_PTR_TYPEDEFS(StatusDataWriter);
@@ -45,18 +45,9 @@ public:
 protected:
        virtual void Start(void);
 
-       virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
-       virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
-
 private:
-       String m_StatusPath;
-       String m_ObjectsPath;
-
        Timer::Ptr m_StatusTimer;
 
-       String GetStatusPath(void) const;
-       String GetObjectsPath(void) const;
-
        void DumpCommand(std::ostream& fp, const Command::Ptr& command);
        void DumpTimePeriod(std::ostream& fp, const TimePeriod::Ptr& tp);
        void DumpDowntimes(std::ostream& fp, const Service::Ptr& owner, CompatObjectType type);
diff --git a/components/compat/statusdatawriter.ti b/components/compat/statusdatawriter.ti
new file mode 100644 (file)
index 0000000..ff6efb2
--- /dev/null
@@ -0,0 +1,17 @@
+#include "base/dynamicobject.h"
+#include "base/application.h"
+
+namespace icinga
+{
+
+class StatusDataWriter : DynamicObject
+{
+       [config] String status_path {
+               default {{{ return Application::GetLocalStateDir() + "/cache/icinga2/status.dat"; }}}
+       };
+       [config] String objects_path {
+               default {{{ return Application::GetLocalStateDir() + "/cache/icinga2/objects.cache"; }}}
+       };
+};
+
+}
index 975215f34d2327c459b11244b1d4e5d2d3283767..6e8b8137cd4b3c49c913e3e33bfc9ab2c77aa146 100644 (file)
@@ -8,16 +8,23 @@ SUBDIRS = \
 pkglib_LTLIBRARIES = \
        libdb_ido_mysql.la
 
+BUILT_SOURCES = \
+       idomysqlconnection.th
+
 CLEANFILES = \
        db_ido_mysql-type.cpp
 
 .conf.cpp: $(top_builddir)/tools/mkembedconfig/mkembedconfig
        $(top_builddir)/tools/mkembedconfig/mkembedconfig $< $@
 
+.ti.th: $(top_builddir)/tools/mkclass/mkclass
+       $(top_builddir)/tools/mkclass/mkclass $< > $@
+
 libdb_ido_mysql_la_SOURCES = \
        db_ido_mysql-type.conf \
        idomysqlconnection.cpp \
-       idomysqlconnection.h
+       idomysqlconnection.h \
+       idomysqlconnection.ti
 
 libdb_ido_mysql_la_CPPFLAGS = \
        $(LTDLINCL) \
index 332d123286b02891678a9887d0992c5359d6737c..e380a26b4c8c1816d360719a98ec604f425c42a9 100644 (file)
@@ -22,6 +22,7 @@
 #include "base/convert.h"
 #include "base/utility.h"
 #include "base/application.h"
+#include "base/dynamictype.h"
 #include "db_ido/dbtype.h"
 #include "db_ido/dbvalue.h"
 #include "db_ido_mysql/idomysqlconnection.h"
@@ -34,12 +35,13 @@ using namespace icinga;
 
 REGISTER_TYPE(IdoMysqlConnection);
 
+#define SCHEMA_VERSION "1.10.0"
+
 void IdoMysqlConnection::Start(void)
 {
        DbConnection::Start();
 
        m_Connected = false;
-       m_RequiredSchemaVersion = "1.10.0";
 
        m_TxTimer = boost::make_shared<Timer>();
        m_TxTimer->SetInterval(5);
@@ -99,13 +101,13 @@ void IdoMysqlConnection::ReconnectTimerHandler(void)
                const char *host, *user , *passwd, *db;
                long port;
 
-               ihost = m_Host;
-               iuser = m_User;
-               ipasswd = m_Password;
-               idb = m_Database;
+               ihost = GetHost();
+               iuser = GetUser();
+               ipasswd = GetPassword();
+               idb = GetDatabase();
 
                host = (!ihost.IsEmpty()) ? ihost.CStr() : NULL;
-               port = m_Port;
+               port = GetPort();
                user = (!iuser.IsEmpty()) ? iuser.CStr() : NULL;
                passwd = (!ipasswd.IsEmpty()) ? ipasswd.CStr() : NULL;
                db = (!idb.IsEmpty()) ? idb.CStr() : NULL;
@@ -127,20 +129,17 @@ void IdoMysqlConnection::ReconnectTimerHandler(void)
                Dictionary::Ptr version_row = version_rows->Get(0);
                String version = version_row->Get("version");
 
-               if (Utility::CompareVersion(m_RequiredSchemaVersion, version) < 0) {
+               if (Utility::CompareVersion(SCHEMA_VERSION, version) < 0) {
                        BOOST_THROW_EXCEPTION(std::runtime_error("Schema version '" + version + "' does not match the required version '" +
-                          m_RequiredSchemaVersion + "'! Please check the upgrade documentation."));
+                          SCHEMA_VERSION + "'! Please check the upgrade documentation."));
                }
 
-               String instanceName = "default";
-
-               if (!m_InstanceName.IsEmpty())
-                       instanceName = m_InstanceName;
+               String instanceName = GetInstanceName();
 
                Array::Ptr rows = Query("SELECT instance_id FROM " + GetTablePrefix() + "instances WHERE instance_name = '" + Escape(instanceName) + "'");
 
                if (rows->GetLength() == 0) {
-                       Query("INSERT INTO " + GetTablePrefix() + "instances (instance_name, instance_description) VALUES ('" + Escape(instanceName) + "', '" + m_InstanceDescription + "')");
+                       Query("INSERT INTO " + GetTablePrefix() + "instances (instance_name, instance_description) VALUES ('" + Escape(instanceName) + "', '" + Escape(GetInstanceDescription()) + "')");
                        m_InstanceID = GetLastInsertID();
                } else {
                        Dictionary::Ptr row = rows->Get(0);
@@ -539,32 +538,3 @@ void IdoMysqlConnection::CleanUpExecuteQuery(const String& table, const String&
            "<FROM_UNIXTIME(" + Convert::ToString(static_cast<long>(time_value)) + ")");
 }
 
-void IdoMysqlConnection::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
-{
-       DbConnection::InternalSerialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               bag->Set("host", m_Host);
-               bag->Set("port", m_Port);
-               bag->Set("user", m_User);
-               bag->Set("password", m_Password);
-               bag->Set("database", m_Database);
-               bag->Set("instance_name", m_InstanceName);
-               bag->Set("instance_description", m_InstanceDescription);
-       }
-}
-
-void IdoMysqlConnection::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
-{
-       DbConnection::InternalDeserialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               m_Host = bag->Get("host");
-               m_Port = bag->Get("port");
-               m_User = bag->Get("user");
-               m_Password = bag->Get("password");
-               m_Database = bag->Get("database");
-               m_InstanceName = bag->Get("instance_name");
-               m_InstanceDescription = bag->Get("instance_description");
-       }
-}
index 2eca680c6a5c538974183bf88074cd5adf5cd145..876fef84012921ab504633e935af2206c1e8f4ac 100644 (file)
 #ifndef IDOMYSQLCONNECTION_H
 #define IDOMYSQLCONNECTION_H
 
+#include "db_ido_mysql/idomysqlconnection.th"
 #include "base/array.h"
-#include "base/dynamictype.h"
 #include "base/timer.h"
-#include "db_ido/dbconnection.h"
 #include <mysql/mysql.h>
 
 namespace icinga
@@ -34,7 +33,7 @@ namespace icinga
  *
  * @ingroup ido
  */
-class IdoMysqlConnection : public DbConnection
+class IdoMysqlConnection : public ReflectionObjectImpl<IdoMysqlConnection>
 {
 public:
        DECLARE_PTR_TYPEDEFS(IdoMysqlConnection);
@@ -54,14 +53,6 @@ protected:
         virtual void CleanUpExecuteQuery(const String& table, const String& time_key, double time_value);
 
 private:
-       String m_Host;
-       Value m_Port;
-       String m_User;
-       String m_Password;
-       String m_Database;
-       String m_InstanceName;
-       String m_InstanceDescription;
-
        DbReference m_InstanceID;
         DbReference m_LastNotificationID;
 
@@ -69,8 +60,6 @@ private:
        bool m_Connected;
        MYSQL m_Connection;
 
-        String m_RequiredSchemaVersion;
-
        Timer::Ptr m_ReconnectTimer;
        Timer::Ptr m_TxTimer;
 
diff --git a/components/db_ido_mysql/idomysqlconnection.ti b/components/db_ido_mysql/idomysqlconnection.ti
new file mode 100644 (file)
index 0000000..202a20a
--- /dev/null
@@ -0,0 +1,19 @@
+#include "db_ido/dbconnection.h"
+
+namespace icinga
+{
+
+class IdoMysqlConnection : DbConnection
+{
+       [config] String host;
+       [config] int port;
+       [config] String user;
+       [config] String password;
+       [config] String database;
+       [config] String instance_name {
+               default {{{ return "default"; }}}
+       };
+       [config] String instance_description;
+};
+
+}
index df5e5963e1726e0f02f0278b28aff5db9fb92dd3..3151556eaac5e0bee1e9bd0611dc4c6995a1a48b 100644 (file)
@@ -3,15 +3,22 @@
 pkglib_LTLIBRARIES = \
        libdemo.la
 
+BUILT_SOURCES = \
+       demo.th
+
 CLEANFILES = \
        demo-type.cpp
 
 .conf.cpp: $(top_builddir)/tools/mkembedconfig/mkembedconfig
        $(top_builddir)/tools/mkembedconfig/mkembedconfig $< $@
 
+.ti.th: $(top_builddir)/tools/mkclass/mkclass
+       $(top_builddir)/tools/mkclass/mkclass $< > $@
+
 libdemo_la_SOURCES = \
        demo.cpp \
        demo.h \
+       demo.ti \
        demo-type.conf
 
 libdemo_la_CPPFLAGS = \
index 860ae227239c27f34c2b768aa86d991628788f43..11537961c28002bd84b235914c994f5fb71e1fd9 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef DEMO_H
 #define DEMO_H
 
-#include "base/dynamicobject.h"
+#include "demo/demo.th"
 #include "base/timer.h"
 
 namespace icinga
@@ -29,7 +29,7 @@ namespace icinga
 /**
  * @ingroup demo
  */
-class Demo : public DynamicObject
+class Demo : public ReflectionObjectImpl<Demo>
 {
 public:
        DECLARE_PTR_TYPEDEFS(Demo);
diff --git a/components/demo/demo.ti b/components/demo/demo.ti
new file mode 100644 (file)
index 0000000..71e14d4
--- /dev/null
@@ -0,0 +1,10 @@
+#include "base/dynamicobject.h"
+
+namespace icinga
+{
+
+class Demo : DynamicObject
+{
+};
+
+}
index a986bbe5402f80c57a106a164123d16b592f5739..91775b984fd91c8643d62aee75060fe7433944fe 100644 (file)
@@ -3,12 +3,18 @@
 pkglib_LTLIBRARIES = \
        liblivestatus.la
 
+BUILT_SOURCES = \
+       listener.th
+
 CLEANFILES = \
        livestatus-type.cpp
 
 .conf.cpp: $(top_builddir)/tools/mkembedconfig/mkembedconfig
        $(top_builddir)/tools/mkembedconfig/mkembedconfig $< $@
 
+.ti.th: $(top_builddir)/tools/mkclass/mkclass
+       $(top_builddir)/tools/mkclass/mkclass $< > $@
+
 liblivestatus_la_SOURCES = \
        aggregator.cpp \
        aggregator.h \
@@ -46,6 +52,7 @@ liblivestatus_la_SOURCES = \
        invsumaggregator.h \
        listener.cpp \
        listener.h \
+       listener.ti \
        livestatus-type.conf \
        logtable.cpp \
        logtable.h \
index b95e8aac816f55af158be665e297ca1e2f856477..f261911f2d3fb6e1e4b8e3ea2136df31a53b5e9b 100644 (file)
@@ -61,9 +61,6 @@ void CommentsTable::FetchRows(const AddRowFunction& addRowFn)
        BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjects<Service>()) {
                Dictionary::Ptr comments = service->GetComments();
 
-               if (!comments)
-                       continue;
-
                ObjectLock olock(comments);
 
                String id;
index 6a901b0cb4103e08e4d75beaaa88bf1cca17b631..adb9917197d7d26ed321c459370a82613c6933cd 100644 (file)
@@ -61,9 +61,6 @@ void DowntimesTable::FetchRows(const AddRowFunction& addRowFn)
        BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjects<Service>()) {
                Dictionary::Ptr downtimes = service->GetDowntimes();
 
-               if (!downtimes)
-                       continue;
-
                ObjectLock olock(downtimes);
 
                String id;
index 893b996a30b6b604b9393084687642ecb8505ae5..64262e746b6b2e8f13a8b62a65c31274a7518989 100644 (file)
@@ -604,7 +604,7 @@ Value HostsTable::CurrentAttemptAccessor(const Value& row)
        if (!hc)
                return Empty;
 
-       return hc->GetCurrentCheckAttempt();
+       return hc->GetCheckAttempt();
 }
 
 Value HostsTable::LastNotificationAccessor(const Value& row)
@@ -761,7 +761,7 @@ Value HostsTable::NoMoreNotificationsAccessor(const Value& row)
                        notification_interval = notification->GetNotificationInterval();
        }
 
-       if (notification_interval == 0 && !hc->IsVolatile())
+       if (notification_interval == 0 && !hc->GetVolatile())
                return 1;
 
        return 0;
@@ -1054,9 +1054,6 @@ Value HostsTable::DowntimesAccessor(const Value& row)
 
        Dictionary::Ptr downtimes = hc->GetDowntimes();
 
-       if (!downtimes)
-               return Empty;
-
        Array::Ptr ids = boost::make_shared<Array>();
 
        ObjectLock olock(downtimes);
@@ -1087,9 +1084,6 @@ Value HostsTable::DowntimesWithInfoAccessor(const Value& row)
 
        Dictionary::Ptr downtimes = hc->GetDowntimes();
 
-       if (!downtimes)
-               return Empty;
-
        Array::Ptr ids = boost::make_shared<Array>();
 
        ObjectLock olock(downtimes);
@@ -1124,9 +1118,6 @@ Value HostsTable::CommentsAccessor(const Value& row)
 
        Dictionary::Ptr comments = hc->GetComments();
 
-       if (!comments)
-               return Empty;
-
        Array::Ptr ids = boost::make_shared<Array>();
 
        ObjectLock olock(comments);
@@ -1157,9 +1148,6 @@ Value HostsTable::CommentsWithInfoAccessor(const Value& row)
 
        Dictionary::Ptr comments = hc->GetComments();
 
-       if (!comments)
-               return Empty;
-
        Array::Ptr ids = boost::make_shared<Array>();
 
        ObjectLock olock(comments);
@@ -1194,9 +1182,6 @@ Value HostsTable::CommentsWithExtraInfoAccessor(const Value& row)
 
        Dictionary::Ptr comments = hc->GetComments();
 
-       if (!comments)
-               return Empty;
-
        Array::Ptr ids = boost::make_shared<Array>();
 
        ObjectLock olock(comments);
index 88473ad7b44117b5179d0594ac82a7240717cbbf..a508a46977da1bafadd5e3528a660b43a3a0e7e4 100644 (file)
@@ -83,40 +83,6 @@ void LivestatusListener::Start(void)
        }
 }
 
-String LivestatusListener::GetSocketType(void) const
-{
-       Value socketType = m_SocketType;
-       if (socketType.IsEmpty())
-               return "unix";
-       else
-               return socketType;
-}
-
-String LivestatusListener::GetSocketPath(void) const
-{
-       Value socketPath = m_SocketPath;
-       if (socketPath.IsEmpty())
-               return Application::GetLocalStateDir() + "/run/icinga2/cmd/livestatus";
-       else
-               return socketPath;
-}
-
-String LivestatusListener::GetBindHost(void) const
-{
-       if (m_BindHost.IsEmpty())
-               return "127.0.0.1";
-       else
-               return m_BindHost;
-}
-
-String LivestatusListener::GetBindPort(void) const
-{
-       if (m_BindPort.IsEmpty())
-               return "6558";
-       else
-               return m_BindPort;
-}
-
 int LivestatusListener::GetClientsConnected(void)
 {
        boost::mutex::scoped_lock lock(l_ComponentMutex);
@@ -189,26 +155,3 @@ void LivestatusListener::ValidateSocketType(const String& location, const Dictio
        }
 }
 
-void LivestatusListener::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
-{
-       DynamicObject::InternalSerialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               bag->Set("socket_type", m_SocketType);
-               bag->Set("socket_path", m_SocketPath);
-               bag->Set("bind_host", m_BindHost);
-               bag->Set("bind_port", m_BindPort);
-       }
-}
-
-void LivestatusListener::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
-{
-       DynamicObject::InternalDeserialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               m_SocketType = bag->Get("socket_type");
-               m_SocketPath = bag->Get("socket_path");
-               m_BindHost = bag->Get("bind_host");
-               m_BindPort = bag->Get("bind_port");
-       }
-}
index a181c4f3ea100101afb01d30ac0b561e62118387..e348f226fa19106af50a45a791a7ca7900940723 100644 (file)
@@ -20,8 +20,8 @@
 #ifndef LIVESTATUSLISTENER_H
 #define LIVESTATUSLISTENER_H
 
+#include "livestatus/listener.th"
 #include "livestatus/query.h"
-#include "base/dynamicobject.h"
 #include "base/socket.h"
 #include <boost/thread/thread.hpp>
 
@@ -33,16 +33,11 @@ namespace livestatus
 /**
  * @ingroup livestatus
  */
-class LivestatusListener : public DynamicObject
+class LivestatusListener : public ReflectionObjectImpl<LivestatusListener>
 {
 public:
        DECLARE_PTR_TYPEDEFS(LivestatusListener);
 
-       String GetSocketType(void) const;
-       String GetSocketPath(void) const;
-       String GetBindHost(void) const;
-       String GetBindPort(void) const;
-
        static int GetClientsConnected(void);
        static int GetConnections(void);
 
@@ -51,15 +46,7 @@ public:
 protected:
        virtual void Start(void);
 
-       virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
-       virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
-
 private:
-       String m_SocketType;
-       String m_SocketPath;
-       String m_BindHost;
-       String m_BindPort;
-
        void ServerThreadProc(const Socket::Ptr& server);
        void ClientThreadProc(const Socket::Ptr& client);
 };
diff --git a/components/livestatus/listener.ti b/components/livestatus/listener.ti
new file mode 100644 (file)
index 0000000..7f7c845
--- /dev/null
@@ -0,0 +1,31 @@
+#include "base/dynamicobject.h"
+#include "base/application.h"
+
+namespace livestatus
+{
+
+code {{{
+class LivestatusListener;
+}}}
+
+}
+
+namespace icinga
+{
+
+class livestatus::LivestatusListener : DynamicObject {
+       [config] String socket_type {
+               default {{{ return "unix"; }}}
+       };
+       [config] String socket_path {
+               default {{{ return Application::GetLocalStateDir() + "/run/icinga2/cmd/livestatus"; }}}
+       };
+       [config] String bind_host {
+               default {{{ return "127.0.0.1"; }}}
+       };
+       [config] String bind_port {
+               default {{{ return "6558"; }}}
+       };
+};
+
+}
index 328557ab6458776db63bf5a34039ad7d5a959f6f..bee708cbd8d4fb6624ae53c3af4d42336ac20b01 100644 (file)
@@ -407,7 +407,7 @@ Value ServicesTable::MaxCheckAttemptsAccessor(const Value& row)
 
 Value ServicesTable::CurrentAttemptAccessor(const Value& row)
 {
-       return static_cast<Service::Ptr>(row)->GetCurrentCheckAttempt();
+       return static_cast<Service::Ptr>(row)->GetCheckAttempt();
 }
 
 Value ServicesTable::StateAccessor(const Value& row)
@@ -471,7 +471,7 @@ Value ServicesTable::NoMoreNotificationsAccessor(const Value& row)
                         notification_interval = notification->GetNotificationInterval();
         }
 
-        if (notification_interval == 0 && !service->IsVolatile())
+        if (notification_interval == 0 && !service->GetVolatile())
                 return 1;
 
        return 0;
@@ -731,9 +731,6 @@ Value ServicesTable::DowntimesAccessor(const Value& row)
 {
        Dictionary::Ptr downtimes = static_cast<Service::Ptr>(row)->GetDowntimes();
 
-       if (!downtimes)
-               return Empty;
-
        Array::Ptr ids = boost::make_shared<Array>();
 
        ObjectLock olock(downtimes);
@@ -758,9 +755,6 @@ Value ServicesTable::DowntimesWithInfoAccessor(const Value& row)
 {
        Dictionary::Ptr downtimes = static_cast<Service::Ptr>(row)->GetDowntimes();
 
-       if (!downtimes)
-               return Empty;
-
        Array::Ptr ids = boost::make_shared<Array>();
 
        ObjectLock olock(downtimes);
@@ -789,9 +783,6 @@ Value ServicesTable::CommentsAccessor(const Value& row)
 {
        Dictionary::Ptr comments = static_cast<Service::Ptr>(row)->GetComments();
 
-       if (!comments)
-               return Empty;
-
        Array::Ptr ids = boost::make_shared<Array>();
 
        ObjectLock olock(comments);
@@ -816,9 +807,6 @@ Value ServicesTable::CommentsWithInfoAccessor(const Value& row)
 {
        Dictionary::Ptr comments = static_cast<Service::Ptr>(row)->GetComments();
 
-       if (!comments)
-               return Empty;
-
        Array::Ptr ids = boost::make_shared<Array>();
 
        ObjectLock olock(comments);
@@ -847,9 +835,6 @@ Value ServicesTable::CommentsWithExtraInfoAccessor(const Value& row)
 {
        Dictionary::Ptr comments = static_cast<Service::Ptr>(row)->GetComments();
 
-       if (!comments)
-               return Empty;
-
        Array::Ptr ids = boost::make_shared<Array>();
 
        ObjectLock olock(comments);
index 1be42ebc1205055464ba0f2843bb7fe650c8d064..58d94395bcae1f2d862c48ffdcb1e0e7d02734bf 100644 (file)
@@ -120,7 +120,7 @@ Value StatusTable::ConnectionsAccessor(const Value& row)
 
 Value StatusTable::ConnectionsRateAccessor(const Value& row)
 {
-       return (LivestatusListener::GetConnections() / (Utility::GetTime() - IcingaApplication::GetInstance()->GetStartTime()));
+       return (LivestatusListener::GetConnections() / (Utility::GetTime() - Application::GetStartTime()));
 }
 
 Value StatusTable::ExternalCommandsAccessor(const Value& row)
@@ -130,7 +130,7 @@ Value StatusTable::ExternalCommandsAccessor(const Value& row)
 
 Value StatusTable::ExternalCommandsRateAccessor(const Value& row)
 {
-       return (Query::GetExternalCommands() / (Utility::GetTime() - IcingaApplication::GetInstance()->GetStartTime()));
+       return (Query::GetExternalCommands() / (Utility::GetTime() - Application::GetStartTime()));
 }
 
 Value StatusTable::NagiosPidAccessor(const Value& row)
@@ -140,7 +140,7 @@ Value StatusTable::NagiosPidAccessor(const Value& row)
 
 Value StatusTable::ProgramStartAccessor(const Value& row)
 {
-       return static_cast<int>(IcingaApplication::GetInstance()->GetStartTime());
+       return Application::GetStartTime();
 }
 
 Value StatusTable::NumHostsAccessor(const Value& row)
index 11864fa5c77fea9158b6ae29a507910760a5cbc9..69134f368fe655b8f2a022eb3383ca3d7349fa74 100644 (file)
@@ -3,15 +3,22 @@
 pkglib_LTLIBRARIES = \
        libnotification.la
 
+BUILT_SOURCES = \
+       notificationcomponent.th
+
 CLEANFILES = \
        notification-type.cpp
 
 .conf.cpp: $(top_builddir)/tools/mkembedconfig/mkembedconfig
        $(top_builddir)/tools/mkembedconfig/mkembedconfig $< $@
 
+.ti.th: $(top_builddir)/tools/mkclass/mkclass
+       $(top_builddir)/tools/mkclass/mkclass $< > $@
+
 libnotification_la_SOURCES = \
        notificationcomponent.cpp \
        notificationcomponent.h \
+       notificationcomponent.ti \
        notification-type.conf
 
 libnotification_la_CPPFLAGS = \
index 90a515710ed9e7984c3c892d1a2f5942277e69ad..1bb1ea6f0df635a0ce3f61bf7ac5a0575a3946d4 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef NOTIFICATIONCOMPONENT_H
 #define NOTIFICATIONCOMPONENT_H
 
+#include "notification/notificationcomponent.th"
 #include "icinga/service.h"
 #include "base/dynamicobject.h"
 #include "base/timer.h"
@@ -30,7 +31,7 @@ namespace icinga
 /**
  * @ingroup notification
  */
-class NotificationComponent : public DynamicObject
+class NotificationComponent : public ReflectionObjectImpl<NotificationComponent>
 {
 public:
        DECLARE_PTR_TYPEDEFS(NotificationComponent);
diff --git a/components/notification/notificationcomponent.ti b/components/notification/notificationcomponent.ti
new file mode 100644 (file)
index 0000000..d19f1c2
--- /dev/null
@@ -0,0 +1,10 @@
+#include "base/dynamicobject.h"
+
+namespace icinga
+{
+
+class NotificationComponent : DynamicObject
+{
+};
+
+}
index d27d84762ef24fcaea86928205f8ee50ce2b6a0b..67c5b829298504b385530de027d4d268ecb07c77 100644 (file)
@@ -4,17 +4,26 @@
 pkglib_LTLIBRARIES =  \
        libperfdata.la
 
+BUILT_SOURCES = \
+       graphitewriter.th \
+       perfdatawriter.th
+
 CLEANFILES = \
        perfdata-type.cpp
 
 .conf.cpp: $(top_builddir)/tools/mkembedconfig/mkembedconfig
        $(top_builddir)/tools/mkembedconfig/mkembedconfig $< $@
 
+.ti.th: $(top_builddir)/tools/mkclass/mkclass
+       $(top_builddir)/tools/mkclass/mkclass $< > $@
+
 libperfdata_la_SOURCES =  \
        graphitewriter.cpp \
        graphitewriter.h \
+       graphitewriter.ti \
        perfdatawriter.cpp \
        perfdatawriter.h \
+       perfdatawriter.th \
        perfdata-type.conf
 
 libperfdata_la_CPPFLAGS = \
index b679d72baee70106b717f4a9a47f8ac55bbbeb57..31ba55fb5954d4ffad395eba948aec76dd109193 100644 (file)
@@ -57,22 +57,6 @@ void GraphiteWriter::Start(void)
        Service::OnNewCheckResult.connect(boost::bind(&GraphiteWriter::CheckResultHandler, this, _1, _2));
 }
 
-String GraphiteWriter::GetHost(void) const
-{
-       if (m_Host.IsEmpty())
-               return "127.0.0.1";
-       else
-               return m_Host;
-}
-
-String GraphiteWriter::GetPort(void) const
-{
-       if (m_Port.IsEmpty())
-               return "2003";
-       else
-               return m_Port;
-}
-
 void GraphiteWriter::ReconnectTimerHandler(void)
 {
        try {
@@ -110,7 +94,7 @@ void GraphiteWriter::CheckResultHandler(const Service::Ptr& service, const Dicti
        Value metricValue;
 
        /* basic metrics */
-       AddServiceMetric(metrics, service, "current_attempt", service->GetCurrentCheckAttempt());
+       AddServiceMetric(metrics, service, "current_attempt", service->GetCheckAttempt());
        AddServiceMetric(metrics, service, "max_check_attempts", service->GetMaxCheckAttempts());
        AddServiceMetric(metrics, service, "state_type", service->GetStateType());
        AddServiceMetric(metrics, service, "state", service->GetState());
@@ -267,22 +251,3 @@ void GraphiteWriter::SanitizeMetric(String& str)
        boost::replace_all(str, "/", "_");
 }
 
-void GraphiteWriter::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
-{
-       DynamicObject::InternalSerialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               bag->Set("host", m_Host);
-               bag->Set("port", m_Port);
-       }
-}
-
-void GraphiteWriter::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
-{
-       DynamicObject::InternalDeserialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               m_Host = bag->Get("host");
-               m_Port = bag->Get("port");
-       }
-}
index cb3162490a1128fb2f180bb2cdf9230ce3a10f4c..a17e8ed65ad0d0b3e41eaca2a19d315c33c97069 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef GRAPHITEWRITER_H
 #define GRAPHITEWRITER_H
 
+#include "perfdata/graphitewriter.th"
 #include "icinga/service.h"
 #include "base/dynamicobject.h"
 #include "base/tcpsocket.h"
@@ -34,24 +35,16 @@ namespace icinga
  *
  * @ingroup perfdata
  */
-class GraphiteWriter : public DynamicObject
+class GraphiteWriter : public ReflectionObjectImpl<GraphiteWriter>
 {
 public:
        DECLARE_PTR_TYPEDEFS(GraphiteWriter);
        DECLARE_TYPENAME(GraphiteWriter);
 
-        String GetHost(void) const;
-        String GetPort(void) const;
-
 protected:
        virtual void Start(void);
 
-       virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
-       virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
-
 private:
-       String m_Host;
-       String m_Port;
         Stream::Ptr m_Stream;
         
         Timer::Ptr m_ReconnectTimer;
diff --git a/components/perfdata/graphitewriter.ti b/components/perfdata/graphitewriter.ti
new file mode 100644 (file)
index 0000000..379663f
--- /dev/null
@@ -0,0 +1,16 @@
+#include "base/dynamicobject.h"
+
+namespace icinga
+{
+
+class GraphiteWriter : DynamicObject
+{
+       [config] String host {
+               default {{{ return "127.0.0.1"; }}}
+       };
+       [config] String port {
+               default {{{ return "2003"; }}}
+       };
+};
+
+}
index 6d9282dd1bab31e744d5075572d740a0a44322c7..8539686725f870a68cf7a93a9e0b8c044459e875 100644 (file)
@@ -33,10 +33,6 @@ using namespace icinga;
 
 REGISTER_TYPE(PerfdataWriter);
 
-PerfdataWriter::PerfdataWriter(void)
-       : m_RotationInterval(30)
-{ }
-
 void PerfdataWriter::Start(void)
 {
        DynamicObject::Start();
@@ -51,37 +47,6 @@ void PerfdataWriter::Start(void)
        RotateFile();
 }
 
-String PerfdataWriter::GetPerfdataPath(void) const
-{
-       if (!m_PerfdataPath.IsEmpty())
-               return m_PerfdataPath;
-       else
-               return Application::GetLocalStateDir() + "/cache/icinga2/perfdata/perfdata";
-}
-
-String PerfdataWriter::GetFormatTemplate(void) const
-{
-       if (!m_FormatTemplate.IsEmpty()) {
-               return m_FormatTemplate;
-       } else {
-               return "DATATYPE::SERVICEPERFDATA\t"
-                       "TIMET::$TIMET$\t"
-                       "HOSTNAME::$HOSTNAME$\t"
-                       "SERVICEDESC::$SERVICEDESC$\t"
-                       "SERVICEPERFDATA::$SERVICEPERFDATA$\t"
-                       "SERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\t"
-                       "HOSTSTATE::$HOSTSTATE$\t"
-                       "HOSTSTATETYPE::$HOSTSTATETYPE$\t"
-                       "SERVICESTATE::$SERVICESTATE$\t"
-                       "SERVICESTATETYPE::$SERVICESTATETYPE$";
-       }
-}
-
-double PerfdataWriter::GetRotationInterval(void) const
-{
-       return m_RotationInterval;
-}
-
 void PerfdataWriter::CheckResultHandler(const Service::Ptr& service, const Dictionary::Ptr& cr)
 {
        if (!IcingaApplication::GetInstance()->GetEnablePerfdata() || !service->GetEnablePerfdata())
@@ -130,24 +95,3 @@ void PerfdataWriter::RotationTimerHandler(void)
        RotateFile();
 }
 
-void PerfdataWriter::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
-{
-       DynamicObject::InternalSerialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               bag->Set("perfdata_path", m_PerfdataPath);
-               bag->Set("format_template", m_FormatTemplate);
-               bag->Set("rotation_interval", m_RotationInterval);
-       }
-}
-
-void PerfdataWriter::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
-{
-       DynamicObject::InternalDeserialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               m_PerfdataPath = bag->Get("perfdata_path");
-               m_FormatTemplate = bag->Get("format_template");
-               m_RotationInterval = bag->Get("rotation_interval");
-       }
-}
index 9518924f43107234c4f97868d4043b1654c5b0af..8ae295fdb38890e6ee7f8a968a2417925ba2b48c 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef PERFDATAWRITER_H
 #define PERFDATAWRITER_H
 
-#include "icinga/i2-icinga.h"
+#include "perfdata/perfdatawriter.th"
 #include "icinga/service.h"
 #include "base/dynamicobject.h"
 #include "base/timer.h"
@@ -34,29 +34,16 @@ namespace icinga
  *
  * @ingroup icinga
  */
-class PerfdataWriter : public DynamicObject
+class PerfdataWriter : public ReflectionObjectImpl<PerfdataWriter>
 {
 public:
        DECLARE_PTR_TYPEDEFS(PerfdataWriter);
        DECLARE_TYPENAME(PerfdataWriter);
 
-       PerfdataWriter(void);
-
-       String GetPerfdataPath(void) const;
-       String GetFormatTemplate(void) const;
-       double GetRotationInterval(void) const;
-
 protected:
        virtual void Start(void);
 
-       virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
-       virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
-
 private:
-       String m_PerfdataPath;
-       String m_FormatTemplate;
-       double m_RotationInterval;
-
        void CheckResultHandler(const Service::Ptr& service, const Dictionary::Ptr& cr);
 
        Timer::Ptr m_RotationTimer;
diff --git a/components/perfdata/perfdatawriter.ti b/components/perfdata/perfdatawriter.ti
new file mode 100644 (file)
index 0000000..0045cb3
--- /dev/null
@@ -0,0 +1,32 @@
+#include "base/dynamicobject.h"
+#include "base/application.h"
+
+namespace icinga
+{
+
+class PerfdataWriter : DynamicObject
+{
+       [config] String perfdata_path {
+               default {{{ return Application::GetLocalStateDir() + "/cache/icinga2/perfdata/perfdata"; }}}
+       };
+       [config] String format_template {
+               default {{{
+                       return "DATATYPE::SERVICEPERFDATA\t"
+                           "TIMET::$TIMET$\t"
+                           "HOSTNAME::$HOSTNAME$\t"
+                           "SERVICEDESC::$SERVICEDESC$\t"
+                           "SERVICEPERFDATA::$SERVICEPERFDATA$\t"
+                           "SERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\t"
+                           "HOSTSTATE::$HOSTSTATE$\t"
+                           "HOSTSTATETYPE::$HOSTSTATETYPE$\t"
+                           "SERVICESTATE::$SERVICESTATE$\t"
+                           "SERVICESTATETYPE::$SERVICESTATETYPE$";
+               }}}
+       };
+
+       [config] double rotation_interval {
+               default {{{ return 30; }}}
+       };
+};
+
+}
index 18b847663b60598f33a9d0554bc677ef3a74b591..7957084b2905beaa3cf01c15784012d23b301b91 100644 (file)
@@ -210,6 +210,7 @@ third-party/mmatch/Makefile
 tools/Makefile
 tools/migration/Makefile
 tools/icinga2-enable-feature
+tools/mkclass/Makefile
 tools/mkembedconfig/Makefile
 ])
 
index 4bdfa0861b4433e94d3cc4e6ecd7850f776ddf47..0203cfa67e9a1a52121318b12a96755beadeb058 100644 (file)
@@ -111,7 +111,7 @@ Attributes:
   max\_check\_attempts|**Optional.** The number of times a service is re-checked before changing into a hard state. Defaults to 3.
   check\_period   |**Optional.** The name of a time period which determines when this service should be checked. Not set by default.
   check\_interval |**Optional.** The check interval (in seconds). This interval is used for checks when the service is in a `HARD` state. Defaults to 5 minutes.
-  retry\_interval |**Optional.** The retry interval (in seconds). This interval is used for checks when the service is in a `SOFT` state. Defaults to 1/5th of the check interval if not specified.
+  retry\_interval |**Optional.** The retry interval (in seconds). This interval is used for checks when the service is in a `SOFT` state. Defaults to 1 minute.
   enable\_active\_checks|**Optional.** Whether active checks are enabled. Defaults to true.
   enable\_passive\_checks|**Optional.** Whether passive checks are enabled. Defaults to true.
   enable\_event\_handler|**Optional.** Enables event handlers for this service. Defaults to true.
index 2ff859138346ad1ed005529ac937787d9d183e62..958ce5122ed1066d413d1d5fd9e662afe1d791af 100644 (file)
@@ -160,6 +160,8 @@ static bool Daemonize(const String& stderrFile)
  */
 int main(int argc, char **argv)
 {
+       Application::SetStartTime(Utility::GetTime());
+
 #ifndef _WIN32
        LTDL_SET_PRELOADED_SYMBOLS();
 #endif /* _WIN32 */
index 66a3aa898ee5a2364b21e40d6d4dff7ee5235906..cb5655c4d51cdba949725fee1a15b0e832ca5747 100644 (file)
@@ -14,6 +14,7 @@ EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "demo", "components\demo\demo.vcxproj", "{2E6C1133-730F-4875-A72C-B455B1DD4C5C}"
        ProjectSection(ProjectDependencies) = postProject
                {D5EE8062-8FC5-40E8-81C0-B435B06AB311} = {D5EE8062-8FC5-40E8-81C0-B435B06AB311}
+               {CBC9DD83-BAEB-4995-8D0B-F711898908E7} = {CBC9DD83-BAEB-4995-8D0B-F711898908E7}
                {9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
                {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7} = {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7}
                {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} = {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}
@@ -21,6 +22,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "demo", "components\demo\dem
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "notification", "components\notification\notification.vcxproj", "{EBEA7D10-66FB-4760-8AA8-81CD500D899E}"
        ProjectSection(ProjectDependencies) = postProject
+               {950E8743-BB34-4F8A-99EC-C87E8FC0EB3F} = {950E8743-BB34-4F8A-99EC-C87E8FC0EB3F}
                {D5EE8062-8FC5-40E8-81C0-B435B06AB311} = {D5EE8062-8FC5-40E8-81C0-B435B06AB311}
                {9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
                {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7} = {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7}
@@ -34,6 +36,7 @@ EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "checker", "components\checker\checker.vcxproj", "{38CE81CC-2660-4EF0-A936-4A337591DA3E}"
        ProjectSection(ProjectDependencies) = postProject
                {D5EE8062-8FC5-40E8-81C0-B435B06AB311} = {D5EE8062-8FC5-40E8-81C0-B435B06AB311}
+               {CBC9DD83-BAEB-4995-8D0B-F711898908E7} = {CBC9DD83-BAEB-4995-8D0B-F711898908E7}
                {9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
                {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7} = {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7}
                {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} = {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}
@@ -42,6 +45,7 @@ EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "compat", "components\compat\compat.vcxproj", "{2BD1C70C-43DB-4F44-B66B-67CF5C7044AA}"
        ProjectSection(ProjectDependencies) = postProject
                {D5EE8062-8FC5-40E8-81C0-B435B06AB311} = {D5EE8062-8FC5-40E8-81C0-B435B06AB311}
+               {CBC9DD83-BAEB-4995-8D0B-F711898908E7} = {CBC9DD83-BAEB-4995-8D0B-F711898908E7}
                {9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
                {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7} = {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7}
                {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} = {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}
@@ -57,6 +61,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "base", "lib\base\base.vcxpr
        ProjectSection(ProjectDependencies) = postProject
                {19CBCE06-3F5C-479A-BD75-E2AB6215D345} = {19CBCE06-3F5C-479A-BD75-E2AB6215D345}
                {66BED474-C33F-48F9-90BA-BBCFEDC006B8} = {66BED474-C33F-48F9-90BA-BBCFEDC006B8}
+               {CBC9DD83-BAEB-4995-8D0B-F711898908E7} = {CBC9DD83-BAEB-4995-8D0B-F711898908E7}
        EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "config", "lib\config\config.vcxproj", "{B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7}"
@@ -68,6 +73,7 @@ EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "icinga", "lib\icinga\icinga.vcxproj", "{C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}"
        ProjectSection(ProjectDependencies) = postProject
                {D5EE8062-8FC5-40E8-81C0-B435B06AB311} = {D5EE8062-8FC5-40E8-81C0-B435B06AB311}
+               {CBC9DD83-BAEB-4995-8D0B-F711898908E7} = {CBC9DD83-BAEB-4995-8D0B-F711898908E7}
                {9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
                {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7} = {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7}
        EndProjectSection
@@ -80,6 +86,7 @@ EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "livestatus", "components\livestatus\livestatus.vcxproj", "{950E8743-BB34-4F8A-99EC-C87E8FC0EB3F}"
        ProjectSection(ProjectDependencies) = postProject
                {D5EE8062-8FC5-40E8-81C0-B435B06AB311} = {D5EE8062-8FC5-40E8-81C0-B435B06AB311}
+               {CBC9DD83-BAEB-4995-8D0B-F711898908E7} = {CBC9DD83-BAEB-4995-8D0B-F711898908E7}
                {9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
                {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7} = {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7}
                {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} = {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}
@@ -90,6 +97,7 @@ EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cluster", "components\cluster\cluster.vcxproj", "{8732E0CD-E3D0-41F2-A538-94884543890F}"
        ProjectSection(ProjectDependencies) = postProject
                {D5EE8062-8FC5-40E8-81C0-B435B06AB311} = {D5EE8062-8FC5-40E8-81C0-B435B06AB311}
+               {CBC9DD83-BAEB-4995-8D0B-F711898908E7} = {CBC9DD83-BAEB-4995-8D0B-F711898908E7}
                {9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
                {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7} = {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7}
                {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} = {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}
@@ -107,6 +115,7 @@ EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "db_ido", "lib\db_ido\db_ido.vcxproj", "{87BBCE4C-36F5-4C04-90FB-9B74618AF988}"
        ProjectSection(ProjectDependencies) = postProject
                {D5EE8062-8FC5-40E8-81C0-B435B06AB311} = {D5EE8062-8FC5-40E8-81C0-B435B06AB311}
+               {CBC9DD83-BAEB-4995-8D0B-F711898908E7} = {CBC9DD83-BAEB-4995-8D0B-F711898908E7}
                {9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
                {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7} = {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7}
                {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} = {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}
@@ -114,12 +123,15 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "db_ido", "lib\db_ido\db_ido
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "perfdata", "components\perfdata\perfdata.vcxproj", "{E08A9B69-97E2-4203-B4D7-501DFF020CCF}"
        ProjectSection(ProjectDependencies) = postProject
+               {950E8743-BB34-4F8A-99EC-C87E8FC0EB3F} = {950E8743-BB34-4F8A-99EC-C87E8FC0EB3F}
                {D5EE8062-8FC5-40E8-81C0-B435B06AB311} = {D5EE8062-8FC5-40E8-81C0-B435B06AB311}
                {9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
                {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7} = {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7}
                {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} = {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}
        EndProjectSection
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mkclass", "tools\mkclass\mkclass.vcxproj", "{CBC9DD83-BAEB-4995-8D0B-F711898908E7}"
+EndProject
 Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
                Debug|Win32 = Debug|Win32
@@ -265,6 +277,14 @@ Global
                {E08A9B69-97E2-4203-B4D7-501DFF020CCF}.Release|Win32.Build.0 = Release|Win32
                {E08A9B69-97E2-4203-B4D7-501DFF020CCF}.Release|x64.ActiveCfg = Release|x64
                {E08A9B69-97E2-4203-B4D7-501DFF020CCF}.Release|x64.Build.0 = Release|x64
+               {CBC9DD83-BAEB-4995-8D0B-F711898908E7}.Debug|Win32.ActiveCfg = Debug|Win32
+               {CBC9DD83-BAEB-4995-8D0B-F711898908E7}.Debug|Win32.Build.0 = Debug|Win32
+               {CBC9DD83-BAEB-4995-8D0B-F711898908E7}.Debug|x64.ActiveCfg = Debug|x64
+               {CBC9DD83-BAEB-4995-8D0B-F711898908E7}.Debug|x64.Build.0 = Debug|x64
+               {CBC9DD83-BAEB-4995-8D0B-F711898908E7}.Release|Win32.ActiveCfg = Release|Win32
+               {CBC9DD83-BAEB-4995-8D0B-F711898908E7}.Release|Win32.Build.0 = Release|Win32
+               {CBC9DD83-BAEB-4995-8D0B-F711898908E7}.Release|x64.ActiveCfg = Release|x64
+               {CBC9DD83-BAEB-4995-8D0B-F711898908E7}.Release|x64.Build.0 = Release|x64
        EndGlobalSection
        GlobalSection(SolutionProperties) = preSolution
                HideSolutionNode = FALSE
index 52f0f447c4d7947dd4ad44615dcd6a32624e2c40..0fea3da058a3f770dbd6de79995d3b9116d549e5 100644 (file)
@@ -4,15 +4,30 @@
 pkglib_LTLIBRARIES =  \
        libbase.la
 
+BUILT_SOURCES = \
+       application.th \
+       consolelogger.th \
+       dynamicobject.th \
+       filelogger.th \
+       logger.th \
+       script.th \
+       streamlogger.th \
+       sysloglogger.th
+
+.ti.th: $(top_builddir)/tools/mkclass/mkclass
+       $(top_builddir)/tools/mkclass/mkclass $< > $@
+
 libbase_la_SOURCES =  \
        application.cpp \
        application.h \
+       application.ti \
        array.cpp \
        array.h \
        bufferedstream.cpp \
        bufferedstream.h \
        consolelogger.cpp \
        consolelogger.h \
+       consolelogger.ti \
        convert.cpp \
        convert.h \
        debug.h \
@@ -20,6 +35,7 @@ libbase_la_SOURCES =  \
        dictionary.h \
        dynamicobject.cpp \
        dynamicobject.h \
+       dynamicobject.ti \
        dynamictype.cpp \
        dynamictype.h \
        exception.cpp \
@@ -28,10 +44,12 @@ libbase_la_SOURCES =  \
        fifo.h \
        filelogger.cpp \
        filelogger.h \
+       filelogger.ti \
        i2-base.h \
        initialize.h \
        logger.cpp \
        logger.h \
+       logger.ti \
        logger_fwd.h \
        netstring.cpp \
        netstring.h \
@@ -47,11 +65,14 @@ libbase_la_SOURCES =  \
        process.h \
        qstring.cpp \
        qstring.h \
+       reflectionobject.cpp \
+       reflectionobject.h \
        registry.h \
        ringbuffer.cpp \
        ringbuffer.h \
        script.cpp \
        script.h \
+       script.ti \
        scriptfunction.cpp \
        scriptfunction.h \
        scriptfunctionwrapper.cpp \
@@ -75,8 +96,10 @@ libbase_la_SOURCES =  \
        stream_bio.h \
        streamlogger.cpp \
        streamlogger.h \
+       streamlogger.ti \
        sysloglogger.cpp \
        sysloglogger.h \
+       sysloglogger.ti \
        tcpsocket.cpp \
        tcpsocket.h \
        threadpool.cpp \
index 16ccb64340cdfe07c52112e5b1dfab5a37a38304..d578ee8965258c9982e22faa01a347fb09f24b92 100644 (file)
@@ -51,6 +51,7 @@ bool Application::m_Restarting = false;
 bool Application::m_Debugging = false;
 int Application::m_ArgC;
 char **Application::m_ArgV;
+double Application::m_StartTime;
 
 /**
  * Constructor for the Application class.
@@ -718,3 +719,13 @@ String Application::GetVersion(void)
        return "unspecified version";
 #endif /* _WIN32 */
 }
+
+double Application::GetStartTime(void)
+{
+       return m_StartTime;
+}
+
+void Application::SetStartTime(double ts)
+{
+       m_StartTime = ts;
+}
index c98b7dc7bc45e70b41e4442d4c0b0ddb8c49f922..b93f5910e838270e79943fe22a639ed065339d44 100644 (file)
@@ -21,6 +21,7 @@
 #define APPLICATION_H
 
 #include "base/i2-base.h"
+#include "base/application.th"
 #include "base/threadpool.h"
 #include "base/dynamicobject.h"
 
@@ -33,7 +34,7 @@ class Component;
  *
  * @ingroup base
  */
-class I2_BASE_API Application : public DynamicObject {
+class I2_BASE_API Application : public ReflectionObjectImpl<Application> {
 public:
        DECLARE_PTR_TYPEDEFS(Application);
 
@@ -94,6 +95,9 @@ public:
 
        static String GetVersion(void);
 
+       static double GetStartTime(void);
+       static void SetStartTime(double ts);
+
 protected:
        virtual void OnConfigLoaded(void);
        virtual void Stop(void);
@@ -112,6 +116,7 @@ private:
        static char **m_ArgV; /**< Command-line arguments. */
        FILE *m_PidFile; /**< The PID file */
        static bool m_Debugging; /**< Whether debugging is enabled. */
+       static double m_StartTime;
 
 #ifndef _WIN32
        static void SigIntHandler(int signum);
diff --git a/lib/base/application.ti b/lib/base/application.ti
new file mode 100644 (file)
index 0000000..4347dd2
--- /dev/null
@@ -0,0 +1,10 @@
+#include "base/dynamicobject.h"
+
+namespace icinga
+{
+
+class Application : DynamicObject
+{
+};
+
+}
index 534e443d549de4abb96a16b938e8b376cc99c72f..099310ac4fc3073144306974b91f2250ad893b62 100644 (file)
@@ -30,6 +30,7 @@
     <ClCompile Include="dynamictype.cpp" />
     <ClCompile Include="filelogger.cpp" />
     <ClCompile Include="networkstream.cpp" />
+    <ClCompile Include="reflectionobject.cpp" />
     <ClCompile Include="script.cpp" />
     <ClCompile Include="scriptinterpreter.cpp" />
     <ClCompile Include="scriptlanguage.cpp" />
@@ -78,6 +79,7 @@
     <ClInclude Include="filelogger.h" />
     <ClInclude Include="initialize.h" />
     <ClInclude Include="networkstream.h" />
+    <ClInclude Include="reflectionobject.h" />
     <ClInclude Include="script.h" />
     <ClInclude Include="scriptinterpreter.h" />
     <ClInclude Include="scriptlanguage.h" />
     <ClInclude Include="zlibstream.h" />
   </ItemGroup>
   <ItemGroup>
+    <CustomBuild Include="dynamicobject.ti">
+      <FileType>Document</FileType>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).th;%(Outputs)</Outputs>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+    </CustomBuild>
+    <ClInclude Include="dynamicobject.th">
+      <FileType>Document</FileType>
+    </ClInclude>
+    <CustomBuild Include="application.ti">
+      <FileType>Document</FileType>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).th;%(Outputs)</Outputs>
+    </CustomBuild>
+    <None Include="application.th" />
+    <CustomBuild Include="logger.ti">
+      <FileType>Document</FileType>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).th;%(Outputs)</Outputs>
+    </CustomBuild>
+    <CustomBuild Include="filelogger.ti">
+      <FileType>Document</FileType>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).th;%(Outputs)</Outputs>
+    </CustomBuild>
+    <CustomBuild Include="consolelogger.ti">
+      <FileType>Document</FileType>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).th;%(Outputs)</Outputs>
+    </CustomBuild>
+    <None Include="consolelogger.th" />
+    <None Include="filelogger.th" />
+    <None Include="logger.th" />
     <None Include="packages.config" />
+    <CustomBuild Include="script.ti">
+      <FileType>Document</FileType>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).th;%(Outputs)</Outputs>
+    </CustomBuild>
+    <None Include="script.th" />
+    <CustomBuild Include="streamlogger.ti">
+      <FileType>Document</FileType>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).th;%(Outputs)</Outputs>
+    </CustomBuild>
+    <None Include="streamlogger.th" />
+    <CustomBuild Include="sysloglogger.ti">
+      <FileType>Document</FileType>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).th;%(Outputs)</Outputs>
+    </CustomBuild>
+    <None Include="sysloglogger.th" />
   </ItemGroup>
   <PropertyGroup Label="Globals">
     <ProjectGuid>{9C92DA90-FD53-43A9-A244-90F2E8AF9677}</ProjectGuid>
index b7861d761a63d3a0e87a0afaf6354049d59e6f3e..827a23c36b151c90a7c58ed7efd504c5decd90c1 100644 (file)
     <ClCompile Include="zlibstream.cpp">
       <Filter>Quelldateien</Filter>
     </ClCompile>
+    <ClCompile Include="reflectionobject.cpp">
+      <Filter>Quelldateien</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="application.h">
     <ClInclude Include="zlibstream.h">
       <Filter>Headerdateien</Filter>
     </ClInclude>
+    <ClInclude Include="reflectionobject.h">
+      <Filter>Headerdateien</Filter>
+    </ClInclude>
+    <ClInclude Include="dynamicobject.th">
+      <Filter>Headerdateien</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <Filter Include="Quelldateien">
   </ItemGroup>
   <ItemGroup>
     <None Include="packages.config" />
+    <None Include="script.th">
+      <Filter>Headerdateien</Filter>
+    </None>
+    <None Include="application.th">
+      <Filter>Headerdateien</Filter>
+    </None>
+    <None Include="logger.th">
+      <Filter>Headerdateien</Filter>
+    </None>
+    <None Include="streamlogger.th">
+      <Filter>Headerdateien</Filter>
+    </None>
+    <None Include="filelogger.th">
+      <Filter>Headerdateien</Filter>
+    </None>
+    <None Include="sysloglogger.th">
+      <Filter>Headerdateien</Filter>
+    </None>
+    <None Include="consolelogger.th">
+      <Filter>Headerdateien</Filter>
+    </None>
+  </ItemGroup>
+  <ItemGroup>
+    <CustomBuild Include="dynamicobject.ti">
+      <Filter>Headerdateien</Filter>
+    </CustomBuild>
+    <CustomBuild Include="script.ti">
+      <Filter>Headerdateien</Filter>
+    </CustomBuild>
+    <CustomBuild Include="application.ti">
+      <Filter>Headerdateien</Filter>
+    </CustomBuild>
+    <CustomBuild Include="logger.ti">
+      <Filter>Headerdateien</Filter>
+    </CustomBuild>
+    <CustomBuild Include="streamlogger.ti">
+      <Filter>Headerdateien</Filter>
+    </CustomBuild>
+    <CustomBuild Include="filelogger.ti">
+      <Filter>Headerdateien</Filter>
+    </CustomBuild>
+    <CustomBuild Include="sysloglogger.ti">
+      <Filter>Headerdateien</Filter>
+    </CustomBuild>
+    <CustomBuild Include="consolelogger.ti">
+      <Filter>Headerdateien</Filter>
+    </CustomBuild>
   </ItemGroup>
 </Project>
\ No newline at end of file
index 75a8fcb64ecc950dad7c8f51ab9d42f9d2709eaa..6fd7a7ff0390fce7eef5844c3bf6d7ded63c6098 100644 (file)
@@ -21,7 +21,7 @@
 #define CONSOLELOGGER_H
 
 #include "base/i2-base.h"
-#include "base/streamlogger.h"
+#include "base/consolelogger.th"
 
 namespace icinga
 {
@@ -31,7 +31,7 @@ namespace icinga
  *
  * @ingroup base
  */
-class I2_BASE_API ConsoleLogger : public StreamLogger
+class I2_BASE_API ConsoleLogger : public ReflectionObjectImpl<ConsoleLogger>
 {
 public:
        DECLARE_PTR_TYPEDEFS(ConsoleLogger);
diff --git a/lib/base/consolelogger.ti b/lib/base/consolelogger.ti
new file mode 100644 (file)
index 0000000..4059f45
--- /dev/null
@@ -0,0 +1,10 @@
+#include "base/streamlogger.h"
+
+namespace icinga
+{
+
+class ConsoleLogger : StreamLogger
+{
+};
+
+}
\ No newline at end of file
index 98050f3f4c67f0ded5be76324fee49108da77355..b46587b15d330bffb9a7d319b19db547d1f7507e 100644 (file)
 
 #include "i2-base.h"
 
-#ifdef NDEBUG
+#ifndef _DEBUG
 #      define ASSERT(expr) ((void)0)
-#else /* NDEBUG */
+#else /* _DEBUG */
 #      define ASSERT(expr) ((expr) ? 0 : icinga_assert_fail(#expr, __FILE__, __LINE__))
-#endif /* NDEBUG */
+#endif /* _DEBUG */
 
 #define VERIFY(expr) ((expr) ? 0 : icinga_assert_fail(#expr, __FILE__, __LINE__))
 
+#ifdef _MSC_VER
+#      define NORETURNPRE __declspec(noreturn)
+#else /* _MSC_VER */
+#      define NORETURNPRE
+#endif /* _MSC_VER */
+
 #ifdef __GNUC__
-#      define NORETURN __attribute__((noreturn))
+#      define NORETURNPOST __attribute__((noreturn))
 #else /* __GNUC__ */
-#      define NORETURN
+#      define NORETURNPOST
 #endif /* __GNUC__ */
 
-int icinga_assert_fail(const char *expr, const char *file, int line) NORETURN;
+NORETURNPRE int icinga_assert_fail(const char *expr, const char *file, int line) NORETURNPOST;
+
+#ifdef _MSC_VER
+#      pragma warning( push )
+#      pragma warning( disable : 4646 ) /* function declared with __declspec(noreturn) has non-void return type */
+#endif /* _MSC_VER */
 
 inline int icinga_assert_fail(const char *expr, const char *file, int line)
 {
        fprintf(stderr, "%s:%d: assertion failed: %s\n", file, line, expr);
        abort();
 
-#ifndef __GNUC__
+#if !defined(__GNUC__) && !defined(_MSC_VER)
        return 0;
-#endif /* __GNUC__ */
+#endif /* !defined(__GNUC__) && !defined(_MSC_VER) */
 }
 
+#ifdef _MSC_VER
+#      pragma warning( pop )
+#endif /* _MSC_VER */
+
 #endif /* DEBUG_H */
index 4f359b9fdb3a63ca25c6e42cd87c12010d0258c3..21ad261679256f3a72e3eb5670ccf7d2bde0e584 100644 (file)
@@ -42,90 +42,21 @@ boost::signals2::signal<void (const DynamicObject::Ptr&)> DynamicObject::OnState
 boost::signals2::signal<void (const DynamicObject::Ptr&, const String&, bool)> DynamicObject::OnAuthorityChanged;
 
 DynamicObject::DynamicObject(void)
-       : m_Active(false)
-{ }
-
-DynamicObject::~DynamicObject(void)
-{ }
-
-Dictionary::Ptr DynamicObject::Serialize(int attributeTypes) const
 {
-       Dictionary::Ptr update = boost::make_shared<Dictionary>();
-
-       ASSERT(!OwnsLock());
-       ObjectLock olock(this);
-
-       InternalSerialize(update, attributeTypes);
-
-       /* Make sure our own InternalSerialize() method was called. */
-       ASSERT(update->Contains("__marker"));
-       update->Remove("__marker");
-
-       return update;
+       SetActive(false);
 }
 
-void DynamicObject::Deserialize(const Dictionary::Ptr& update, int attributeTypes)
-{
-       ASSERT(!OwnsLock());
-
-       {
-               ObjectLock olock(this);
-               InternalDeserialize(update, attributeTypes);
-       }
-}
-
-void DynamicObject::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
-{
-       if (attributeTypes & Attribute_Config) {
-               bag->Set("__name", m_Name);
-               bag->Set("__type", m_Type);
-               bag->Set("methods", m_Methods);
-               bag->Set("custom", m_Custom);
-               bag->Set("authorities", m_Authorities);
-               bag->Set("domains", m_Domains);
-       }
-
-       if (attributeTypes & Attribute_State)
-               bag->Set("extensions", m_Extensions);
-
-       /* This attribute is used by Serialize() to check that this
-        * method was called. */
-       bag->Set("__marker", 1);
-}
-
-void DynamicObject::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
-{
-       if (attributeTypes & Attribute_Config) {
-               m_Name = bag->Get("__name");
-               m_Type = bag->Get("__type");
-               m_Methods = bag->Get("methods");
-               m_Custom = bag->Get("custom");
-               m_Authorities = bag->Get("authorities");
-               m_Domains = bag->Get("domains");
-       }
-
-       if (attributeTypes & Attribute_State)
-               m_Extensions = bag->Get("extensions");
-}
+DynamicObject::~DynamicObject(void)
+{ }
 
 DynamicType::Ptr DynamicObject::GetType(void) const
 {
-       return DynamicType::GetByName(m_Type);
-}
-
-String DynamicObject::GetName(void) const
-{
-       return m_Name;
+       return DynamicType::GetByName(GetTypeName());
 }
 
 bool DynamicObject::IsActive(void) const
 {
-       return m_Active;
-}
-
-Array::Ptr DynamicObject::GetAuthorities(void) const
-{
-       return m_Authorities;
+       return GetActive();
 }
 
 void DynamicObject::SetAuthority(const String& type, bool value)
@@ -135,15 +66,12 @@ void DynamicObject::SetAuthority(const String& type, bool value)
        {
                ObjectLock olock(this);
 
-               if (!m_Authority)
-                       m_Authority = boost::make_shared<Dictionary>();
-
                bool old_value = HasAuthority(type);
 
                if (old_value == value)
                        return;
 
-               m_Authority->Set(type, value);
+               GetAuthorityInfo()->Set(type, value);
        }
 
        OnAuthorityChanged(GetSelf(), type, value);
@@ -151,15 +79,7 @@ void DynamicObject::SetAuthority(const String& type, bool value)
 
 bool DynamicObject::HasAuthority(const String& type) const
 {
-       if (!m_Authority)
-               return true;
-
-       return m_Authority->Get(type);
-}
-
-Array::Ptr DynamicObject::GetDomains(void) const
-{
-       return m_Domains;
+       return GetAuthorityInfo()->Get(type);
 }
 
 void DynamicObject::SetPrivileges(const String& instance, int privs)
@@ -183,11 +103,11 @@ bool DynamicObject::HasPrivileges(const String& instance, int privs) const
 
 void DynamicObject::SetExtension(const String& key, const Object::Ptr& object)
 {
-       Dictionary::Ptr extensions = m_Extensions;
+       Dictionary::Ptr extensions = GetExtensions();
 
        if (!extensions) {
                extensions = boost::make_shared<Dictionary>();
-               m_Extensions = extensions;
+               SetExtensions(extensions);
        }
 
        extensions->Set(key, object);
@@ -195,7 +115,7 @@ void DynamicObject::SetExtension(const String& key, const Object::Ptr& object)
 
 Object::Ptr DynamicObject::GetExtension(const String& key)
 {
-       Dictionary::Ptr extensions = m_Extensions;
+       Dictionary::Ptr extensions = GetExtensions();
 
        if (!extensions)
                return Object::Ptr();
@@ -205,7 +125,7 @@ Object::Ptr DynamicObject::GetExtension(const String& key)
 
 void DynamicObject::ClearExtension(const String& key)
 {
-       Dictionary::Ptr extensions = m_Extensions;
+       Dictionary::Ptr extensions = GetExtensions();
 
        if (!extensions)
                return;
@@ -225,8 +145,8 @@ void DynamicObject::Start(void)
 {
        ASSERT(!OwnsLock());
 
-       ASSERT(!m_Active);
-       m_Active = true;
+       ASSERT(!IsActive());
+       SetActive(true);
 
        OnStarted(GetSelf());
 }
@@ -235,8 +155,8 @@ void DynamicObject::Stop(void)
 {
        ASSERT(!OwnsLock());
 
-       ASSERT(m_Active);
-       m_Active = false;
+       ASSERT(IsActive());
+       SetActive(false);
 
        OnStopped(GetSelf());
 }
@@ -256,7 +176,7 @@ Value DynamicObject::InvokeMethod(const String& method,
 {
        Dictionary::Ptr methods;
 
-       methods = m_Methods;
+       methods = GetMethods();
 
        if (!methods)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Method '" + method + "' does not exist."));
@@ -383,8 +303,3 @@ DynamicObject::Ptr DynamicObject::GetObject(const String& type, const String& na
        DynamicType::Ptr dtype = DynamicType::GetByName(type);
        return dtype->GetObject(name);
 }
-
-Dictionary::Ptr DynamicObject::GetCustom(void) const
-{
-       return m_Custom;
-}
index d9138f69ec40d696c716c048d703ab710a9ecd7e..a2dcb4c26c6f1b3817797eca2d3114d024b41b73 100644 (file)
@@ -21,6 +21,7 @@
 #define DYNAMICOBJECT_H
 
 #include "base/i2-base.h"
+#include "base/dynamicobject.th"
 #include "base/object.h"
 #include "base/dictionary.h"
 #include "base/array.h"
@@ -40,8 +41,8 @@ class DynamicType;
  */
 enum AttributeType
 {
-       Attribute_State = 1,
-       Attribute_Config = 2,
+       Attribute_State = FAState,
+       Attribute_Config = FAConfig
 };
 
 enum DomainPriv
@@ -57,16 +58,13 @@ enum DomainPriv
  *
  * @ingroup base
  */
-class I2_BASE_API DynamicObject : public Object
+class I2_BASE_API DynamicObject : public ReflectionObjectImpl<DynamicObject>
 {
 public:
        DECLARE_PTR_TYPEDEFS(DynamicObject);
 
        ~DynamicObject(void);
 
-       Dictionary::Ptr Serialize(int attributeTypes) const;
-       void Deserialize(const Dictionary::Ptr& update, int attributeTypes);
-
        static boost::signals2::signal<void (const DynamicObject::Ptr&)> OnStarted;
        static boost::signals2::signal<void (const DynamicObject::Ptr&)> OnStopped;
        static boost::signals2::signal<void (const DynamicObject::Ptr&)> OnStateChanged;
@@ -75,17 +73,12 @@ public:
        Value InvokeMethod(const String& method, const std::vector<Value>& arguments);
 
        shared_ptr<DynamicType> GetType(void) const;
-       String GetName(void) const;
 
        bool IsActive(void) const;
 
-       Array::Ptr GetAuthorities(void) const;
-
        void SetAuthority(const String& type, bool value);
        bool HasAuthority(const String& type) const;
 
-       Array::Ptr GetDomains(void) const;
-
        void SetPrivileges(const String& instance, int privs);
        bool HasPrivileges(const String& instance, int privs) const;
 
@@ -116,27 +109,12 @@ public:
        static void RestoreObjects(const String& filename, int attributeTypes = Attribute_State);
        static void StopObjects(void);
 
-       Dictionary::Ptr GetCustom(void) const;
-
 protected:
        explicit DynamicObject(void);
 
-       virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
-       virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
-
 private:
-       String m_Name;
-       String m_Type;
-       Dictionary::Ptr m_Extensions;
-       Dictionary::Ptr m_Methods;
-       Dictionary::Ptr m_Custom;
-       Array::Ptr m_Authorities;
-       Array::Ptr m_Domains;
        std::map<String, int> m_Privileges;
 
-       bool m_Active;
-       Dictionary::Ptr m_Authority;
-
        static DynamicObject::Ptr GetObject(const String& type, const String& name);
 };
 
diff --git a/lib/base/dynamicobject.ti b/lib/base/dynamicobject.ti
new file mode 100644 (file)
index 0000000..5e98269
--- /dev/null
@@ -0,0 +1,21 @@
+#include <boost/smart_ptr/make_shared.hpp>
+
+namespace icinga
+{
+
+class DynamicObject
+{
+       [config] String __name (Name);
+       [config, get_protected] String __type (TypeName);
+       [config] Dictionary::Ptr methods;
+       [config] Dictionary::Ptr custom;
+       [config] Array::Ptr domains;
+       [config] Array::Ptr authorities;
+       [get_protected] bool active;
+       Dictionary::Ptr authority_info {
+               default {{{ return boost::make_shared<Dictionary>(); }}}
+       };
+       [protected] Dictionary::Ptr extensions;
+};
+
+}
index 5e649411d0f75e9ae7fa668e2f5a9385458327a9..0888e900881929d39f960ad54a33abcf9c2d423f 100644 (file)
@@ -34,7 +34,7 @@ void FileLogger::Start()
 
        std::ofstream *stream = new std::ofstream();
 
-       String path = m_Path;
+       String path = GetPath();
 
        try {
                stream->open(path.CStr(), std::fstream::out | std::fstream::trunc);
@@ -48,19 +48,3 @@ void FileLogger::Start()
 
        BindStream(stream, true);
 }
-
-void FileLogger::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
-{
-       StreamLogger::InternalSerialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config)
-               bag->Set("path", m_Path);
-}
-
-void FileLogger::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
-{
-       StreamLogger::InternalDeserialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config)
-               m_Path = bag->Get("path");
-}
index 7f52ffe64a54e80c1b5ca8b5fcfcd16e138e1f5e..e1d138a0d6f3b6c44e045b3dac17c7b3b7145073 100644 (file)
@@ -21,7 +21,7 @@
 #define FILELOGGER_H
 
 #include "base/i2-base.h"
-#include "base/streamlogger.h"
+#include "base/filelogger.th"
 
 namespace icinga
 {
@@ -31,19 +31,12 @@ namespace icinga
  *
  * @ingroup base
  */
-class I2_BASE_API FileLogger : public StreamLogger
+class I2_BASE_API FileLogger : public ReflectionObjectImpl<FileLogger>
 {
 public:
        DECLARE_PTR_TYPEDEFS(FileLogger);
 
        virtual void Start(void);
-
-protected:
-       virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
-       virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
-
-private:
-       String m_Path;
 };
 
 }
diff --git a/lib/base/filelogger.ti b/lib/base/filelogger.ti
new file mode 100644 (file)
index 0000000..882b1c4
--- /dev/null
@@ -0,0 +1,11 @@
+#include "base/streamlogger.h"
+
+namespace icinga
+{
+
+class FileLogger : StreamLogger
+{
+       [config] String path;
+};
+
+}
\ No newline at end of file
index 90a2b3f6c9026b975f07356fcb40c766a6fde6b7..4faa31bde7e0ab5a1826ff1754257d69cedac3ff 100644 (file)
@@ -105,7 +105,7 @@ void icinga::Log(LogSeverity severity, const String& facility,
  */
 LogSeverity Logger::GetMinSeverity(void) const
 {
-       String severity = m_Severity;
+       String severity = GetSeverity();
        if (severity.IsEmpty())
                return LogInformation;
        else
@@ -151,19 +151,3 @@ LogSeverity Logger::StringToSeverity(const String& severity)
        else
                BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid severity: " + severity));
 }
-
-void Logger::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
-{
-       DynamicObject::InternalSerialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config)
-               bag->Set("severity", m_Severity);
-}
-
-void Logger::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
-{
-       DynamicObject::InternalDeserialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config)
-               m_Severity = bag->Get("severity");
-}
index c99f97e838c83f4f6e08a776827b1f77447535c1..4098870c2ef14768b5e51810f668b3bd5e4c1f39 100644 (file)
@@ -21,6 +21,7 @@
 #define LOGGER_H
 
 #include "base/i2-base.h"
+#include "base/logger.th"
 #include "base/dynamicobject.h"
 #include "base/logger_fwd.h"
 #include <set>
@@ -45,7 +46,7 @@ struct LogEntry {
  *
  * @ingroup base
  */
-class I2_BASE_API Logger : public DynamicObject
+class I2_BASE_API Logger : public ReflectionObjectImpl<Logger>
 {
 public:
        DECLARE_PTR_TYPEDEFS(Logger);
@@ -69,12 +70,7 @@ protected:
        virtual void Start(void);
        virtual void Stop(void);
 
-       virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
-       virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
-
 private:
-       String m_Severity;
-
        static boost::mutex m_Mutex;
        static std::set<Logger::Ptr> m_Loggers;
 
diff --git a/lib/base/logger.ti b/lib/base/logger.ti
new file mode 100644 (file)
index 0000000..a50033b
--- /dev/null
@@ -0,0 +1,11 @@
+#include "base/dynamicobject.h"
+
+namespace icinga
+{
+
+class Logger : DynamicObject
+{
+       [config] String severity;
+};
+
+}
\ No newline at end of file
index a7e82d356efdd121d17e6bf16194a6d35a567cda..3e910d97e6fabbfb46c9cf6ea308278446dff46e 100644 (file)
@@ -129,7 +129,7 @@ ProcessResult Process::Run(void)
                (void) close(fds[0]);
                (void) close(fds[1]);
 
-               if (execvpe(argv[0], argv, envp) < 0) {
+               if (icinga2_execvpe(argv[0], argv, envp) < 0) {
                        perror("execvpe() failed.");
                        _exit(128);
                }
diff --git a/lib/base/reflectionobject.cpp b/lib/base/reflectionobject.cpp
new file mode 100644 (file)
index 0000000..ab990fc
--- /dev/null
@@ -0,0 +1,54 @@
+/******************************************************************************
+ * 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/reflectionobject.h"
+#include <boost/smart_ptr/make_shared.hpp>
+
+using namespace icinga;
+
+Dictionary::Ptr ReflectionObject::Serialize(int attributeTypes) const
+{
+       Dictionary::Ptr update = boost::make_shared<Dictionary>();
+
+       for (int i = 0; i < GetFieldCount(); i++) {
+               ReflectionField field = 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)
+{
+       for (int i = 0; i < GetFieldCount(); i++) {
+               ReflectionField field = GetFieldInfo(i);
+
+               if ((field.Attributes & attributeTypes) == 0)
+                       continue;
+
+               if (!update->Contains(field.Name))
+                       continue;
+
+               SetField(i, update->Get(field.Name));
+       }
+}
diff --git a/lib/base/reflectionobject.h b/lib/base/reflectionobject.h
new file mode 100644 (file)
index 0000000..842aa3a
--- /dev/null
@@ -0,0 +1,76 @@
+/******************************************************************************
+ * 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.             *
+ ******************************************************************************/
+
+#ifndef REFLECTIONOBJECT_H
+#define REFLECTIONOBJECT_H
+
+#include "base/object.h"
+#include "base/dictionary.h"
+#include <vector>
+
+namespace icinga
+{
+
+enum ReflectionFieldAttribute
+{
+       FAConfig = 1,
+       FAState = 2
+};
+
+struct ReflectionField
+{
+       int ID;
+       String Name;
+       int Attributes;
+       Value DefaultValue;
+
+       ReflectionField(int id, const String& name, int attributes, const Value& default_value = Empty)
+               : ID(id), Name(name), Attributes(attributes), DefaultValue(default_value)
+       { }
+};
+
+enum InvokationType
+{
+       ITGet,
+       ITSet
+};
+
+class I2_BASE_API ReflectionObject : public Object
+{
+public:
+       DECLARE_PTR_TYPEDEFS(ReflectionObject);
+
+       virtual int GetFieldId(const String& name) const = 0;
+       virtual ReflectionField GetFieldInfo(int id) const = 0;
+       virtual int GetFieldCount(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 ReflectionObjectImpl
+{
+};
+
+}
+
+#endif /* REFLECTIONOBJECT_H */
index a4489a6d83f90ece3a6c32b7a6fefdf1b45c6743..1c0a7d74c01dc912e1da3f6df46a0516dee2e4cc 100644 (file)
@@ -37,20 +37,6 @@ void Script::Start(void)
        SpawnInterpreter();
 }
 
-String Script::GetLanguage(void) const
-{
-       ObjectLock olock(this);
-
-       return m_Language;
-}
-
-String Script::GetCode(void) const
-{
-       ObjectLock olock(this);
-
-       return m_Code;
-}
-
 void Script::SpawnInterpreter(void)
 {
        Log(LogInformation, "base", "Reloading script '" + GetName() + "'");
@@ -58,23 +44,3 @@ void Script::SpawnInterpreter(void)
        ScriptLanguage::Ptr language = ScriptLanguage::GetByName(GetLanguage());
        m_Interpreter = language->CreateInterpreter(GetSelf());
 }
-
-void Script::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
-{
-       DynamicObject::InternalSerialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               bag->Set("language", m_Language);
-               bag->Set("code", m_Code);
-       }
-}
-
-void Script::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
-{
-       DynamicObject::InternalDeserialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               m_Language = bag->Get("language");
-               m_Code = bag->Get("code");
-       }
-}
index d3c0b0a350dbbbdcd046f5ffdec5df862460fa49..4243a71ee785936ad5696f16514e80c79aabce8a 100644 (file)
@@ -21,7 +21,7 @@
 #define SCRIPT_H
 
 #include "base/i2-base.h"
-#include "base/dynamicobject.h"
+#include "base/script.th"
 
 namespace icinga
 {
@@ -33,24 +33,14 @@ class ScriptInterpreter;
  *
  * @ingroup base
  */
-class I2_BASE_API Script : public DynamicObject
+class I2_BASE_API Script : public ReflectionObjectImpl<Script>
 {
 public:
        DECLARE_PTR_TYPEDEFS(Script);
 
        virtual void Start(void);
 
-       String GetLanguage(void) const;
-       String GetCode(void) const;
-
-protected:
-       virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
-       virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
-
 private:
-       String m_Language;
-       String m_Code;
-
        shared_ptr<ScriptInterpreter> m_Interpreter;
 
        void SpawnInterpreter(void);
diff --git a/lib/base/script.ti b/lib/base/script.ti
new file mode 100644 (file)
index 0000000..43afbe2
--- /dev/null
@@ -0,0 +1,12 @@
+#include "base/dynamicobject.h"
+
+namespace icinga
+{
+
+class Script : DynamicObject
+{
+       [config] String language;
+       [config] String "code";
+};
+
+}
index 3016e1b205e6dda504dfbeb42ccd82b10d91413a..3fec2af991f5fa144d22bdc9d1fc559c6fc05509 100644 (file)
@@ -21,7 +21,7 @@
 #define STREAMLOGGER_H
 
 #include "base/i2-base.h"
-#include "base/logger.h"
+#include "base/streamlogger.th"
 #include "base/timer.h"
 #include <ostream>
 
@@ -33,7 +33,7 @@ namespace icinga
  *
  * @ingroup base
  */
-class I2_BASE_API StreamLogger : public Logger
+class I2_BASE_API StreamLogger : public ReflectionObjectImpl<StreamLogger>
 {
 public:
        DECLARE_PTR_TYPEDEFS(StreamLogger);
@@ -53,11 +53,11 @@ private:
        static boost::mutex m_Mutex;
        std::ostream *m_Stream;
        bool m_OwnsStream;
-        bool m_Tty;
+       bool m_Tty;
 
-        Timer::Ptr m_FlushLogTimer;
+       Timer::Ptr m_FlushLogTimer;
 
-        void FlushLogTimerHandler(void);
+       void FlushLogTimerHandler(void);
 };
 
 }
diff --git a/lib/base/streamlogger.ti b/lib/base/streamlogger.ti
new file mode 100644 (file)
index 0000000..185c644
--- /dev/null
@@ -0,0 +1,10 @@
+#include "base/logger.h"
+
+namespace icinga
+{
+
+class StreamLogger : Logger
+{
+};
+
+}
\ No newline at end of file
index 126271010433fc928defa815b3de74bc0d5ded53..c1678ef6761e1e22098e745b133fcd339ea89405 100644 (file)
@@ -21,7 +21,7 @@
 #define SYSLOGLOGGER_H
 
 #include "base/i2-base.h"
-#include "base/logger.h"
+#include "base/sysloglogger.th"
 
 #ifndef _WIN32
 namespace icinga
@@ -32,7 +32,7 @@ namespace icinga
  *
  * @ingroup base
  */
-class I2_BASE_API SyslogLogger : public Logger
+class I2_BASE_API SyslogLogger : public ReflectionObjectImpl<SyslogLogger>
 {
 public:
        DECLARE_PTR_TYPEDEFS(SyslogLogger);
diff --git a/lib/base/sysloglogger.ti b/lib/base/sysloglogger.ti
new file mode 100644 (file)
index 0000000..2fbc2ba
--- /dev/null
@@ -0,0 +1,10 @@
+#include "base/logger.h"
+
+namespace icinga
+{
+
+class SyslogLogger : Logger
+{
+};
+
+}
\ No newline at end of file
index 71a02a4e78203898b61be26a4ea9ac81be7c92eb..a2b1e850a4af4359e94c95ff245a76888a9f81d7 100644 (file)
@@ -3,17 +3,24 @@
 pkglib_LTLIBRARIES = \
        libdb_ido.la
 
+BUILT_SOURCES = \
+       dbconnection.th
+
 CLEANFILES = \
        db_ido-type.cpp
 
 .conf.cpp: $(top_builddir)/tools/mkembedconfig/mkembedconfig
        $(top_builddir)/tools/mkembedconfig/mkembedconfig $< $@
 
+.ti.th: $(top_builddir)/tools/mkclass/mkclass
+       $(top_builddir)/tools/mkclass/mkclass $< > $@
+
 libdb_ido_la_SOURCES = \
        commanddbobject.cpp \
        commanddbobject.h \
        dbconnection.cpp \
        dbconnection.h \
+       dbconnection.ti \
        dbobject.cpp \
        dbobject.h \
        dbquery.cpp \
index 2f012b5ec6bb6ddd688465626019658acb95a7c1..2605ded8e4081b26c8e7573cc099100576b7b3f7 100644 (file)
     </CustomBuild>
   </ItemGroup>
   <ItemGroup>
+    <CustomBuild Include="dbconnection.ti">
+      <FileType>Document</FileType>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).th;%(Outputs)</Outputs>
+    </CustomBuild>
+    <None Include="dbconnection.th" />
     <None Include="packages.config" />
   </ItemGroup>
   <PropertyGroup Label="Globals">
index 143c5ec8249c862e5aeabfe2e14aaa8ff149fcb3..f5f0f357db839f90ffcbbd7060ae5ece62a44bbf 100644 (file)
   </ItemGroup>
   <ItemGroup>
     <None Include="packages.config" />
+    <None Include="dbconnection.th">
+      <Filter>Headerdateien</Filter>
+    </None>
   </ItemGroup>
   <ItemGroup>
     <CustomBuild Include="db_ido-type.conf">
       <Filter>Quelldateien</Filter>
     </CustomBuild>
+    <CustomBuild Include="dbconnection.ti">
+      <Filter>Headerdateien</Filter>
+    </CustomBuild>
   </ItemGroup>
 </Project>
\ No newline at end of file
index 7345a993bd1d75e3138381860e3229100e631a99..8b70f354e356421b513fe56c8814ef9dbc8af3eb 100644 (file)
@@ -55,14 +55,6 @@ void DbConnection::StaticInitialize(void)
        m_ProgramStatusTimer->Start();
 }
 
-String DbConnection::GetTablePrefix(void) const
-{
-       if (m_TablePrefix.IsEmpty())
-               return "icinga_";
-       else
-               return m_TablePrefix;
-}
-
 void DbConnection::InsertRuntimeVariable(const String& key, const Value& value)
 {
        DbQuery query;
@@ -91,7 +83,7 @@ void DbConnection::ProgramStatusHandler(void)
        query2.Fields = boost::make_shared<Dictionary>();
        query2.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */
        query2.Fields->Set("status_update_time", DbValue::FromTimestamp(Utility::GetTime()));
-       query2.Fields->Set("program_start_time", DbValue::FromTimestamp(IcingaApplication::GetInstance()->GetStartTime()));
+       query2.Fields->Set("program_start_time", DbValue::FromTimestamp(Application::GetStartTime()));
        query2.Fields->Set("is_currently_running", 1);
        query2.Fields->Set("process_id", Utility::GetPid());
        query2.Fields->Set("daemon_mode", 1);
@@ -122,95 +114,95 @@ void DbConnection::CleanUpHandler(void)
 {
        long now = static_cast<long>(Utility::GetTime());
 
-       if (GetCleanUpAcknowledgementsAge() > 0) {
-               CleanUpExecuteQuery("acknowledgements", "entry_time", now - GetCleanUpAcknowledgementsAge());
-               Log(LogDebug, "db_ido", "GetCleanUpAcknowledgementsAge: " + Convert::ToString(GetCleanUpAcknowledgementsAge()) +
+       if (GetCleanupAcknowledgementsAge() > 0) {
+               CleanUpExecuteQuery("acknowledgements", "entry_time", now - GetCleanupAcknowledgementsAge());
+               Log(LogDebug, "db_ido", "GetCleanupAcknowledgementsAge: " + Convert::ToString(GetCleanupAcknowledgementsAge()) +
                    " now: " + Convert::ToString(now) +
-                   " old: " + Convert::ToString(now - GetCleanUpAcknowledgementsAge()));
+                   " old: " + Convert::ToString(now - GetCleanupAcknowledgementsAge()));
        }
-       if (GetCleanUpCommentHistoryAge() > 0) {
-               CleanUpExecuteQuery("commenthistory", "entry_time", now - GetCleanUpCommentHistoryAge());
-               Log(LogDebug, "db_ido", "GetCleanUpCommentHistoryAge: " + Convert::ToString(GetCleanUpCommentHistoryAge()) +
+       if (GetCleanupCommentHistoryAge() > 0) {
+               CleanUpExecuteQuery("commenthistory", "entry_time", now - GetCleanupCommentHistoryAge());
+               Log(LogDebug, "db_ido", "GetCleanupCommentHistoryAge: " + Convert::ToString(GetCleanupCommentHistoryAge()) +
                    " now: " + Convert::ToString(now) +
-                   " old: " + Convert::ToString(now - GetCleanUpCommentHistoryAge()));
+                   " old: " + Convert::ToString(now - GetCleanupCommentHistoryAge()));
        }
-       if (GetCleanUpContactNotificationsAge() > 0) {
-               CleanUpExecuteQuery("contactnotifications", "start_time", now - GetCleanUpContactNotificationsAge());
-               Log(LogDebug, "db_ido", "GetCleanUpContactNotificationsAge: " + Convert::ToString(GetCleanUpContactNotificationsAge()) +
+       if (GetCleanupContactNotificationsAge() > 0) {
+               CleanUpExecuteQuery("contactnotifications", "start_time", now - GetCleanupContactNotificationsAge());
+               Log(LogDebug, "db_ido", "GetCleanupContactNotificationsAge: " + Convert::ToString(GetCleanupContactNotificationsAge()) +
                    " now: " + Convert::ToString(now) +
-                   " old: " + Convert::ToString(now - GetCleanUpContactNotificationsAge()));
+                   " old: " + Convert::ToString(now - GetCleanupContactNotificationsAge()));
        }
-       if (GetCleanUpContactNotificationMethodsAge() > 0) {
-               CleanUpExecuteQuery("contactnotificationmethods", "start_time", now - GetCleanUpContactNotificationMethodsAge());
-               Log(LogDebug, "db_ido", "GetCleanUpContactNotificationMethodsAge: " + Convert::ToString(GetCleanUpContactNotificationMethodsAge()) +
+       if (GetCleanupContactNotificationMethodsAge() > 0) {
+               CleanUpExecuteQuery("contactnotificationmethods", "start_time", now - GetCleanupContactNotificationMethodsAge());
+               Log(LogDebug, "db_ido", "GetCleanupContactNotificationMethodsAge: " + Convert::ToString(GetCleanupContactNotificationMethodsAge()) +
                    " now: " + Convert::ToString(now) +
-                   " old: " + Convert::ToString(now - GetCleanUpContactNotificationMethodsAge()));
+                   " old: " + Convert::ToString(now - GetCleanupContactNotificationMethodsAge()));
        }
-       if (GetCleanUpDowntimeHistoryAge() > 0) {
-               CleanUpExecuteQuery("downtimehistory", "entry_time", now - GetCleanUpDowntimeHistoryAge());
-               Log(LogDebug, "db_ido", "CleanUpDowntimeHistoryAge: " + Convert::ToString(GetCleanUpDowntimeHistoryAge()) +
+       if (GetCleanupDowntimeHistoryAge() > 0) {
+               CleanUpExecuteQuery("downtimehistory", "entry_time", now - GetCleanupDowntimeHistoryAge());
+               Log(LogDebug, "db_ido", "CleanUpDowntimeHistoryAge: " + Convert::ToString(GetCleanupDowntimeHistoryAge()) +
                    " now: " + Convert::ToString(now) +
-                   " old: " + Convert::ToString(now - GetCleanUpDowntimeHistoryAge()));
+                   " old: " + Convert::ToString(now - GetCleanupDowntimeHistoryAge()));
        }
-       if (GetCleanUpEventHandlersAge() > 0) {
-               CleanUpExecuteQuery("eventhandlers", "start_time", now - GetCleanUpEventHandlersAge());
-               Log(LogDebug, "db_ido", "GetCleanUpEventHandlersAge: " + Convert::ToString(GetCleanUpEventHandlersAge()) +
+       if (GetCleanupEventHandlersAge() > 0) {
+               CleanUpExecuteQuery("eventhandlers", "start_time", now - GetCleanupEventHandlersAge());
+               Log(LogDebug, "db_ido", "GetCleanupEventHandlersAge: " + Convert::ToString(GetCleanupEventHandlersAge()) +
                    " now: " + Convert::ToString(now) +
-                   " old: " + Convert::ToString(now - GetCleanUpEventHandlersAge()));
+                   " old: " + Convert::ToString(now - GetCleanupEventHandlersAge()));
        }
-       if (GetCleanUpExternalCommandsAge() > 0) {
-               CleanUpExecuteQuery("externalcommands", "entry_time", now - GetCleanUpExternalCommandsAge());
-               Log(LogDebug, "db_ido", "GetCleanUpExternalCommandsAge: " + Convert::ToString(GetCleanUpExternalCommandsAge()) +
+       if (GetCleanupExternalCommandsAge() > 0) {
+               CleanUpExecuteQuery("externalcommands", "entry_time", now - GetCleanupExternalCommandsAge());
+               Log(LogDebug, "db_ido", "GetCleanupExternalCommandsAge: " + Convert::ToString(GetCleanupExternalCommandsAge()) +
                    " now: " + Convert::ToString(now) +
-                   " old: " + Convert::ToString(now - GetCleanUpExternalCommandsAge()));
+                   " old: " + Convert::ToString(now - GetCleanupExternalCommandsAge()));
        }
-       if (GetCleanUpFlappingHistoryAge() > 0) {
-               CleanUpExecuteQuery("flappinghistory", "event_time", now - GetCleanUpFlappingHistoryAge());
-               Log(LogDebug, "db_ido", "GetCleanUpFlappingHistoryAge: " + Convert::ToString(GetCleanUpFlappingHistoryAge()) +
+       if (GetCleanupFlappingHistoryAge() > 0) {
+               CleanUpExecuteQuery("flappinghistory", "event_time", now - GetCleanupFlappingHistoryAge());
+               Log(LogDebug, "db_ido", "GetCleanupFlappingHistoryAge: " + Convert::ToString(GetCleanupFlappingHistoryAge()) +
                    " now: " + Convert::ToString(now) +
-                   " old: " + Convert::ToString(now - GetCleanUpFlappingHistoryAge()));
+                   " old: " + Convert::ToString(now - GetCleanupFlappingHistoryAge()));
        }
-       if (GetCleanUpHostChecksAge() > 0) {
-               CleanUpExecuteQuery("hostchecks", "start_time", now - GetCleanUpHostChecksAge());
-               Log(LogDebug, "db_ido", "GetCleanUpHostChecksAge: " + Convert::ToString(GetCleanUpHostChecksAge()) +
+       if (GetCleanupHostChecksAge() > 0) {
+               CleanUpExecuteQuery("hostchecks", "start_time", now - GetCleanupHostChecksAge());
+               Log(LogDebug, "db_ido", "GetCleanupHostChecksAge: " + Convert::ToString(GetCleanupHostChecksAge()) +
                    " now: " + Convert::ToString(now) +
-                   " old: " + Convert::ToString(now - GetCleanUpHostChecksAge()));
+                   " old: " + Convert::ToString(now - GetCleanupHostChecksAge()));
        }
-       if (GetCleanUpLogEntriesAge() > 0) {
-               CleanUpExecuteQuery("logentries", "logentry_time", now - GetCleanUpLogEntriesAge());
-               Log(LogDebug, "db_ido", "GetCleanUpLogEntriesAge: " + Convert::ToString(GetCleanUpLogEntriesAge()) +
+       if (GetCleanupLogEntriesAge() > 0) {
+               CleanUpExecuteQuery("logentries", "logentry_time", now - GetCleanupLogEntriesAge());
+               Log(LogDebug, "db_ido", "GetCleanupLogEntriesAge: " + Convert::ToString(GetCleanupLogEntriesAge()) +
                    " now: " + Convert::ToString(now) +
-                   " old: " + Convert::ToString(now - GetCleanUpLogEntriesAge()));
+                   " old: " + Convert::ToString(now - GetCleanupLogEntriesAge()));
        }
-       if (GetCleanUpNotificationsAge() > 0) {
-               CleanUpExecuteQuery("notifications", "start_time", now - GetCleanUpNotificationsAge());
-               Log(LogDebug, "db_ido", "GetCleanUpNotificationsAge: " + Convert::ToString(GetCleanUpNotificationsAge()) +
+       if (GetCleanupNotificationsAge() > 0) {
+               CleanUpExecuteQuery("notifications", "start_time", now - GetCleanupNotificationsAge());
+               Log(LogDebug, "db_ido", "GetCleanupNotificationsAge: " + Convert::ToString(GetCleanupNotificationsAge()) +
                    " now: " + Convert::ToString(now) +
-                   " old: " + Convert::ToString(now - GetCleanUpNotificationsAge()));
+                   " old: " + Convert::ToString(now - GetCleanupNotificationsAge()));
        }
-       if (GetCleanUpProcessEventsAge() > 0) {
-               CleanUpExecuteQuery("processevents", "event_time", now - GetCleanUpProcessEventsAge());
-               Log(LogDebug, "db_ido", "GetCleanUpProcessEventsAge: " + Convert::ToString(GetCleanUpProcessEventsAge()) +
+       if (GetCleanupProcessEventsAge() > 0) {
+               CleanUpExecuteQuery("processevents", "event_time", now - GetCleanupProcessEventsAge());
+               Log(LogDebug, "db_ido", "GetCleanupProcessEventsAge: " + Convert::ToString(GetCleanupProcessEventsAge()) +
                    " now: " + Convert::ToString(now) +
-                   " old: " + Convert::ToString(now - GetCleanUpProcessEventsAge()));
+                   " old: " + Convert::ToString(now - GetCleanupProcessEventsAge()));
        }
-       if (GetCleanUpStateHistoryAge() > 0) {
-               CleanUpExecuteQuery("statehistory", "state_time", now - GetCleanUpStateHistoryAge());
-               Log(LogDebug, "db_ido", "GetCleanUpStateHistoryAge: " + Convert::ToString(GetCleanUpStateHistoryAge()) +
+       if (GetCleanupStateHistoryAge() > 0) {
+               CleanUpExecuteQuery("statehistory", "state_time", now - GetCleanupStateHistoryAge());
+               Log(LogDebug, "db_ido", "GetCleanupStateHistoryAge: " + Convert::ToString(GetCleanupStateHistoryAge()) +
                    " now: " + Convert::ToString(now) +
-                   " old: " + Convert::ToString(now - GetCleanUpStateHistoryAge()));
+                   " old: " + Convert::ToString(now - GetCleanupStateHistoryAge()));
        }
-       if (GetCleanUpServiceChecksAge() > 0) {
-               CleanUpExecuteQuery("servicechecks", "start_time", now - GetCleanUpServiceChecksAge());
-               Log(LogDebug, "db_ido", "GetCleanUpServiceChecksAge: " + Convert::ToString(GetCleanUpServiceChecksAge()) +
+       if (GetCleanupServiceChecksAge() > 0) {
+               CleanUpExecuteQuery("servicechecks", "start_time", now - GetCleanupServiceChecksAge());
+               Log(LogDebug, "db_ido", "GetCleanupServiceChecksAge: " + Convert::ToString(GetCleanupServiceChecksAge()) +
                    " now: " + Convert::ToString(now) +
-                   " old: " + Convert::ToString(now - GetCleanUpServiceChecksAge()));
+                   " old: " + Convert::ToString(now - GetCleanupServiceChecksAge()));
        }
-       if (GetCleanUpSystemCommandsAge() > 0) {
-               CleanUpExecuteQuery("systemcommands", "start_time", now - GetCleanUpSystemCommandsAge());
-               Log(LogDebug, "db_ido", "GetCleanUpSystemCommandsAge: " + Convert::ToString(GetCleanUpSystemCommandsAge()) +
+       if (GetCleanupSystemCommandsAge() > 0) {
+               CleanUpExecuteQuery("systemcommands", "start_time", now - GetCleanupSystemCommandsAge());
+               Log(LogDebug, "db_ido", "GetCleanupSystemCommandsAge: " + Convert::ToString(GetCleanupSystemCommandsAge()) +
                    " now: " + Convert::ToString(now) +
-                   " old: " + Convert::ToString(now - GetCleanUpSystemCommandsAge()));
+                   " old: " + Convert::ToString(now - GetCleanupSystemCommandsAge()));
        }
 }
 
@@ -219,162 +211,79 @@ void DbConnection::CleanUpExecuteQuery(const String& table, const String& time_k
        /* Default handler does nothing. */
 }
 
-Dictionary::Ptr DbConnection::GetCleanUp(void) const
+double DbConnection::GetCleanupAcknowledgementsAge(void) const
 {
-       if (!m_CleanUp)
-               return Empty;
-       else
-               return m_CleanUp;
+       return GetCleanup()->Get("acknowledgement_age");
 }
 
-Value DbConnection::GetCleanUpAcknowledgementsAge(void) const
+double DbConnection::GetCleanupCommentHistoryAge(void) const
 {
-       Dictionary::Ptr cleanup = GetCleanUp();
-
-       if (!cleanup || cleanup->Get("acknowledgement_age").IsEmpty())
-               return CleanUpAgeNone;
-       else
-               return cleanup->Get("acknowledgement_age");
+       return GetCleanup()->Get("commenthistory_age");
 }
 
-Value DbConnection::GetCleanUpCommentHistoryAge(void) const
+double DbConnection::GetCleanupContactNotificationsAge(void) const
 {
-       Dictionary::Ptr cleanup = GetCleanUp();
-
-       if (!cleanup || cleanup->Get("commenthistory_age").IsEmpty())
-               return CleanUpAgeNone;
-       else
-               return cleanup->Get("commenthistory_age");
+       return GetCleanup()->Get("contactnotifications_age");
 }
 
-Value DbConnection::GetCleanUpContactNotificationsAge(void) const
+double DbConnection::GetCleanupContactNotificationMethodsAge(void) const
 {
-       Dictionary::Ptr cleanup = GetCleanUp();
-
-       if (!cleanup || cleanup->Get("contactnotifications_age").IsEmpty())
-               return CleanUpAgeNone;
-       else
-               return cleanup->Get("contactnotifications_age");
+       return GetCleanup()->Get("contactnotificationmethods_age");
 }
 
-Value DbConnection::GetCleanUpContactNotificationMethodsAge(void) const
+double DbConnection::GetCleanupDowntimeHistoryAge(void) const
 {
-       Dictionary::Ptr cleanup = GetCleanUp();
-
-       if (!cleanup || cleanup->Get("contactnotificationmethods_age").IsEmpty())
-               return CleanUpAgeNone;
-       else
-               return cleanup->Get("contactnotificationmethods_age");
+       return GetCleanup()->Get("downtimehistory_age");
 }
 
-Value DbConnection::GetCleanUpDowntimeHistoryAge(void) const
+double DbConnection::GetCleanupEventHandlersAge(void) const
 {
-       Dictionary::Ptr cleanup = GetCleanUp();
-
-       if (!cleanup || cleanup->Get("downtimehistory_age").IsEmpty())
-               return CleanUpAgeNone;
-       else
-               return cleanup->Get("downtimehistory_age");
+       return GetCleanup()->Get("eventhandlers_age");
 }
 
-Value DbConnection::GetCleanUpEventHandlersAge(void) const
+double DbConnection::GetCleanupExternalCommandsAge(void) const
 {
-       Dictionary::Ptr cleanup = GetCleanUp();
-
-       if (!cleanup || cleanup->Get("eventhandlers_age").IsEmpty())
-               return CleanUpAgeNone;
-       else
-               return cleanup->Get("eventhandlers_age");
+       return GetCleanup()->Get("externalcommands_age");
 }
 
-Value DbConnection::GetCleanUpExternalCommandsAge(void) const
+double DbConnection::GetCleanupFlappingHistoryAge(void) const
 {
-       Dictionary::Ptr cleanup = GetCleanUp();
-
-       if (!cleanup || cleanup->Get("externalcommands_age").IsEmpty())
-               return CleanUpAgeNone;
-       else
-               return cleanup->Get("externalcommands_age");
+       return GetCleanup()->Get("flappinghistory_age");
 }
 
-Value DbConnection::GetCleanUpFlappingHistoryAge(void) const
+double DbConnection::GetCleanupHostChecksAge(void) const
 {
-       Dictionary::Ptr cleanup = GetCleanUp();
-
-       if (!cleanup || cleanup->Get("flappinghistory_age").IsEmpty())
-               return CleanUpAgeNone;
-       else
-               return cleanup->Get("flappinghistory_age");
+       return GetCleanup()->Get("hostchecks_age");
 }
 
-Value DbConnection::GetCleanUpHostChecksAge(void) const
+double DbConnection::GetCleanupLogEntriesAge(void) const
 {
-       Dictionary::Ptr cleanup = GetCleanUp();
-
-       if (!cleanup || cleanup->Get("hostchecks_age").IsEmpty())
-               return CleanUpAgeNone;
-       else
-               return cleanup->Get("hostchecks_age");
+       return GetCleanup()->Get("logentries_age");
 }
 
-Value DbConnection::GetCleanUpLogEntriesAge(void) const
+double DbConnection::GetCleanupNotificationsAge(void) const
 {
-       Dictionary::Ptr cleanup = GetCleanUp();
-
-       if (!cleanup || cleanup->Get("logentries_age").IsEmpty())
-               return CleanUpAgeNone;
-       else
-               return cleanup->Get("logentries_age");
+       return GetCleanup()->Get("notifications_age");
 }
 
-Value DbConnection::GetCleanUpNotificationsAge(void) const
+double DbConnection::GetCleanupProcessEventsAge(void) const
 {
-       Dictionary::Ptr cleanup = GetCleanUp();
-
-       if (!cleanup || cleanup->Get("notifications_age").IsEmpty())
-               return CleanUpAgeNone;
-       else
-               return cleanup->Get("notifications_age");
+       return GetCleanup()->Get("processevents_age");
 }
 
-Value DbConnection::GetCleanUpProcessEventsAge(void) const
+double DbConnection::GetCleanupStateHistoryAge(void) const
 {
-       Dictionary::Ptr cleanup = GetCleanUp();
-
-       if (!cleanup || cleanup->Get("processevents_age").IsEmpty())
-               return CleanUpAgeNone;
-       else
-               return cleanup->Get("processevents_age");
+       return GetCleanup()->Get("statehistory_age");
 }
 
-Value DbConnection::GetCleanUpStateHistoryAge(void) const
+double DbConnection::GetCleanupServiceChecksAge(void) const
 {
-       Dictionary::Ptr cleanup = GetCleanUp();
-
-       if (!cleanup || cleanup->Get("statehistory_age").IsEmpty())
-               return CleanUpAgeNone;
-       else
-               return cleanup->Get("statehistory_age");
+       return GetCleanup()->Get("servicechecks_age");
 }
 
-Value DbConnection::GetCleanUpServiceChecksAge(void) const
+double DbConnection::GetCleanupSystemCommandsAge(void) const
 {
-       Dictionary::Ptr cleanup = GetCleanUp();
-
-       if (!cleanup || cleanup->Get("servicechecks_age").IsEmpty())
-               return CleanUpAgeNone;
-       else
-               return cleanup->Get("servicechecks_age");
-}
-
-Value DbConnection::GetCleanUpSystemCommandsAge(void) const
-{
-       Dictionary::Ptr cleanup = GetCleanUp();
-
-       if (!cleanup || cleanup->Get("systemcommands_age").IsEmpty())
-               return CleanUpAgeNone;
-       else
-               return cleanup->Get("systemcommands_age");
+       return GetCleanup()->Get("systemcommands_age");
 }
 
 void DbConnection::SetObjectID(const DbObject::Ptr& dbobj, const DbReference& dbref)
@@ -463,23 +372,3 @@ void DbConnection::UpdateAllObjects(void)
                }
        }
 }
-
-void DbConnection::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
-{
-       DynamicObject::InternalSerialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               bag->Set("table_prefix", m_TablePrefix);
-               bag->Set("cleanup", m_CleanUp);
-       }
-}
-
-void DbConnection::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
-{
-       DynamicObject::InternalDeserialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               m_TablePrefix = bag->Get("table_prefix");
-               m_CleanUp = bag->Get("cleanup");
-       }
-}
\ No newline at end of file
index aa0a6778525b25c79f759f3b4a54e7013524771d..2fbfbf58aabf352eb83a0a347677a011bd6a59a9 100644 (file)
 #ifndef DBCONNECTION_H
 #define DBCONNECTION_H
 
-#include "base/dynamicobject.h"
-#include "base/timer.h"
+#include "db_ido/dbconnection.th"
 #include "db_ido/dbobject.h"
 #include "db_ido/dbquery.h"
+#include "base/timer.h"
 
 namespace icinga
 {
 
-enum CleanUpAge
-{
-    CleanUpAgeNone = 0,
-    CleanUpAgeOneMonth = 44640,
-    CleanUpAgeOneMeek = 10080,
-    CleanUpAgeOneDay = 1440,
-};
-
 /**
  * A database connection.
  *
  * @ingroup db_ido
  */
-class DbConnection : public DynamicObject
+class DbConnection : public ReflectionObjectImpl<DbConnection>
 {
 public:
        DECLARE_PTR_TYPEDEFS(DbConnection);
@@ -60,49 +52,41 @@ public:
        void SetStatusUpdate(const DbObject::Ptr& dbobj, bool hasupdate);
        bool GetStatusUpdate(const DbObject::Ptr& dbobj) const;
 
-       String GetTablePrefix(void) const;
-        Dictionary::Ptr GetCleanUp(void) const;
-        Value GetCleanUpAcknowledgementsAge(void) const;
-        Value GetCleanUpCommentHistoryAge(void) const;
-        Value GetCleanUpContactNotificationsAge(void) const;
-        Value GetCleanUpContactNotificationMethodsAge(void) const;
-        Value GetCleanUpDowntimeHistoryAge(void) const;
-        Value GetCleanUpEventHandlersAge(void) const;
-        Value GetCleanUpExternalCommandsAge(void) const;
-        Value GetCleanUpFlappingHistoryAge(void) const;
-        Value GetCleanUpHostChecksAge(void) const;
-        Value GetCleanUpLogEntriesAge(void) const;
-        Value GetCleanUpNotificationsAge(void) const;
-        Value GetCleanUpProcessEventsAge(void) const;
-        Value GetCleanUpStateHistoryAge(void) const;
-        Value GetCleanUpServiceChecksAge(void) const;
-        Value GetCleanUpSystemCommandsAge(void) const;
+       double GetCleanupAcknowledgementsAge(void) const;
+       double GetCleanupCommentHistoryAge(void) const;
+       double GetCleanupContactNotificationsAge(void) const;
+       double GetCleanupContactNotificationMethodsAge(void) const;
+       double GetCleanupDowntimeHistoryAge(void) const;
+       double GetCleanupEventHandlersAge(void) const;
+       double GetCleanupExternalCommandsAge(void) const;
+       double GetCleanupFlappingHistoryAge(void) const;
+       double GetCleanupHostChecksAge(void) const;
+       double GetCleanupLogEntriesAge(void) const;
+       double GetCleanupNotificationsAge(void) const;
+       double GetCleanupProcessEventsAge(void) const;
+       double GetCleanupStateHistoryAge(void) const;
+       double GetCleanupServiceChecksAge(void) const;
+       double GetCleanupSystemCommandsAge(void) const;
 
 protected:
        virtual void Start(void);
 
-       virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
-       virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
-
        virtual void ExecuteQuery(const DbQuery& query) = 0;
        virtual void ActivateObject(const DbObject::Ptr& dbobj) = 0;
        virtual void DeactivateObject(const DbObject::Ptr& dbobj) = 0;
 
-        virtual void CleanUpExecuteQuery(const String& table, const String& time_key, double time_value) = 0;
+       virtual void CleanUpExecuteQuery(const String& table, const String& time_key, double time_value) = 0;
 
        void UpdateAllObjects(void);
 
 private:
-       String m_TablePrefix;
-        Dictionary::Ptr m_CleanUp;
-
        std::map<DbObject::Ptr, DbReference> m_ObjectIDs;
        std::map<DbObject::Ptr, DbReference> m_InsertIDs;
        std::set<DbObject::Ptr> m_ConfigUpdates;
        std::set<DbObject::Ptr> m_StatusUpdates;
-        Timer::Ptr m_CleanUpTimer;
+       Timer::Ptr m_CleanUpTimer;
 
-        void CleanUpHandler(void);
+       void CleanUpHandler(void);
 
        static Timer::Ptr m_ProgramStatusTimer;
 
diff --git a/lib/db_ido/dbconnection.ti b/lib/db_ido/dbconnection.ti
new file mode 100644 (file)
index 0000000..d7132cd
--- /dev/null
@@ -0,0 +1,18 @@
+#include "base/dynamicobject.h"
+#include <boost/smart_ptr/make_shared.hpp>
+
+namespace icinga
+{
+
+class DbConnection : DynamicObject
+{
+       [config] String table_prefix {
+               default {{{ return "icinga_"; }}}
+       };
+
+       [config] Dictionary::Ptr cleanup {
+               default {{{ return boost::make_shared<Dictionary>(); }}}
+       };
+};
+
+}
\ No newline at end of file
index d0ae5992169444c4a79423c5a6540b6adf0da020..ab723e216bdd912e13d25dacc37f683b99c8b22e 100644 (file)
@@ -362,9 +362,6 @@ void ServiceDbObject::AddComments(const Service::Ptr& service)
        /* dump all comments */
        Dictionary::Ptr comments = service->GetComments();
 
-       if (!comments)
-               return;
-
        ObjectLock olock(comments);
 
        String comment_id;
@@ -532,9 +529,6 @@ void ServiceDbObject::AddDowntimes(const Service::Ptr& service)
        /* dump all downtimes */
        Dictionary::Ptr downtimes = service->GetDowntimes();
 
-       if (!downtimes)
-               return;
-
        ObjectLock olock(downtimes);
 
        String downtime_id;
@@ -926,7 +920,7 @@ void ServiceDbObject::AddStateChangeHistory(const Service::Ptr& service, const D
        fields1->Set("state_change", 1); /* service */
        fields1->Set("state", service->GetState());
        fields1->Set("state_type", service->GetStateType());
-       fields1->Set("current_check_attempt", service->GetCurrentCheckAttempt());
+       fields1->Set("current_check_attempt", service->GetCheckAttempt());
        fields1->Set("max_check_attempts", service->GetMaxCheckAttempts());
        fields1->Set("last_state", service->GetLastState());
        fields1->Set("last_hard_state", service->GetLastHardState());
index f625a58aa83fe86fd9dbfce70bb34add52f4a30d..f644fedf6f7eab022f980b3c06a2d41973ce6e9e 100644 (file)
@@ -4,37 +4,63 @@
 pkglib_LTLIBRARIES =  \
        libicinga.la
 
+BUILT_SOURCES = \
+       checkcommand.th \
+       command.th \
+       domain.th \
+       eventcommand.th \
+       host.th \
+       hostgroup.th \
+       icingaapplication.th \
+       notification.th \
+       notificationcommand.th \
+       service.th \
+       servicegroup.th \
+       timeperiod.th \
+       user.th \
+       usergroup.th
+
 CLEANFILES = \
        icinga-type.cpp
 
 .conf.cpp: $(top_builddir)/tools/mkembedconfig/mkembedconfig
        $(top_builddir)/tools/mkembedconfig/mkembedconfig $< $@
 
+.ti.th: $(top_builddir)/tools/mkclass/mkclass
+       $(top_builddir)/tools/mkclass/mkclass $< > $@
+
 libicinga_la_SOURCES =  \
        api.cpp \
        api.h \
        checkcommand.cpp \
        checkcommand.h \
+       checkcommand.ti \
        cib.cpp \
        cib.h \
        command.cpp \
        command.h \
+       command.ti \
        compatutility.cpp \
        compatutility.h \
        domain.cpp \
        domain.h \
+       domain.ti \
        eventcommand.cpp \
        eventcommand.h \
+       eventcommand.ti \
        externalcommandprocessor.cpp \
        externalcommandprocessor.h \
        host.cpp \
+       host.h \
+       host.ti \
        hostgroup.cpp \
        hostgroup.h \
-       host.h \
+       hostgroup.ti \
        i2-icinga.h \
        icinga-type.conf \
        icingaapplication.cpp \
        icingaapplication.h \
+       icingaapplication.ti \
        legacytimeperiod.cpp \
        legacytimeperiod.h \
        macroprocessor.cpp \
@@ -43,8 +69,10 @@ libicinga_la_SOURCES =  \
        macroresolver.h \
        notification.cpp \
        notification.h \
+       notification.ti \
        notificationcommand.cpp \
        notificationcommand.h \
+       notificationcommand.ti \
        nullchecktask.cpp \
        nullchecktask.h \
        nulleventtask.cpp \
@@ -58,21 +86,26 @@ libicinga_la_SOURCES =  \
        randomchecktask.cpp \
        randomchecktask.h \
        service.cpp \
+       service.h \
+       service.ti \
        service-check.cpp \
        service-comment.cpp \
        service-downtime.cpp \
        service-event.cpp \
        service-flapping.cpp \
        service-notification.cpp \
-       service.h \
        servicegroup.cpp \
        servicegroup.h \
+       servicegroup.ti \
        timeperiod.cpp \
        timeperiod.h \
+       timeperiod.ti \
        user.cpp \
        user.h \
+       user.ti \
        usergroup.cpp \
-       usergroup.h
+       usergroup.h \
+       usergroup.ti
 
 libicinga_la_CPPFLAGS = \
        -DI2_ICINGA_BUILD \
index 967e3f966d0d2856e68eaaaf08efff86acc64f59..4063187d1f32a761cc3d1f8b80196799073c3747 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef CHECKCOMMAND_H
 #define CHECKCOMMAND_H
 
-#include "icinga/command.h"
+#include "icinga/checkcommand.th"
 #include "icinga/service.h"
 
 namespace icinga
@@ -31,7 +31,7 @@ namespace icinga
  *
  * @ingroup icinga
  */
-class I2_ICINGA_API CheckCommand : public Command
+class I2_ICINGA_API CheckCommand : public ReflectionObjectImpl<CheckCommand>
 {
 public:
        DECLARE_PTR_TYPEDEFS(CheckCommand);
diff --git a/lib/icinga/checkcommand.ti b/lib/icinga/checkcommand.ti
new file mode 100644 (file)
index 0000000..0e5d5bc
--- /dev/null
@@ -0,0 +1,10 @@
+#include "icinga/command.h"
+
+namespace icinga
+{
+
+class CheckCommand : Command
+{
+};
+
+}
\ No newline at end of file
index cfb95cd0836795b765dda60de7801ecda333463c..2bd1749bc2953bc91966fc04301226fcdd905722 100644 (file)
 
 using namespace icinga;
 
-Value Command::GetCommandLine(void) const
-{
-       return m_CommandLine;
-}
-
-double Command::GetTimeout(void) const
-{
-       if (m_Timeout.IsEmpty())
-               return 300;
-       else
-               return m_Timeout;
-}
-
-Dictionary::Ptr Command::GetMacros(void) const
-{
-       return m_Macros;
-}
-
-Array::Ptr Command::GetExportMacros(void) const
-{
-       return m_ExportMacros;
-}
-
-Array::Ptr Command::GetEscapeMacros(void) const
-{
-       return m_EscapeMacros;
-}
-
 bool Command::ResolveMacro(const String& macro, const Dictionary::Ptr&, String *result) const
 {
        Dictionary::Ptr macros = GetMacros();
@@ -60,30 +32,3 @@ bool Command::ResolveMacro(const String& macro, const Dictionary::Ptr&, String *
 
        return false;
 }
-
-void Command::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
-{
-       DynamicObject::InternalSerialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               bag->Set("command", m_CommandLine);
-               bag->Set("timeout", m_Timeout);
-               bag->Set("macros", m_Macros);
-               bag->Set("export_macros", m_ExportMacros);
-               bag->Set("escape_macros", m_EscapeMacros);
-       }
-}
-
-void Command::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
-{
-       DynamicObject::InternalDeserialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               m_CommandLine = bag->Get("command");
-               m_Timeout = bag->Get("timeout");
-               m_Macros = bag->Get("macros");
-               m_Macros = bag->Get("macros");
-               m_ExportMacros = bag->Get("export_macros");
-               m_EscapeMacros = bag->Get("escape_macros");
-       }
-}
index df9b63f5fc2bb499c79f66b61d2f9b2f82bc760e..236279425f8c95c709bfcf2121533cd9b5be1197 100644 (file)
 #ifndef COMMAND_H
 #define COMMAND_H
 
+#include "icinga/command.th"
 #include "icinga/macroresolver.h"
 #include "base/i2-base.h"
 #include "base/array.h"
-#include "base/dynamicobject.h"
 #include "base/logger_fwd.h"
 #include <set>
 
@@ -35,31 +35,14 @@ namespace icinga
  *
  * @ingroup icinga
  */
-class I2_ICINGA_API Command : public DynamicObject, public MacroResolver
+class I2_ICINGA_API Command : public ReflectionObjectImpl<Command>, public MacroResolver
 {
 public:
        DECLARE_PTR_TYPEDEFS(Command);
 
        //virtual Dictionary::Ptr Execute(const Object::Ptr& context) = 0;
 
-       Value GetCommandLine(void) const;
-       double GetTimeout(void) const;
-
-       Dictionary::Ptr GetMacros(void) const;
-       Array::Ptr GetExportMacros(void) const;
-       Array::Ptr GetEscapeMacros(void) const;
        virtual bool ResolveMacro(const String& macro, const Dictionary::Ptr& cr, String *result) const;
-
-protected:
-       virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
-       virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
-
-private:
-       Value m_CommandLine;
-       Value m_Timeout;
-       Dictionary::Ptr m_Macros;
-       Array::Ptr m_ExportMacros;
-       Array::Ptr m_EscapeMacros;
 };
 
 }
diff --git a/lib/icinga/command.ti b/lib/icinga/command.ti
new file mode 100644 (file)
index 0000000..7b62f4e
--- /dev/null
@@ -0,0 +1,17 @@
+#include "base/dynamicobject.h"
+
+namespace icinga
+{
+
+class Command : DynamicObject
+{
+       [config] Value command_line;
+       [config] Value timeout {
+               default {{{ return 300; }}}
+       };
+       [config] Dictionary::Ptr macros;
+       [config] Array::Ptr export_macros;
+       [config] Array::Ptr escape_macros;
+};
+
+}
\ No newline at end of file
index 096e9084db38d5e8fac5ddcd8403e1328d6fc1d3..04b33791e62ebad87f01143d107c6d7a32ebe4ac 100644 (file)
@@ -263,7 +263,7 @@ Dictionary::Ptr CompatUtility::GetServiceStatusAttributes(const Service::Ptr& se
        attr->Set("check_type", (service->GetEnableActiveChecks() ? 0 : 1));
        attr->Set("last_check", schedule_end);
        attr->Set("next_check", service->GetNextCheck());
-       attr->Set("current_attempt", service->GetCurrentCheckAttempt());
+       attr->Set("current_attempt", service->GetCheckAttempt());
        attr->Set("max_attempts", service->GetMaxCheckAttempts());
        attr->Set("last_state_change", service->GetLastStateChange());
        attr->Set("last_hard_state_change", service->GetLastHardStateChange());
@@ -393,7 +393,7 @@ Dictionary::Ptr CompatUtility::GetServiceConfigAttributes(const Service::Ptr& se
        attr->Set("high_flap_threshold", service->GetFlappingThreshold());
        attr->Set("notifications_enabled", (service->GetEnableNotifications() ? 1 : 0));
        attr->Set("eventhandler_enabled", 1); /* always 1 */
-       attr->Set("is_volatile", (service->IsVolatile() ? 1 : 0));
+       attr->Set("is_volatile", (service->GetVolatile() ? 1 : 0));
        attr->Set("notifications_enabled", (service->GetEnableNotifications() ? 1 : 0));
        attr->Set("notification_options", boost::algorithm::join(notification_options, ","));
        attr->Set("notification_interval", notification_interval / 60.0);
index 3e6d5fb9496f6a946641a27a3f0dffcfd23809ee..3a049de0221405c2a5d20a783327fcbd804cb192 100644 (file)
@@ -24,30 +24,7 @@ using namespace icinga;
 
 REGISTER_TYPE(Domain);
 
-Dictionary::Ptr Domain::GetAcl(void) const
-{
-       return m_Acl;
-}
-
 int Domain::GetPrivileges(const String& instance) const
 {
-       return m_Acl->Get(instance);
-}
-
-void Domain::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
-{
-       DynamicObject::InternalSerialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               bag->Set("acl", m_Acl);
-       }
-}
-
-void Domain::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
-{
-       DynamicObject::InternalDeserialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               m_Acl = bag->Get("acl");
-       }
+       return GetAcl()->Get(instance);
 }
index 252b040a7158dc3fe260e39eafe58ac3ca168c04..cdee0746c1d506b7dbaf19c8eabd5404b9953585 100644 (file)
@@ -21,7 +21,7 @@
 #define DOMAIN_H
 
 #include "icinga/i2-icinga.h"
-#include "base/dynamicobject.h"
+#include "icinga/domain.th"
 #include "base/dictionary.h"
 
 namespace icinga
@@ -32,21 +32,13 @@ namespace icinga
  *
  * @ingroup icinga
  */
-class I2_ICINGA_API Domain : public DynamicObject
+class I2_ICINGA_API Domain : public ReflectionObjectImpl<Domain>
 {
 public:
        DECLARE_PTR_TYPEDEFS(Domain);
        DECLARE_TYPENAME(Domain);
 
-       Dictionary::Ptr GetAcl(void) const;
        int GetPrivileges(const String& instance) const;
-
-protected:
-       virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
-       virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
-
-private:
-       Dictionary::Ptr m_Acl;
 };
 
 }
diff --git a/lib/icinga/domain.ti b/lib/icinga/domain.ti
new file mode 100644 (file)
index 0000000..6ec8f06
--- /dev/null
@@ -0,0 +1,11 @@
+#include "base/dynamicobject.h"
+
+namespace icinga
+{
+
+class Domain : DynamicObject
+{
+       [config] Dictionary::Ptr acl;
+};
+
+}
\ No newline at end of file
index 9a1ad81845791d44e63b9a5e3f3acf85bd1afa49..baf27c699b908c5a3f413486aaea9a75d9d60de2 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef EVENTCOMMAND_H
 #define EVENTCOMMAND_H
 
-#include "icinga/command.h"
+#include "icinga/eventcommand.th"
 #include "icinga/service.h"
 
 namespace icinga
@@ -31,7 +31,7 @@ namespace icinga
  *
  * @ingroup icinga
  */
-class I2_ICINGA_API EventCommand : public Command
+class I2_ICINGA_API EventCommand : public ReflectionObjectImpl<EventCommand>
 {
 public:
        DECLARE_PTR_TYPEDEFS(EventCommand);
diff --git a/lib/icinga/eventcommand.ti b/lib/icinga/eventcommand.ti
new file mode 100644 (file)
index 0000000..a3913bb
--- /dev/null
@@ -0,0 +1,10 @@
+#include "icinga/command.h"
+
+namespace icinga
+{
+
+class EventCommand : Command
+{
+};
+
+}
\ No newline at end of file
index 16a8b71e90be3a0045a4ae56b5cbbb5091dcc068..9c148d29312556e6c23da2208f093034c6e272bd 100644 (file)
@@ -84,44 +84,6 @@ void Host::Stop(void)
        // TODO: unregister slave services/notifications?
 }
 
-String Host::GetDisplayName(void) const
-{
-       if (!m_DisplayName.IsEmpty())
-               return m_DisplayName;
-       else
-               return GetName();
-}
-
-Array::Ptr Host::GetGroups(void) const
-{
-       return m_Groups;
-}
-
-Dictionary::Ptr Host::GetMacros(void) const
-{
-       return m_Macros;
-}
-
-Array::Ptr Host::GetHostDependencies(void) const
-{
-       return m_HostDependencies;;
-}
-
-Array::Ptr Host::GetServiceDependencies(void) const
-{
-       return m_ServiceDependencies;
-}
-
-String Host::GetCheck(void) const
-{
-       return m_Check;
-}
-
-Dictionary::Ptr Host::GetNotificationDescriptions(void) const
-{
-       return m_NotificationDescriptions;
-}
-
 bool Host::IsReachable(void) const
 {
        ASSERT(!OwnsLock());
@@ -182,13 +144,15 @@ void Host::UpdateSlaveServices(void)
        if (!item)
                return;
 
-       if (!m_ServiceDescriptions)
+       Dictionary::Ptr service_descriptions = GetServiceDescriptions();
+
+       if (!service_descriptions)
                return;
 
-       ObjectLock olock(m_ServiceDescriptions);
+       ObjectLock olock(service_descriptions);
        String svcname;
        Value svcdesc;
-       BOOST_FOREACH(boost::tie(svcname, svcdesc), m_ServiceDescriptions) {
+       BOOST_FOREACH(boost::tie(svcname, svcdesc), service_descriptions) {
                if (svcdesc.IsScalar())
                        svcname = svcdesc;
 
@@ -332,7 +296,7 @@ std::set<Host::Ptr> Host::GetParentHosts(void) const
 
 std::set<Host::Ptr> Host::GetChildHosts(void) const
 {
-       std::set<Host::Ptr> childs;
+       std::set<Host::Ptr> children;
 
         BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjects<Host>()) {
                Array::Ptr dependencies = host->GetHostDependencies();
@@ -342,13 +306,12 @@ std::set<Host::Ptr> Host::GetChildHosts(void) const
 
                        BOOST_FOREACH(const Value& value, dependencies) {
                                if (value == GetName())
-                                       childs.insert(host);
+                                       children.insert(host);
                        }
                }
        }
 
-       return childs;
-
+       return children;
 }
 
 Service::Ptr Host::GetCheckService(void) const
@@ -500,7 +463,7 @@ double Host::GetLastStateChange(void) const
        Service::Ptr hc = GetCheckService();
 
        if (!hc)
-               return IcingaApplication::GetInstance()->GetStartTime();
+               return Application::GetStartTime();
 
        return hc->GetLastStateChange();
 }
@@ -511,7 +474,7 @@ double Host::GetLastHardStateChange(void) const
        Service::Ptr hc = GetCheckService();
 
        if (!hc)
-               return IcingaApplication::GetInstance()->GetStartTime();
+               return Application::GetStartTime();
 
        return hc->GetLastHardStateChange();
 }
@@ -593,7 +556,7 @@ bool Host::ResolveMacro(const String& macro, const Dictionary::Ptr&, String *res
                        *result = Service::StateTypeToString(hc->GetStateType());
                        return true;
                } else if (macro == "HOSTATTEMPT") {
-                       *result = Convert::ToString(hc->GetCurrentCheckAttempt());
+                       *result = Convert::ToString(hc->GetCheckAttempt());
                        return true;
                } else if (macro == "MAXHOSTATTEMPT") {
                        *result = Convert::ToString(hc->GetMaxCheckAttempts());
@@ -658,35 +621,3 @@ bool Host::ResolveMacro(const String& macro, const Dictionary::Ptr&, String *res
 
        return false;
 }
-
-void Host::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
-{
-       DynamicObject::InternalSerialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               bag->Set("display_name", m_DisplayName);
-               bag->Set("groups", m_Groups);
-               bag->Set("macros", m_Macros);
-               bag->Set("host_dependencies", m_HostDependencies);
-               bag->Set("service_dependencies", m_ServiceDependencies);
-               bag->Set("check", m_Check);
-               bag->Set("services", m_ServiceDescriptions);
-               bag->Set("notifications", m_NotificationDescriptions);
-       }
-}
-
-void Host::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
-{
-       DynamicObject::InternalDeserialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               m_DisplayName = bag->Get("display_name");
-               m_Groups = bag->Get("groups");
-               m_Macros = bag->Get("macros");
-               m_HostDependencies = bag->Get("host_dependencies");
-               m_ServiceDependencies = bag->Get("service_dependencies");
-               m_Check = bag->Get("check");
-               m_ServiceDescriptions = bag->Get("services");
-               m_NotificationDescriptions = bag->Get("notifications");
-       }
-}
index f11ad2fe0a2840a45687ecc8314abcbe5ef30bb4..123841dcb9230dd866727d829d0fcdf689cdda4b 100644 (file)
@@ -21,9 +21,9 @@
 #define HOST_H
 
 #include "icinga/i2-icinga.h"
+#include "icinga/host.th"
 #include "icinga/macroresolver.h"
 #include "base/array.h"
-#include "base/dynamicobject.h"
 #include "base/dictionary.h"
 
 namespace icinga
@@ -43,51 +43,17 @@ enum HostState
        HostUnreachable = 2
 };
 
-/**
- * The state of a service.
- *
- * @ingroup icinga
- */
-enum ServiceState
-{
-       StateOK = 0,
-       StateWarning = 1,
-       StateCritical = 2,
-       StateUnknown = 3
-};
-
-/**
- * The state type of a host or service.
- *
- * @ingroup icinga
- */
-enum StateType
-{
-       StateTypeSoft = 0,
-       StateTypeHard = 1
-};
-
 /**
  * An Icinga host.
  *
  * @ingroup icinga
  */
-class I2_ICINGA_API Host : public DynamicObject, public MacroResolver
+class I2_ICINGA_API Host : public ReflectionObjectImpl<Host>, public MacroResolver
 {
 public:
        DECLARE_PTR_TYPEDEFS(Host);
        DECLARE_TYPENAME(Host);
 
-       String GetDisplayName(void) const;
-       Array::Ptr GetGroups(void) const;
-
-       Dictionary::Ptr GetMacros(void) const;
-       Array::Ptr GetHostDependencies(void) const;
-       Array::Ptr GetServiceDependencies(void) const;
-       String GetCheck(void) const;
-       //Dictionary::Ptr GetServiceDescriptions(void) const;
-       Dictionary::Ptr GetNotificationDescriptions(void) const;
-
        shared_ptr<Service> GetCheckService(void) const;
        std::set<Host::Ptr> GetParentHosts(void) const;
        std::set<Host::Ptr> GetChildHosts(void) const;
@@ -126,19 +92,7 @@ protected:
 
        virtual void OnConfigLoaded(void);
 
-       virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
-       virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
-
 private:
-       String m_DisplayName;
-       Array::Ptr m_Groups;
-       Dictionary::Ptr m_Macros;
-       Array::Ptr m_HostDependencies;
-       Array::Ptr m_ServiceDependencies;
-       String m_Check;
-       Dictionary::Ptr m_ServiceDescriptions;
-       Dictionary::Ptr m_NotificationDescriptions;
-
        mutable boost::mutex m_ServicesMutex;
        std::map<String, shared_ptr<Service> > m_Services;
 
diff --git a/lib/icinga/host.ti b/lib/icinga/host.ti
new file mode 100644 (file)
index 0000000..bef23f4
--- /dev/null
@@ -0,0 +1,45 @@
+#include "base/dynamicobject.h"
+
+namespace icinga
+{
+
+code {{{
+/**
+ * The state of a service.
+ *
+ * @ingroup icinga
+ */
+enum ServiceState
+{
+       StateOK = 0,
+       StateWarning = 1,
+       StateCritical = 2,
+       StateUnknown = 3
+};
+
+/**
+ * The state type of a host or service.
+ *
+ * @ingroup icinga
+ */
+enum StateType
+{
+       StateTypeSoft = 0,
+       StateTypeHard = 1
+};
+}}}
+
+class Host : DynamicObject
+{
+       [config] String display_name {
+               default {{{ return GetName(); }}}
+       };
+       [config] Array::Ptr groups;
+       [config] Dictionary::Ptr macros;
+       [config] Array::Ptr host_dependencies;
+       [config] Array::Ptr service_dependencies;
+       [config] String check;
+       [config, protected] Dictionary::Ptr services (ServiceDescriptions);
+};
+
+}
\ No newline at end of file
index 693215b80eab2816d800c7bc893b886334b65483..8a5590283fcf22a5211d2d1349bab360342bd611 100644 (file)
@@ -30,14 +30,6 @@ using namespace icinga;
 
 REGISTER_TYPE(HostGroup);
 
-String HostGroup::GetDisplayName(void) const
-{
-       if (!m_DisplayName.IsEmpty())
-               return m_DisplayName;
-       else
-               return GetName();
-}
-
 std::set<Host::Ptr> HostGroup::GetMembers(void) const
 {
        return m_Members;
@@ -52,19 +44,3 @@ void HostGroup::RemoveMember(const Host::Ptr& host)
 {
        m_Members.erase(host);
 }
-
-void HostGroup::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
-{
-       DynamicObject::InternalSerialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config)
-               bag->Set("display_name", m_DisplayName);
-}
-
-void HostGroup::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
-{
-       DynamicObject::InternalDeserialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config)
-               m_DisplayName = bag->Get("display_name");
-}
index 2df55fe473650bce0a9e40b23f331897ac76ddaf..1374a123083a4eb99abaed9a83ee9d59dc9ea827 100644 (file)
@@ -21,8 +21,8 @@
 #define HOSTGROUP_H
 
 #include "icinga/i2-icinga.h"
+#include "icinga/hostgroup.th"
 #include "icinga/host.h"
-#include "base/dynamicobject.h"
 
 namespace icinga
 {
@@ -32,24 +32,17 @@ namespace icinga
  *
  * @ingroup icinga
  */
-class I2_ICINGA_API HostGroup : public DynamicObject
+class I2_ICINGA_API HostGroup : public ReflectionObjectImpl<HostGroup>
 {
 public:
        DECLARE_PTR_TYPEDEFS(HostGroup);
        DECLARE_TYPENAME(HostGroup);
 
-       String GetDisplayName(void) const;
-
        std::set<Host::Ptr> GetMembers(void) const;
        void AddMember(const Host::Ptr& host);
        void RemoveMember(const Host::Ptr& host);
 
-protected:
-       virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
-       virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
-
 private:
-       String m_DisplayName;
        std::set<Host::Ptr> m_Members;
 };
 
diff --git a/lib/icinga/hostgroup.ti b/lib/icinga/hostgroup.ti
new file mode 100644 (file)
index 0000000..cf1cd8e
--- /dev/null
@@ -0,0 +1,13 @@
+#include "base/dynamicobject.h"
+
+namespace icinga
+{
+
+class HostGroup : DynamicObject
+{
+       [config] String display_name {
+               default {{{ return GetName(); }}}
+       };
+};
+
+}
\ No newline at end of file
index e68544e0ba3cefcea734fd6a8ee5e424e7aed87a..2c290f54af76b9af09a353fe759a9313dbaecd80 100644 (file)
     </CustomBuild>
   </ItemGroup>
   <ItemGroup>
+    <CustomBuild Include="checkcommand.ti">
+      <FileType>Document</FileType>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).th;%(Outputs)</Outputs>
+    </CustomBuild>
+    <None Include="checkcommand.th" />
+    <CustomBuild Include="command.ti">
+      <FileType>Document</FileType>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).th;%(Outputs)</Outputs>
+    </CustomBuild>
+    <None Include="command.th" />
+    <CustomBuild Include="eventcommand.ti">
+      <FileType>Document</FileType>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).th;%(Outputs)</Outputs>
+    </CustomBuild>
+    <CustomBuild Include="domain.ti">
+      <FileType>Document</FileType>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).th;%(Outputs)</Outputs>
+    </CustomBuild>
+    <None Include="eventcommand.th" />
+    <CustomBuild Include="host.ti">
+      <FileType>Document</FileType>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).th;%(Outputs)</Outputs>
+    </CustomBuild>
+    <None Include="host.th" />
+    <CustomBuild Include="hostgroup.ti">
+      <FileType>Document</FileType>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).th;%(Outputs)</Outputs>
+    </CustomBuild>
+    <None Include="hostgroup.th" />
+    <CustomBuild Include="icingaapplication.ti">
+      <FileType>Document</FileType>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).th;%(Outputs)</Outputs>
+    </CustomBuild>
+    <None Include="icingaapplication.th" />
+    <CustomBuild Include="notificationcommand.ti">
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).th;%(Outputs)</Outputs>
+    </CustomBuild>
+    <CustomBuild Include="notification.ti">
+      <FileType>Document</FileType>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).th;%(Outputs)</Outputs>
+    </CustomBuild>
+    <None Include="notification.th" />
+    <None Include="notificationcommand.th" />
     <None Include="packages.config" />
+    <CustomBuild Include="timeperiod.ti">
+      <FileType>Document</FileType>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).th;%(Outputs)</Outputs>
+    </CustomBuild>
+    <CustomBuild Include="servicegroup.ti">
+      <FileType>Document</FileType>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).th;%(Outputs)</Outputs>
+    </CustomBuild>
+    <CustomBuild Include="service.ti">
+      <FileType>Document</FileType>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).th;%(Outputs)</Outputs>
+    </CustomBuild>
+    <None Include="service.th" />
+    <None Include="servicegroup.th" />
+    <None Include="timeperiod.th" />
+    <CustomBuild Include="usergroup.ti">
+      <FileType>Document</FileType>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).th;%(Outputs)</Outputs>
+    </CustomBuild>
+    <CustomBuild Include="user.ti">
+      <FileType>Document</FileType>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(SolutionDir)$(Platform)\$(Configuration)\mkclass.exe" "%(Identity)" &gt; "%(Filename).th"</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).th;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).th;%(Outputs)</Outputs>
+    </CustomBuild>
+    <None Include="user.th" />
+    <None Include="usergroup.th" />
   </ItemGroup>
   <PropertyGroup Label="Globals">
     <ProjectGuid>{C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}</ProjectGuid>
     <Import Project="..\..\packages\boost_date_time.1.54.0.2\build\native\boost_date_time.targets" Condition="Exists('..\..\packages\boost_date_time.1.54.0.2\build\native\boost_date_time.targets')" />
     <Import Project="..\..\packages\boost_chrono.1.54.0.2\build\native\boost_chrono.targets" Condition="Exists('..\..\packages\boost_chrono.1.54.0.2\build\native\boost_chrono.targets')" />
   </ImportGroup>
-</Project>
+</Project>
\ No newline at end of file
index daa423c9e6d9a4a28e6a85cc9e8c84ae1ee4a878..71d2b310636512900666271214dfaf05669132b5 100644 (file)
     <ClCompile Include="domain.cpp">
       <Filter>Quelldateien</Filter>
     </ClCompile>
+    <ClCompile Include="randomchecktask.cpp">
+      <Filter>Quelldateien</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="i2-icinga.h">
     <ClInclude Include="domain.h">
       <Filter>Headerdateien</Filter>
     </ClInclude>
+    <ClInclude Include="randomchecktask.h">
+      <Filter>Headerdateien</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <Filter Include="Headerdateien">
     <CustomBuild Include="icinga-type.conf">
       <Filter>Quelldateien</Filter>
     </CustomBuild>
+    <CustomBuild Include="checkcommand.ti">
+      <Filter>Headerdateien</Filter>
+    </CustomBuild>
+    <CustomBuild Include="command.ti">
+      <Filter>Headerdateien</Filter>
+    </CustomBuild>
+    <CustomBuild Include="eventcommand.ti">
+      <Filter>Headerdateien</Filter>
+    </CustomBuild>
+    <CustomBuild Include="domain.ti">
+      <Filter>Headerdateien</Filter>
+    </CustomBuild>
+    <CustomBuild Include="host.ti">
+      <Filter>Headerdateien</Filter>
+    </CustomBuild>
+    <CustomBuild Include="hostgroup.ti">
+      <Filter>Headerdateien</Filter>
+    </CustomBuild>
+    <CustomBuild Include="icingaapplication.ti">
+      <Filter>Headerdateien</Filter>
+    </CustomBuild>
+    <CustomBuild Include="timeperiod.ti">
+      <Filter>Headerdateien</Filter>
+    </CustomBuild>
+    <CustomBuild Include="usergroup.ti">
+      <Filter>Headerdateien</Filter>
+    </CustomBuild>
+    <CustomBuild Include="servicegroup.ti">
+      <Filter>Headerdateien</Filter>
+    </CustomBuild>
+    <CustomBuild Include="notificationcommand.ti">
+      <Filter>Headerdateien</Filter>
+    </CustomBuild>
+    <CustomBuild Include="notification.ti">
+      <Filter>Headerdateien</Filter>
+    </CustomBuild>
+    <CustomBuild Include="user.ti">
+      <Filter>Headerdateien</Filter>
+    </CustomBuild>
+    <CustomBuild Include="service.ti">
+      <Filter>Headerdateien</Filter>
+    </CustomBuild>
   </ItemGroup>
   <ItemGroup>
     <None Include="packages.config" />
+    <None Include="checkcommand.th">
+      <Filter>Headerdateien</Filter>
+    </None>
+    <None Include="command.th">
+      <Filter>Headerdateien</Filter>
+    </None>
+    <None Include="eventcommand.th">
+      <Filter>Headerdateien</Filter>
+    </None>
+    <None Include="host.th">
+      <Filter>Headerdateien</Filter>
+    </None>
+    <None Include="hostgroup.th">
+      <Filter>Headerdateien</Filter>
+    </None>
+    <None Include="icingaapplication.th">
+      <Filter>Headerdateien</Filter>
+    </None>
+    <None Include="timeperiod.th">
+      <Filter>Headerdateien</Filter>
+    </None>
+    <None Include="usergroup.th">
+      <Filter>Headerdateien</Filter>
+    </None>
+    <None Include="servicegroup.th">
+      <Filter>Headerdateien</Filter>
+    </None>
+    <None Include="notificationcommand.th">
+      <Filter>Headerdateien</Filter>
+    </None>
+    <None Include="notification.th">
+      <Filter>Headerdateien</Filter>
+    </None>
+    <None Include="user.th">
+      <Filter>Headerdateien</Filter>
+    </None>
+    <None Include="service.th">
+      <Filter>Headerdateien</Filter>
+    </None>
   </ItemGroup>
 </Project>
\ No newline at end of file
index 0a3f1bf3f3438a8df6660953001fb8e3a393e466..f8e567515f98c5ac990b4967de0c984c52124957 100644 (file)
@@ -54,8 +54,6 @@ int IcingaApplication::Main(void)
 {
        Log(LogDebug, "icinga", "In IcingaApplication::Main()");
 
-       m_StartTime = Utility::GetTime();
-
        /* periodically dump the program state */
        l_RetentionTimer = boost::make_shared<Timer>();
        l_RetentionTimer->SetInterval(300);
@@ -96,13 +94,6 @@ Dictionary::Ptr IcingaApplication::GetMacros(void) const
        return ScriptVariable::Get("IcingaMacros");
 }
 
-double IcingaApplication::GetStartTime(void) const
-{
-       ObjectLock olock(this);
-
-       return m_StartTime;
-}
-
 bool IcingaApplication::ResolveMacro(const String& macro, const Dictionary::Ptr&, String *result) const
 {
        double now = Utility::GetTime();
@@ -136,116 +127,90 @@ bool IcingaApplication::ResolveMacro(const String& macro, const Dictionary::Ptr&
 
 bool IcingaApplication::GetEnableNotifications(void) const
 {
-       if (!m_OverrideEnableNotifications.IsEmpty())
-               return m_OverrideEnableNotifications;
+       if (!GetOverrideEnableNotifications().IsEmpty())
+               return GetOverrideEnableNotifications();
        else
                return ScriptVariable::Get("IcingaEnableNotifications");
 }
 
 void IcingaApplication::SetEnableNotifications(bool enabled)
 {
-       m_OverrideEnableNotifications = enabled;
+       SetOverrideEnableNotifications(enabled);
 }
 
 void IcingaApplication::ClearEnableNotifications(void)
 {
-       m_OverrideEnableNotifications = Empty;
+       SetOverrideEnableNotifications(Empty);
 }
 
 bool IcingaApplication::GetEnableEventHandlers(void) const
 {
-       if (!m_OverrideEnableEventHandlers.IsEmpty())
-               return m_OverrideEnableEventHandlers;
+       if (!GetOverrideEnableEventHandlers().IsEmpty())
+               return GetOverrideEnableEventHandlers();
        else
                return ScriptVariable::Get("IcingaEnableEventHandlers");
 }
 
 void IcingaApplication::SetEnableEventHandlers(bool enabled)
 {
-       m_OverrideEnableEventHandlers = enabled;
+       SetOverrideEnableEventHandlers(enabled);
 }
 
 void IcingaApplication::ClearEnableEventHandlers(void)
 {
-       m_OverrideEnableEventHandlers = Empty;
+       SetOverrideEnableEventHandlers(Empty);
 }
 
 bool IcingaApplication::GetEnableFlapping(void) const
 {
-       if (!m_OverrideEnableFlapping.IsEmpty())
-               return m_OverrideEnableFlapping;
+       if (!GetOverrideEnableFlapping().IsEmpty())
+               return GetOverrideEnableFlapping();
        else
                return ScriptVariable::Get("IcingaEnableFlapping");
 }
 
 void IcingaApplication::SetEnableFlapping(bool enabled)
 {
-       m_OverrideEnableFlapping = enabled;
+       SetOverrideEnableFlapping(enabled);
 }
 
 void IcingaApplication::ClearEnableFlapping(void)
 {
-       m_OverrideEnableFlapping = Empty;
+       SetOverrideEnableFlapping(Empty);
 }
 
 bool IcingaApplication::GetEnableChecks(void) const
 {
-       if (!m_OverrideEnableChecks.IsEmpty())
-               return m_OverrideEnableChecks;
+       if (!GetOverrideEnableChecks().IsEmpty())
+               return GetOverrideEnableChecks();
        else
                return ScriptVariable::Get("IcingaEnableChecks");
 }
 
 void IcingaApplication::SetEnableChecks(bool enabled)
 {
-       m_OverrideEnableChecks = enabled;
+       SetOverrideEnableChecks(enabled);
 }
 
 void IcingaApplication::ClearEnableChecks(void)
 {
-       m_OverrideEnableChecks = Empty;
+       SetOverrideEnableChecks(Empty);
 }
 
 bool IcingaApplication::GetEnablePerfdata(void) const
 {
-       if (!m_OverrideEnablePerfdata.IsEmpty())
-               return m_OverrideEnablePerfdata;
+       if (!GetOverrideEnablePerfdata().IsEmpty())
+               return GetOverrideEnablePerfdata();
        else
                return ScriptVariable::Get("IcingaEnablePerfdata");
 }
 
 void IcingaApplication::SetEnablePerfdata(bool enabled)
 {
-       m_OverrideEnablePerfdata = enabled;
+       SetOverrideEnablePerfdata(enabled);
 }
 
 void IcingaApplication::ClearEnablePerfdata(void)
 {
-       m_OverrideEnablePerfdata = Empty;
-}
-
-void IcingaApplication::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
-{
-       DynamicObject::InternalSerialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_State) {
-               bag->Set("override_enable_notifications", m_OverrideEnableNotifications);
-               bag->Set("override_enable_event_handlers", m_OverrideEnableEventHandlers);
-               bag->Set("override_enable_flapping", m_OverrideEnableFlapping);
-               bag->Set("override_enable_checks", m_OverrideEnableChecks);
-               bag->Set("override_enable_perfdata", m_OverrideEnablePerfdata);
-       }
-}
-
-void IcingaApplication::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
-{
-       DynamicObject::InternalDeserialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_State) {
-               m_OverrideEnableNotifications = bag->Get("override_enable_notifications");
-               m_OverrideEnableEventHandlers = bag->Get("override_enable_event_handlers");
-               m_OverrideEnableFlapping = bag->Get("override_enable_flapping");
-               m_OverrideEnableChecks = bag->Get("override_enable_checks");
-               m_OverrideEnablePerfdata = bag->Get("override_enable_perfdata");
-       }
+       SetOverrideEnablePerfdata(Empty);
 }
index acb90ec5e1f0d03a66b4659f4d87b65e9c4fa3a9..657c562392aedb4f26177127139ebd355d4b9c93 100644 (file)
@@ -21,8 +21,8 @@
 #define ICINGAAPPLICATION_H
 
 #include "icinga/i2-icinga.h"
+#include "icinga/icingaapplication.th"
 #include "icinga/macroresolver.h"
-#include "base/application.h"
 
 namespace icinga
 {
@@ -32,7 +32,7 @@ namespace icinga
  *
  * @ingroup icinga
  */
-class I2_ICINGA_API IcingaApplication : public Application, public MacroResolver
+class I2_ICINGA_API IcingaApplication : public ReflectionObjectImpl<IcingaApplication>, public MacroResolver
 {
 public:
        DECLARE_PTR_TYPEDEFS(IcingaApplication);
@@ -47,8 +47,6 @@ public:
        String GetPidPath(void) const;
        Dictionary::Ptr GetMacros(void) const;
 
-       double GetStartTime(void) const;
-
        virtual bool ResolveMacro(const String& macro, const Dictionary::Ptr& cr, String *result) const;
 
        bool GetEnableNotifications(void) const;
@@ -71,19 +69,7 @@ public:
        void SetEnablePerfdata(bool enabled);
        void ClearEnablePerfdata(void);
 
-protected:
-       virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
-       virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
-
 private:
-       double m_StartTime;
-
-       Value m_OverrideEnableNotifications;
-       Value m_OverrideEnableEventHandlers;
-       Value m_OverrideEnableFlapping;
-       Value m_OverrideEnableChecks;
-       Value m_OverrideEnablePerfdata;
-
        void DumpProgramState(void);
 
        virtual void OnShutdown(void);
diff --git a/lib/icinga/icingaapplication.ti b/lib/icinga/icingaapplication.ti
new file mode 100644 (file)
index 0000000..95d2425
--- /dev/null
@@ -0,0 +1,15 @@
+#include "base/application.h"
+
+namespace icinga
+{
+
+class IcingaApplication : Application
+{
+       [state, protected] Value override_enable_notifications;
+       [state, protected] Value override_enable_event_handlers;
+       [state, protected] Value override_enable_flapping;
+       [state, protected] Value override_enable_checks;
+       [state, protected] Value override_enable_perfdata;
+};
+
+}
\ No newline at end of file
index 6a0f321e9a950a1dfa5099b40d791bb923c0851a..797337f334651e55e38a5178de7054eaa9833db1 100644 (file)
@@ -52,37 +52,27 @@ void Notification::Stop(void)
 
 Service::Ptr Notification::GetService(void) const
 {
-       Host::Ptr host = Host::GetByName(m_HostName);
+       Host::Ptr host = Host::GetByName(GetHostRaw());
 
        if (!host)
                return Service::Ptr();
 
-       if (m_Service.IsEmpty())
+       if (GetServiceRaw().IsEmpty())
                return host->GetCheckService();
        else
-               return host->GetServiceByShortName(m_Service);
+               return host->GetServiceByShortName(GetServiceRaw());
 }
 
 NotificationCommand::Ptr Notification::GetNotificationCommand(void) const
 {
-       return NotificationCommand::GetByName(m_NotificationCommand);
-}
-
-Dictionary::Ptr Notification::GetMacros(void) const
-{
-       return m_Macros;
-}
-
-Array::Ptr Notification::GetExportMacros(void) const
-{
-       return m_ExportMacros;
+       return NotificationCommand::GetByName(GetNotificationCommandRaw());
 }
 
 std::set<User::Ptr> Notification::GetUsers(void) const
 {
        std::set<User::Ptr> result;
 
-       Array::Ptr users = m_Users;
+       Array::Ptr users = GetUsersRaw();
 
        if (users) {
                ObjectLock olock(users);
@@ -104,7 +94,7 @@ std::set<UserGroup::Ptr> Notification::GetUserGroups(void) const
 {
        std::set<UserGroup::Ptr> result;
 
-       Array::Ptr groups = m_UserGroups;
+       Array::Ptr groups = GetUserGroupsRaw();
 
        if (groups) {
                ObjectLock olock(groups);
@@ -122,62 +112,14 @@ std::set<UserGroup::Ptr> Notification::GetUserGroups(void) const
        return result;
 }
 
-Dictionary::Ptr Notification::GetTimes(void) const
-{
-       return m_Times;
-}
-
-unsigned long Notification::GetNotificationTypeFilter(void) const
-{
-       if (m_NotificationTypeFilter.IsEmpty())
-               return ~(unsigned long)0; /* All types. */
-       else
-               return m_NotificationTypeFilter;
-}
-
-unsigned long Notification::GetNotificationStateFilter(void) const
-{
-       if (m_NotificationStateFilter.IsEmpty())
-               return ~(unsigned long)0; /* All states. */
-       else
-               return m_NotificationStateFilter;
-}
-
-double Notification::GetNotificationInterval(void) const
-{
-       if (m_NotificationInterval.IsEmpty())
-               return 300;
-       else
-               return m_NotificationInterval;
-}
-
 TimePeriod::Ptr Notification::GetNotificationPeriod(void) const
 {
-       return TimePeriod::GetByName(m_NotificationPeriod);
-}
-
-double Notification::GetLastNotification(void) const
-{
-       if (m_LastNotification.IsEmpty())
-               return 0;
-       else
-               return m_LastNotification;
-}
-
-/**
- * Sets the timestamp when the last notification was sent.
- */
-void Notification::SetLastNotification(double time)
-{
-       m_LastNotification = time;
+       return TimePeriod::GetByName(GetNotificationPeriodRaw());
 }
 
 double Notification::GetNextNotification(void) const
 {
-       if (m_NextNotification.IsEmpty())
-               return 0;
-       else
-               return m_NextNotification;
+       return GetNextNotificationRaw();
 }
 
 /**
@@ -186,27 +128,19 @@ double Notification::GetNextNotification(void) const
  */
 void Notification::SetNextNotification(double time, const String& authority)
 {
-       m_NextNotification = time;
+       SetNextNotificationRaw(time);
 
        Utility::QueueAsyncCallback(boost::bind(boost::ref(OnNextNotificationChanged), GetSelf(), time, authority));
 }
 
-long Notification::GetNotificationNumber(void) const
-{
-       if (m_NotificationNumber.IsEmpty())
-               return 0;
-       else
-               return m_NotificationNumber;
-}
-
 void Notification::UpdateNotificationNumber(void)
 {
-       m_NotificationNumber = m_NotificationNumber + 1;
+       SetNotificationNumber(GetNotificationNumber() + 1);
 }
 
 void Notification::ResetNotificationNumber(void)
 {
-       m_NotificationNumber = 0;
+       SetNotificationNumber(0);
 }
 
 String Notification::NotificationTypeToString(NotificationType type)
@@ -374,55 +308,3 @@ bool Notification::ResolveMacro(const String& macro, const Dictionary::Ptr&, Str
 
        return false;
 }
-
-void Notification::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
-{
-       DynamicObject::InternalSerialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               bag->Set("notification_command", m_NotificationCommand);
-               bag->Set("notification_interval", m_NotificationInterval);
-               bag->Set("notification_period", m_NotificationPeriod);
-               bag->Set("macros", m_Macros);
-               bag->Set("users", m_Users);
-               bag->Set("user_groups", m_UserGroups);
-               bag->Set("times", m_Times);
-               bag->Set("notification_type_filter", m_NotificationTypeFilter);
-               bag->Set("notification_state_filter", m_NotificationStateFilter);
-               bag->Set("host", m_HostName);
-               bag->Set("export_macros", m_ExportMacros);
-               bag->Set("service", m_Service);
-       }
-
-       if (attributeTypes & Attribute_State) {
-               bag->Set("last_notification", m_LastNotification);
-               bag->Set("next_notification", m_NextNotification);
-               bag->Set("notification_number", m_NotificationNumber);
-       }
-}
-
-void Notification::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
-{
-       DynamicObject::InternalDeserialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               m_NotificationCommand = bag->Get("notification_command");
-               m_NotificationInterval = bag->Get("notification_interval");
-               m_NotificationPeriod = bag->Get("notification_period");
-               m_Macros = bag->Get("macros");
-               m_Users = bag->Get("users");
-               m_UserGroups = bag->Get("user_groups");
-               m_Times = bag->Get("times");
-               m_NotificationTypeFilter = bag->Get("notification_type_filter");
-               m_NotificationStateFilter = bag->Get("notification_state_filter");
-               m_HostName = bag->Get("host");
-               m_ExportMacros = bag->Get("export_macros");
-               m_Service = bag->Get("service");
-       }
-
-       if (attributeTypes & Attribute_State) {
-               m_LastNotification = bag->Get("last_notification");
-               m_NextNotification = bag->Get("next_notification");
-               m_NotificationNumber = bag->Get("notification_number");
-       }
-}
index 45031541d3aefaba5352768b93228722837f184a..3e75fa3ce0a16457fa45668b1e4be8fe4f1620ad 100644 (file)
@@ -21,6 +21,7 @@
 #define NOTIFICATION_H
 
 #include "icinga/i2-icinga.h"
+#include "icinga/notification.th"
 #include "icinga/user.h"
 #include "icinga/usergroup.h"
 #include "icinga/timeperiod.h"
@@ -55,7 +56,7 @@ class NotificationCommand;
  *
  * @ingroup icinga
  */
-class I2_ICINGA_API Notification : public DynamicObject, public MacroResolver
+class I2_ICINGA_API Notification : public ReflectionObjectImpl<Notification>, public MacroResolver
 {
 public:
        DECLARE_PTR_TYPEDEFS(Notification);
@@ -63,23 +64,13 @@ public:
 
        shared_ptr<Service> GetService(void) const;
        shared_ptr<NotificationCommand> GetNotificationCommand(void) const;
-       double GetNotificationInterval(void) const;
        TimePeriod::Ptr GetNotificationPeriod(void) const;
-       Dictionary::Ptr GetMacros(void) const;
-       Array::Ptr GetExportMacros(void) const;
        std::set<User::Ptr> GetUsers(void) const;
        std::set<UserGroup::Ptr> GetUserGroups(void) const;
-       Dictionary::Ptr GetTimes(void) const;
-       unsigned long GetNotificationTypeFilter(void) const;
-       unsigned long GetNotificationStateFilter(void) const;
-
-       double GetLastNotification(void) const;
-       void SetLastNotification(double time);
 
        double GetNextNotification(void) const;
        void SetNextNotification(double time, const String& authority = String());
 
-       long GetNotificationNumber(void) const;
        void UpdateNotificationNumber(void);
        void ResetNotificationNumber(void);
 
@@ -95,26 +86,7 @@ protected:
        virtual void Start(void);
        virtual void Stop(void);
 
-       virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
-       virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
-
 private:
-       String m_NotificationCommand;
-       Value m_NotificationInterval;
-       String m_NotificationPeriod;
-       Value m_LastNotification;
-       Value m_NextNotification;
-       Value m_NotificationNumber;
-       Dictionary::Ptr m_Macros;
-       Array::Ptr m_ExportMacros;
-       Array::Ptr m_Users;
-       Array::Ptr m_UserGroups;
-       Dictionary::Ptr m_Times;
-       Value m_NotificationTypeFilter;
-       Value m_NotificationStateFilter;
-       String m_HostName;
-       String m_Service;
-
        void ExecuteNotificationHelper(NotificationType type, const User::Ptr& user, const Dictionary::Ptr& cr, bool force, const String& author = "", const String& text = "");
 };
 
diff --git a/lib/icinga/notification.ti b/lib/icinga/notification.ti
new file mode 100644 (file)
index 0000000..d7cf424
--- /dev/null
@@ -0,0 +1,31 @@
+#include "base/dynamicobject.h"
+
+namespace icinga
+{
+
+class Notification : DynamicObject
+{
+       [config, protected] String notification_command (NotificationCommandRaw);
+       [config] double notification_interval {
+               default {{{ return 300; }}}
+       };
+       [config] String notification_period (NotificationPeriodRaw);
+       [config] Dictionary::Ptr macros;
+       [config, protected] Array::Ptr users (UsersRaw);
+       [config, protected] Array::Ptr user_groups (UserGroupsRaw);
+       [config] Dictionary::Ptr times;
+       [config] int notification_type_filter {
+               default {{{ return ~(int)0; }}}
+       };
+       [config] int notification_state_filter {
+               default {{{ return ~(int)0; }}}
+       };
+       [config, protected] String host (HostRaw);
+       [config, protected] String service (ServiceRaw);
+
+       [state] double last_notification;
+       [state, set_protected] double next_notification (NextNotificationRaw);
+       [state, set_protected] Value notification_number;
+};
+
+}
\ No newline at end of file
index 47725b947fa4d8782a5b2cb0f793d369548a7e92..3ef99f26cdabec1d6c843a7785d8ef1b903691b2 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef NOTIFICATIONCOMMAND_H
 #define NOTIFICATIONCOMMAND_H
 
-#include "icinga/command.h"
+#include "icinga/notificationcommand.th"
 #include "icinga/notification.h"
 
 namespace icinga
@@ -33,7 +33,7 @@ class Notification;
  *
  * @ingroup icinga
  */
-class I2_ICINGA_API NotificationCommand : public Command
+class I2_ICINGA_API NotificationCommand : public ReflectionObjectImpl<NotificationCommand>
 {
 public:
        DECLARE_PTR_TYPEDEFS(NotificationCommand);
diff --git a/lib/icinga/notificationcommand.ti b/lib/icinga/notificationcommand.ti
new file mode 100644 (file)
index 0000000..24d460c
--- /dev/null
@@ -0,0 +1,10 @@
+#include "icinga/command.h"
+
+namespace icinga
+{
+
+class NotificationCommand : Command
+{
+};
+
+}
\ No newline at end of file
index fd26ba4a6da0609158429814f50f1247df80f552..5cacf9e837b4a81eea4534c7f5f9e27ae888ea19 100644 (file)
@@ -64,7 +64,7 @@ void PluginNotificationTask::ScriptFunc(const Notification::Ptr& notification, c
 
        Dictionary::Ptr envMacros = boost::make_shared<Dictionary>();
 
-       Array::Ptr export_macros = notification->GetExportMacros();
+       Array::Ptr export_macros = commandObj->GetExportMacros();
 
        if (export_macros) {
                BOOST_FOREACH(const String& macro, export_macros) {
index df5c9eec17d1e612483a2a70b62f052b01e5adbc..6fd8dc0e8eeabf1bf392338080a7296ff4b0c318 100644 (file)
 
 using namespace icinga;
 
-const int Service::DefaultMaxCheckAttempts = 3;
-const double Service::DefaultCheckInterval = 5 * 60;
-const double Service::CheckIntervalDivisor = 5.0;
-
 boost::signals2::signal<void (const Service::Ptr&, const Dictionary::Ptr&, const String&)> Service::OnNewCheckResult;
 boost::signals2::signal<void (const Service::Ptr&, const Dictionary::Ptr&, StateType, const String&)> Service::OnStateChange;
 boost::signals2::signal<void (const Service::Ptr&, NotificationType, const Dictionary::Ptr&, const String&, const String&)> Service::OnNotificationsRequested;
@@ -51,51 +47,38 @@ boost::signals2::signal<void (const Service::Ptr&, FlappingState)> Service::OnFl
 
 CheckCommand::Ptr Service::GetCheckCommand(void) const
 {
-       return CheckCommand::GetByName(m_CheckCommand);
-}
-
-long Service::GetMaxCheckAttempts(void) const
-{
-       if (m_MaxCheckAttempts.IsEmpty())
-               return DefaultMaxCheckAttempts;
-
-       return m_MaxCheckAttempts;
+       return CheckCommand::GetByName(GetCheckCommandRaw());
 }
 
 TimePeriod::Ptr Service::GetCheckPeriod(void) const
 {
-       return TimePeriod::GetByName(m_CheckPeriod);
+       return TimePeriod::GetByName(GetCheckPeriodRaw());
 }
 
 double Service::GetCheckInterval(void) const
 {
-       if (!m_OverrideCheckInterval.IsEmpty())
-               return m_OverrideCheckInterval;
-       else if (!m_CheckInterval.IsEmpty())
-               return m_CheckInterval;
+       if (!GetOverrideCheckInterval().IsEmpty())
+               return GetOverrideCheckInterval();
        else
-               return DefaultCheckInterval;
+               return GetCheckIntervalRaw();
 }
 
 void Service::SetCheckInterval(double interval)
 {
-       m_OverrideCheckInterval = interval;
+       SetOverrideCheckInterval(interval);
 }
 
-
 double Service::GetRetryInterval(void) const
 {
-       if (!m_OverrideRetryInterval.IsEmpty())
-               return m_OverrideRetryInterval;
-       if (!m_RetryInterval.IsEmpty())
-               return m_RetryInterval;
+       if (!GetOverrideRetryInterval().IsEmpty())
+               return GetOverrideRetryInterval();
        else
-               return GetCheckInterval() / CheckIntervalDivisor;
+               return GetRetryIntervalRaw();
 }
 
 void Service::SetRetryInterval(double interval)
 {
-       m_OverrideRetryInterval = interval;
+       SetOverrideRetryInterval(interval);
 }
 
 void Service::SetSchedulingOffset(long offset)
@@ -110,14 +93,14 @@ long Service::GetSchedulingOffset(void)
 
 void Service::SetNextCheck(double nextCheck, const String& authority)
 {
-       m_NextCheck = nextCheck;
+       SetNextCheckRaw(nextCheck);
 
        Utility::QueueAsyncCallback(boost::bind(boost::ref(Service::OnNextCheckChanged), GetSelf(), nextCheck, authority));
 }
 
 double Service::GetNextCheck(void)
 {
-       return m_NextCheck;
+       return GetNextCheckRaw();
 }
 
 void Service::UpdateNextCheck(void)
@@ -140,187 +123,6 @@ void Service::UpdateNextCheck(void)
        SetNextCheck(now - adj + interval);
 }
 
-void Service::SetCurrentChecker(const String& checker)
-{
-       m_CurrentChecker = checker;
-}
-
-String Service::GetCurrentChecker(void) const
-{
-       return m_CurrentChecker;
-}
-
-void Service::SetCurrentCheckAttempt(long attempt)
-{
-       m_CheckAttempt = attempt;
-}
-
-long Service::GetCurrentCheckAttempt(void) const
-{
-       if (m_CheckAttempt.IsEmpty())
-               return 1;
-
-       return m_CheckAttempt;
-}
-
-void Service::SetState(ServiceState state)
-{
-       m_State = static_cast<long>(state);
-}
-
-ServiceState Service::GetState(void) const
-{
-       if (m_State.IsEmpty())
-               return StateUnknown;
-
-       int ivalue = static_cast<int>(m_State);
-       return static_cast<ServiceState>(ivalue);
-}
-
-void Service::SetLastState(ServiceState state)
-{
-       m_LastState = static_cast<long>(state);
-}
-
-ServiceState Service::GetLastState(void) const
-{
-       if (m_LastState.IsEmpty())
-               return StateUnknown;
-
-       int ivalue = static_cast<int>(m_LastState);
-       return static_cast<ServiceState>(ivalue);
-}
-
-void Service::SetLastHardState(ServiceState state)
-{
-       m_LastHardState = static_cast<long>(state);
-}
-
-ServiceState Service::GetLastHardState(void) const
-{
-       if (m_LastHardState.IsEmpty())
-               return StateUnknown;
-
-       int ivalue = static_cast<int>(m_LastHardState);
-       return static_cast<ServiceState>(ivalue);
-}
-
-void Service::SetStateType(StateType type)
-{
-       m_StateType = static_cast<long>(type);
-}
-
-StateType Service::GetStateType(void) const
-{
-       if (m_StateType.IsEmpty())
-               return StateTypeSoft;
-
-       int ivalue = static_cast<int>(m_StateType);
-       return static_cast<StateType>(ivalue);
-}
-
-void Service::SetLastStateType(StateType type)
-{
-       m_LastStateType = static_cast<long>(type);
-}
-
-StateType Service::GetLastStateType(void) const
-{
-       if (m_LastStateType.IsEmpty())
-               return StateTypeSoft;
-
-       int ivalue = static_cast<int>(m_LastStateType);
-       return static_cast<StateType>(ivalue);
-}
-
-void Service::SetLastStateOK(double ts)
-{
-       m_LastStateOK = ts;
-}
-
-double Service::GetLastStateOK(void) const
-{
-       if (m_LastStateOK.IsEmpty())
-               return 0;
-
-       return m_LastStateOK;
-}
-
-void Service::SetLastStateWarning(double ts)
-{
-       m_LastStateWarning = ts;
-}
-
-double Service::GetLastStateWarning(void) const
-{
-       if (m_LastStateWarning.IsEmpty())
-               return 0;
-
-       return m_LastStateWarning;
-}
-
-void Service::SetLastStateCritical(double ts)
-{
-       m_LastStateCritical = ts;
-}
-
-double Service::GetLastStateCritical(void) const
-{
-       if (m_LastStateCritical.IsEmpty())
-               return 0;
-
-       return m_LastStateCritical;
-}
-
-void Service::SetLastStateUnknown(double ts)
-{
-       m_LastStateUnknown = ts;
-}
-
-double Service::GetLastStateUnknown(void) const
-{
-       if (m_LastStateUnknown.IsEmpty())
-               return 0;
-
-       return m_LastStateUnknown;
-}
-
-void Service::SetLastStateUnreachable(double ts)
-{
-       m_LastStateUnreachable = ts;
-}
-
-double Service::GetLastStateUnreachable(void) const
-{
-       if (m_LastStateUnreachable.IsEmpty())
-               return 0;
-
-       return m_LastStateUnreachable;
-}
-
-void Service::SetLastReachable(bool reachable)
-{
-       m_LastReachable = reachable;
-}
-
-bool Service::GetLastReachable(void) const
-{
-       if (m_LastReachable.IsEmpty())
-               return true;
-
-       return m_LastReachable;
-}
-
-void Service::SetLastCheckResult(const Dictionary::Ptr& result)
-{
-       m_LastResult = result;
-}
-
-Dictionary::Ptr Service::GetLastCheckResult(void) const
-{
-       return m_LastResult;
-}
-
 bool Service::HasBeenChecked(void) const
 {
        return GetLastCheckResult();
@@ -331,9 +133,8 @@ double Service::GetLastCheck(void) const
        Dictionary::Ptr cr = GetLastCheckResult();
        double schedule_end = -1;
 
-       if (cr) {
+       if (cr)
                schedule_end = cr->Get("schedule_end");
-       }
 
        return schedule_end;
 }
@@ -384,77 +185,44 @@ String Service::GetLastCheckPerfData(void) const
        return perfdata;
 }
 
-void Service::SetLastStateChange(double ts)
-{
-       m_LastStateChange = ts;
-}
-
-double Service::GetLastStateChange(void) const
-{
-       if (m_LastStateChange.IsEmpty())
-               return IcingaApplication::GetInstance()->GetStartTime();
-
-       return m_LastStateChange;
-}
-
-void Service::SetLastHardStateChange(double ts)
-{
-       m_LastHardStateChange = ts;
-}
-
-double Service::GetLastHardStateChange(void) const
-{
-       if (m_LastHardStateChange.IsEmpty())
-               return IcingaApplication::GetInstance()->GetStartTime();
-
-       return m_LastHardStateChange;
-}
-
 bool Service::GetEnableActiveChecks(void) const
 {
-       if (!m_OverrideEnableActiveChecks.IsEmpty())
-               return m_OverrideEnableActiveChecks;
-       else if (!m_EnableActiveChecks.IsEmpty())
-               return m_EnableActiveChecks;
+       if (!GetOverrideEnableActiveChecks().IsEmpty())
+               return GetOverrideEnableActiveChecks();
        else
-               return true;
+               return GetEnableActiveChecksRaw();
 }
 
 void Service::SetEnableActiveChecks(bool enabled, const String& authority)
 {
-       m_OverrideEnableActiveChecks = enabled ? 1 : 0;
+       SetOverrideEnableActiveChecks(enabled);
 
        Utility::QueueAsyncCallback(boost::bind(boost::ref(OnEnableActiveChecksChanged), GetSelf(), enabled, authority));
 }
 
 bool Service::GetEnablePassiveChecks(void) const
 {
-       if (!m_OverrideEnablePassiveChecks.IsEmpty())
-               return m_OverrideEnablePassiveChecks;
-       if (!m_EnablePassiveChecks.IsEmpty())
-               return m_EnablePassiveChecks;
+       if (!GetOverrideEnablePassiveChecks().IsEmpty())
+               return GetOverrideEnablePassiveChecks();
        else
-               return true;
+               return GetEnablePassiveChecksRaw();
 }
 
 void Service::SetEnablePassiveChecks(bool enabled, const String& authority)
 {
-       m_OverrideEnablePassiveChecks = enabled ? 1 : 0;
+       SetOverrideEnablePassiveChecks(enabled);
 
        Utility::QueueAsyncCallback(boost::bind(boost::ref(OnEnablePassiveChecksChanged), GetSelf(), enabled, authority));
 }
 
 bool Service::GetForceNextCheck(void) const
 {
-       if (m_ForceNextCheck.IsEmpty())
-               return false;
-
-       return static_cast<bool>(m_ForceNextCheck);
+       return GetForceNextCheckRaw();
 }
 
 void Service::SetForceNextCheck(bool forced, const String& authority)
 {
-       m_ForceNextCheck = forced ? 1 : 0;
+       SetForceNextCheckRaw(forced);
 
        Utility::QueueAsyncCallback(boost::bind(boost::ref(OnForceNextCheckChanged), GetSelf(), forced, authority));
 }
@@ -494,7 +262,7 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr, const String& author
        Dictionary::Ptr old_cr = GetLastCheckResult();
        ServiceState old_state = GetState();
        StateType old_stateType = GetStateType();
-       long old_attempt = GetCurrentCheckAttempt();
+       long old_attempt = GetCheckAttempt();
        bool recovery;
 
        if (old_cr && cr->Get("execution_start") < old_cr->Get("execution_start"))
@@ -540,7 +308,7 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr, const String& author
        if (!reachable)
                SetLastStateUnreachable(Utility::GetTime());
 
-       SetCurrentCheckAttempt(attempt);
+       SetCheckAttempt(attempt);
 
        int state = cr->Get("state");
        SetState(static_cast<ServiceState>(state));
@@ -585,7 +353,7 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr, const String& author
        if (old_state != GetState() && old_stateType == StateTypeHard && GetStateType() == StateTypeHard)
                hardChange = true;
 
-       if (IsVolatile())
+       if (GetVolatile())
                hardChange = true;
 
        if (hardChange) {
@@ -604,8 +372,8 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr, const String& author
        if (old_state == StateOK && old_stateType == StateTypeSoft)
                send_notification = false; /* Don't send notifications for SOFT-OK -> HARD-OK. */
 
-       bool send_downtime_notification = m_LastInDowntime != in_downtime;
-       m_LastInDowntime = in_downtime;
+       bool send_downtime_notification = (GetLastInDowntime() != in_downtime);
+       SetLastInDowntime(in_downtime);
 
        olock.Unlock();
 
@@ -615,7 +383,7 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr, const String& author
        Dictionary::Ptr vars_after = boost::make_shared<Dictionary>();
        vars_after->Set("state", GetState());
        vars_after->Set("state_type", GetStateType());
-       vars_after->Set("attempt", GetCurrentCheckAttempt());
+       vars_after->Set("attempt", GetCheckAttempt());
        vars_after->Set("reachable", reachable);
        vars_after->Set("host_reachable", host_reachable);
 
index fd1e168e19531fe59a28fe17c41c5d4e495fd70a..758e0212d46eb813abd116ee25eeb6533fcb0faa 100644 (file)
@@ -45,11 +45,6 @@ int Service::GetNextCommentID(void)
        return l_NextCommentID;
 }
 
-Dictionary::Ptr Service::GetComments(void) const
-{
-       return m_Comments;
-}
-
 String Service::AddComment(CommentType entryType, const String& author,
     const String& text, double expireTime, const String& id, const String& authority)
 {
@@ -77,24 +72,7 @@ String Service::AddComment(CommentType entryType, const String& author,
 
        comment->Set("legacy_id", legacy_id);
 
-       Dictionary::Ptr comments;
-
-       {
-               ObjectLock olock(this);
-
-               comments = GetComments();
-
-               if (!comments)
-                       comments = boost::make_shared<Dictionary>();
-
-               m_Comments = comments;
-       }
-
-       {
-               ObjectLock olock(this);
-
-               comments->Set(uid, comment);
-       }
+       GetComments()->Set(uid, comment);
 
        {
                boost::mutex::scoped_lock lock(l_CommentMutex);
@@ -110,10 +88,7 @@ String Service::AddComment(CommentType entryType, const String& author,
 void Service::RemoveAllComments(void)
 {
        std::vector<String> ids;
-       Dictionary::Ptr comments = m_Comments;
-
-       if (!comments)
-               return;
+       Dictionary::Ptr comments = GetComments();
 
        ObjectLock olock(comments);
        String id;
@@ -135,9 +110,6 @@ void Service::RemoveComment(const String& id, const String& authority)
 
        Dictionary::Ptr comments = owner->GetComments();
 
-       if (!comments)
-               return;
-
        ObjectLock olock(owner);
 
        Dictionary::Ptr comment = comments->Get(id);
@@ -205,9 +177,6 @@ void Service::AddCommentsToCache(void)
 
        Dictionary::Ptr comments = GetComments();
 
-       if (!comments)
-               return;
-
        ObjectLock olock(comments);
 
        boost::mutex::scoped_lock lock(l_CommentMutex);
@@ -229,9 +198,6 @@ void Service::RemoveCommentsByType(int type)
 {
        Dictionary::Ptr comments = GetComments();
 
-       if (!comments)
-               return;
-
        std::vector<String> removedComments;
 
        {
@@ -254,9 +220,6 @@ void Service::RemoveExpiredComments(void)
 {
        Dictionary::Ptr comments = GetComments();
 
-       if (!comments)
-               return;
-
        std::vector<String> expiredComments;
 
        {
index a3fd394fd2136563b0b85f3977f0c3560c15c0e2..9eab76ec9f470ae8335f572048d8c7779443a1f1 100644 (file)
@@ -46,11 +46,6 @@ int Service::GetNextDowntimeID(void)
        return l_NextDowntimeID;
 }
 
-Dictionary::Ptr Service::GetDowntimes(void) const
-{
-       return m_Downtimes;
-}
-
 String Service::AddDowntime(const String& comment_id,
     double startTime, double endTime, bool fixed,
     const String& triggeredBy, double duration, const String& id, const String& authority)
@@ -85,7 +80,7 @@ String Service::AddDowntime(const String& comment_id,
 
        if (!triggeredBy.IsEmpty()) {
                Service::Ptr otherOwner = GetOwnerByDowntimeID(triggeredBy);
-               Dictionary::Ptr otherDowntimes = otherOwner->m_Downtimes;
+               Dictionary::Ptr otherDowntimes = otherOwner->GetDowntimes();
                Dictionary::Ptr otherDowntime = otherDowntimes->Get(triggeredBy);
                Dictionary::Ptr triggers = otherDowntime->Get("triggers");
 
@@ -95,20 +90,7 @@ String Service::AddDowntime(const String& comment_id,
                }
        }
 
-       Dictionary::Ptr downtimes;
-
-       {
-               ObjectLock olock(this);
-
-               downtimes = m_Downtimes;
-
-               if (!downtimes)
-                       downtimes = boost::make_shared<Dictionary>();
-
-               m_Downtimes = downtimes;
-       }
-
-       downtimes->Set(uid, downtime);
+       GetDowntimes()->Set(uid, downtime);
 
        {
                boost::mutex::scoped_lock lock(l_DowntimeMutex);
@@ -132,9 +114,6 @@ void Service::RemoveDowntime(const String& id, bool cancelled, const String& aut
 
        Dictionary::Ptr downtimes = owner->GetDowntimes();
 
-       if (!downtimes)
-               return;
-
        Dictionary::Ptr downtime = downtimes->Get(id);
 
        if (!downtime)
@@ -165,9 +144,6 @@ void Service::TriggerDowntimes(void)
 {
        Dictionary::Ptr downtimes = GetDowntimes();
 
-       if (!downtimes)
-               return;
-
        std::vector<String> ids;
 
        {
@@ -305,9 +281,6 @@ void Service::AddDowntimesToCache(void)
 
        Dictionary::Ptr downtimes = GetDowntimes();
 
-       if (!downtimes)
-               return;
-
        boost::mutex::scoped_lock lock(l_DowntimeMutex);
 
        ObjectLock olock(downtimes);
@@ -329,9 +302,6 @@ void Service::RemoveExpiredDowntimes(void)
 {
        Dictionary::Ptr downtimes = GetDowntimes();
 
-       if (!downtimes)
-               return;
-
        std::vector<String> expiredDowntimes;
 
        {
@@ -361,9 +331,6 @@ bool Service::IsInDowntime(void) const
 {
        Dictionary::Ptr downtimes = GetDowntimes();
 
-       if (!downtimes)
-               return false;
-
        ObjectLock olock(downtimes);
 
        Dictionary::Ptr downtime;
@@ -380,9 +347,6 @@ int Service::GetDowntimeDepth(void) const
        int downtime_depth = 0;
        Dictionary::Ptr downtimes = GetDowntimes();
 
-       if (!downtimes)
-               return 0;
-
        ObjectLock olock(downtimes);
 
        Dictionary::Ptr downtime;
index adacd53daf11696c77966af76c3365b5302da850..205a54e3833a20d36a376adfad49523b64948b4b 100644 (file)
@@ -27,22 +27,20 @@ boost::signals2::signal<void (const Service::Ptr&)> Service::OnEventCommandExecu
 
 bool Service::GetEnableEventHandler(void) const
 {
-       if (!m_OverrideEnableEventHandler.IsEmpty())
-               return m_EnableEventHandler;
-       else if (!m_EnableEventHandler.IsEmpty())
-               return m_EnableEventHandler;
+       if (!GetOverrideEnableEventHandler().IsEmpty())
+               return GetOverrideEnableEventHandler();
        else
-               return true;
+               return GetEnableEventHandlerRaw();
 }
 
 void Service::SetEnableEventHandler(bool enabled)
 {
-       m_OverrideEnableEventHandler = enabled;
+       SetOverrideEnableEventHandler(enabled);
 }
 
 EventCommand::Ptr Service::GetEventCommand(void) const
 {
-       return EventCommand::GetByName(m_EventCommand);
+       return EventCommand::GetByName(GetEventCommandRaw());
 }
 
 void Service::ExecuteEventHandler(void)
index aeeeb86ea424ceb75556fa2c920587f3b5210557..86a6d94e1564610ba5ed0aa62a5967a09ce2dd40 100644 (file)
@@ -35,32 +35,20 @@ using namespace icinga;
 
 double Service::GetFlappingCurrent(void) const
 {
-       if (m_FlappingPositive + m_FlappingNegative <= 0)
+       if (GetFlappingPositive() + GetFlappingNegative() <= 0)
                return 0;
 
-       return 100 * m_FlappingPositive / (m_FlappingPositive + m_FlappingNegative);
-}
-
-double Service::GetFlappingThreshold(void) const
-{
-       if (m_FlappingThreshold.IsEmpty())
-               return 30;
-       else
-               return m_FlappingThreshold;
+       return 100 * GetFlappingPositive() / (GetFlappingPositive() + GetFlappingNegative());
 }
 
 bool Service::GetEnableFlapping(void) const
 {
-       if (m_EnableFlapping.IsEmpty())
-               return true;
-       else
-               return m_EnableFlapping;
-
+       return GetEnableFlappingRaw();
 }
 
 void Service::SetEnableFlapping(bool enabled, const String& authority)
 {
-       m_EnableFlapping = enabled;
+       SetEnableFlappingRaw(enabled);
 
        OnFlappingChanged(GetSelf(), enabled ? FlappingEnabled : FlappingDisabled);
        Utility::QueueAsyncCallback(boost::bind(boost::ref(OnEnableFlappingChanged), GetSelf(), enabled, authority));
@@ -73,15 +61,9 @@ void Service::UpdateFlappingStatus(bool stateChange)
 
        now = Utility::GetTime();
 
-       if (m_FlappingLastChange.IsEmpty()) {
-               ts = now;
-               positive = 0;
-               negative = 0;
-       } else {
-               ts = m_FlappingLastChange;
-               positive = m_FlappingPositive;
-               negative = m_FlappingNegative;
-       }
+       ts = GetFlappingLastChange();
+       positive = GetFlappingPositive();
+       negative = GetFlappingNegative();
 
        double diff = now - ts;
 
@@ -104,9 +86,9 @@ void Service::UpdateFlappingStatus(bool stateChange)
 
 //     Log(LogDebug, "icinga", "Flapping counter for '" + GetName() + "' is positive=" + Convert::ToString(positive) + ", negative=" + Convert::ToString(negative));
 
-       m_FlappingPositive = positive;
-       m_FlappingNegative = negative;
-       m_FlappingLastChange = now;
+       SetFlappingLastChange(now);
+       SetFlappingPositive(positive);
+       SetFlappingNegative(negative);
 }
 
 bool Service::IsFlapping(void) const
index 36b5453a88d2f330841b992592d7e2adb4de6b72..b69101fb155ee55aecf1bfb418b57e74170570cb 100644 (file)
@@ -35,11 +35,6 @@ using namespace icinga;
 boost::signals2::signal<void (const Service::Ptr&, const std::set<User::Ptr>&, const NotificationType&, const Dictionary::Ptr&, const String&, const String&)> Service::OnNotificationSentToAllUsers;
 boost::signals2::signal<void (const Service::Ptr&, const User::Ptr&, const NotificationType&, const Dictionary::Ptr&, const String&, const String&)> Service::OnNotificationSentToUser;
 
-Dictionary::Ptr Service::GetNotificationDescriptions(void) const
-{
-       return m_NotificationDescriptions;
-}
-
 void Service::ResetNotificationNumbers(void)
 {
        BOOST_FOREACH(const Notification::Ptr& notification, GetNotifications()) {
@@ -170,30 +165,24 @@ void Service::UpdateSlaveNotifications(void)
 
 bool Service::GetEnableNotifications(void) const
 {
-       if (m_EnableNotifications.IsEmpty())
-               return true;
-       else
-               return m_EnableNotifications;
+       return GetEnableNotificationsRaw();
 }
 
 void Service::SetEnableNotifications(bool enabled, const String& authority)
 {
-       m_EnableNotifications = enabled;
+       SetEnableNotificationsRaw(enabled);
 
        Utility::QueueAsyncCallback(boost::bind(boost::ref(OnEnableNotificationsChanged), GetSelf(), enabled, authority));
 }
 
 bool Service::GetForceNextNotification(void) const
 {
-       if (m_ForceNextNotification.IsEmpty())
-               return false;
-
-       return static_cast<bool>(m_ForceNextNotification);
+       return GetForceNextNotificationRaw();
 }
 
 void Service::SetForceNextNotification(bool forced, const String& authority)
 {
-       m_ForceNextNotification = forced ? 1 : 0;
+       SetForceNextNotificationRaw(forced);
 
        Utility::QueueAsyncCallback(boost::bind(boost::ref(OnForceNextNotificationChanged), GetSelf(), forced, authority));
 }
index bd56df284768fdeea5586f5a3bd4658d4f6df943..8db89814afbf0788c18c1ed8a8008f363e78f07d 100644 (file)
@@ -79,14 +79,6 @@ void Service::OnConfigLoaded(void)
        UpdateSlaveNotifications();
 }
 
-String Service::GetDisplayName(void) const
-{
-       if (m_DisplayName.IsEmpty())
-               return GetShortName();
-       else
-               return m_DisplayName;
-}
-
 Service::Ptr Service::GetByNamePair(const String& hostName, const String& serviceName)
 {
        if (!hostName.IsEmpty()) {
@@ -103,40 +95,7 @@ Service::Ptr Service::GetByNamePair(const String& hostName, const String& servic
 
 Host::Ptr Service::GetHost(void) const
 {
-       return Host::GetByName(m_HostName);
-}
-
-Dictionary::Ptr Service::GetMacros(void) const
-{
-       return m_Macros;
-}
-
-Array::Ptr Service::GetHostDependencies(void) const
-{
-       return m_HostDependencies;
-}
-
-Array::Ptr Service::GetServiceDependencies(void) const
-{
-       return m_ServiceDependencies;
-}
-
-Array::Ptr Service::GetGroups(void) const
-{
-       return m_Groups;
-}
-
-String Service::GetHostName(void) const
-{
-       return m_HostName;
-}
-
-String Service::GetShortName(void) const
-{
-       if (m_ShortName.IsEmpty())
-               return GetName();
-       else
-               return m_ShortName;
+       return Host::GetByName(GetHostRaw());
 }
 
 bool Service::IsHostCheck(void) const
@@ -206,23 +165,11 @@ bool Service::IsReachable(void) const
        return true;
 }
 
-bool Service::IsVolatile(void) const
-{
-       if (m_Volatile.IsEmpty())
-               return false;
-
-       return m_Volatile;
-}
-
 AcknowledgementType Service::GetAcknowledgement(void)
 {
        ASSERT(OwnsLock());
 
-       if (m_Acknowledgement.IsEmpty())
-               return AcknowledgementNone;
-
-       int ivalue = static_cast<int>(m_Acknowledgement);
-       AcknowledgementType avalue = static_cast<AcknowledgementType>(ivalue);
+       AcknowledgementType avalue = static_cast<AcknowledgementType>(GetAcknowledgementRaw());
 
        if (avalue != AcknowledgementNone) {
                double expiry = GetAcknowledgementExpiry();
@@ -241,21 +188,13 @@ bool Service::IsAcknowledged(void)
        return GetAcknowledgement() != AcknowledgementNone;
 }
 
-double Service::GetAcknowledgementExpiry(void) const
-{
-       if (m_AcknowledgementExpiry.IsEmpty())
-               return 0;
-
-       return static_cast<double>(m_AcknowledgementExpiry);
-}
-
 void Service::AcknowledgeProblem(const String& author, const String& comment, AcknowledgementType type, double expiry, const String& authority)
 {
        {
                ObjectLock olock(this);
 
-               m_Acknowledgement = type;
-               m_AcknowledgementExpiry = expiry;
+               SetAcknowledgementRaw(type);
+               SetAcknowledgementExpiry(expiry);
        }
 
        OnNotificationsRequested(GetSelf(), NotificationAcknowledgement, GetLastCheckResult(), author, comment);
@@ -268,8 +207,8 @@ void Service::ClearAcknowledgement(const String& authority)
 {
        ASSERT(OwnsLock());
 
-       m_Acknowledgement = AcknowledgementNone;
-       m_AcknowledgementExpiry = 0;
+       SetAcknowledgementRaw(AcknowledgementNone);
+       SetAcknowledgementExpiry(0);
 
        Utility::QueueAsyncCallback(boost::bind(boost::ref(OnAcknowledgementCleared), GetSelf(), authority));
 }
@@ -328,31 +267,23 @@ std::set<Service::Ptr> Service::GetParentServices(void) const
        return parents;
 }
 
-bool Service::GetEnablePerfdata(void) const
-{
-       if (!m_EnablePerfdata.IsEmpty())
-               return m_EnablePerfdata;
-       else
-               return true;
-}
-
 int Service::GetModifiedAttributes(void) const
 {
        int attrs = 0;
 
-       if (!m_OverrideEnableActiveChecks.IsEmpty())
+       if (!GetOverrideEnableActiveChecks().IsEmpty())
                attrs |= ModAttrActiveChecksEnabled;
 
-       if (!m_OverrideEnablePassiveChecks.IsEmpty())
+       if (!GetOverrideEnablePassiveChecks().IsEmpty())
                attrs |= ModAttrPassiveChecksEnabled;
 
-       if (!m_OverrideEnableEventHandler.IsEmpty())
+       if (!GetOverrideEnableEventHandler().IsEmpty())
                attrs |= ModAttrEventHandlerEnabled;
 
-       if (!m_OverrideCheckInterval.IsEmpty())
+       if (!GetOverrideCheckInterval().IsEmpty())
                attrs |= ModAttrNormalCheckInterval;
 
-       if (!m_OverrideRetryInterval.IsEmpty())
+       if (!GetOverrideRetryInterval().IsEmpty())
                attrs |= ModAttrRetryCheckInterval;
 
        // TODO: finish
@@ -363,19 +294,19 @@ int Service::GetModifiedAttributes(void) const
 void Service::SetModifiedAttributes(int flags)
 {
        if ((flags & ModAttrActiveChecksEnabled) == 0)
-               m_OverrideEnableActiveChecks = Empty;
+               SetOverrideEnableActiveChecks(Empty);
 
        if ((flags & ModAttrPassiveChecksEnabled) == 0)
-               m_OverrideEnablePassiveChecks = Empty;
+               SetOverrideEnablePassiveChecks(Empty);
 
        if ((flags & ModAttrEventHandlerEnabled) == 0)
-               m_OverrideEnableEventHandler = Empty;
+               SetOverrideEnableEventHandler(Empty);
 
        if ((flags & ModAttrNormalCheckInterval) == 0)
-               m_OverrideCheckInterval = Empty;
+               SetOverrideCheckInterval(Empty);
 
        if ((flags & ModAttrRetryCheckInterval) == 0)
-               m_OverrideRetryInterval = Empty;
+               SetOverrideRetryInterval(Empty);
 }
 
 bool Service::ResolveMacro(const String& macro, const Dictionary::Ptr& cr, String *result) const
@@ -407,7 +338,7 @@ bool Service::ResolveMacro(const String& macro, const Dictionary::Ptr& cr, Strin
                *result = StateTypeToString(GetStateType());
                return true;
        } else if (macro == "SERVICEATTEMPT") {
-               *result = Convert::ToString(GetCurrentCheckAttempt());
+               *result = Convert::ToString(GetCheckAttempt());
                return true;
        } else if (macro == "MAXSERVICEATTEMPT") {
                *result = Convert::ToString(GetMaxCheckAttempts());
@@ -480,135 +411,3 @@ bool Service::ResolveMacro(const String& macro, const Dictionary::Ptr& cr, Strin
 
        return false;
 }
-
-void Service::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
-{
-       DynamicObject::InternalSerialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               bag->Set("display_name", m_DisplayName);
-               bag->Set("macros", m_Macros);
-               bag->Set("host_dependencies", m_HostDependencies);
-               bag->Set("service_dependencies", m_ServiceDependencies);
-               bag->Set("groups", m_Groups);
-               bag->Set("check_command", m_CheckCommand);
-               bag->Set("max_check_attempts", m_MaxCheckAttempts);
-               bag->Set("check_period", m_CheckPeriod);
-               bag->Set("check_interval", m_CheckInterval);
-               bag->Set("retry_interval", m_RetryInterval);
-               bag->Set("event_command", m_EventCommand);
-               bag->Set("volatile", m_Volatile);
-               bag->Set("short_name", m_ShortName);
-               bag->Set("host", m_HostName);
-               bag->Set("flapping_threshold", m_FlappingThreshold);
-               bag->Set("notifications", m_NotificationDescriptions);
-               bag->Set("enable_active_checks", m_EnableActiveChecks);
-               bag->Set("enable_passive_checks", m_EnablePassiveChecks);
-               bag->Set("enable_event_handler", m_EnableEventHandler);
-       }
-
-       if (attributeTypes & Attribute_State) {
-               bag->Set("next_check", m_NextCheck);
-               bag->Set("current_checker", m_CurrentChecker);
-               bag->Set("check_attempt", m_CheckAttempt);
-               bag->Set("state", m_State);
-               bag->Set("state_type", m_StateType);
-               bag->Set("last_state", m_LastState);
-               bag->Set("last_hard_state", m_LastHardState);
-               bag->Set("last_state_type", m_LastStateType);
-               bag->Set("last_reachable", m_LastReachable);
-               bag->Set("last_result", m_LastResult);
-               bag->Set("last_state_change", m_LastStateChange);
-               bag->Set("last_hard_state_change", m_LastHardStateChange);
-               bag->Set("last_state_ok", m_LastStateOK);
-               bag->Set("last_state_warning", m_LastStateWarning);
-               bag->Set("last_state_critical", m_LastStateCritical);
-               bag->Set("last_state_unknown", m_LastStateUnknown);
-               bag->Set("last_state_unreachable", m_LastStateUnreachable);
-               bag->Set("last_in_downtime", m_LastInDowntime);
-               bag->Set("enable_active_checks", m_EnableActiveChecks);
-               bag->Set("enable_passive_checks", m_EnablePassiveChecks);
-               bag->Set("force_next_check", m_ForceNextCheck);
-               bag->Set("acknowledgement", m_Acknowledgement);
-               bag->Set("acknowledgement_expiry", m_AcknowledgementExpiry);
-               bag->Set("comments", m_Comments);
-               bag->Set("downtimes", m_Downtimes);
-               bag->Set("enable_notifications", m_EnableNotifications);
-               bag->Set("force_next_notification", m_ForceNextNotification);
-               bag->Set("flapping_positive", m_FlappingPositive);
-               bag->Set("flapping_negative", m_FlappingNegative);
-               bag->Set("flapping_lastchange", m_FlappingLastChange);
-               bag->Set("enable_flapping", m_EnableFlapping);
-               bag->Set("enable_perfdata", m_EnablePerfdata);
-               bag->Set("override_enable_active_checks", m_OverrideEnableActiveChecks);
-               bag->Set("override_enable_passive_checks", m_OverrideEnablePassiveChecks);
-               bag->Set("override_check_interval", m_OverrideCheckInterval);
-               bag->Set("override_retry_interval", m_OverrideRetryInterval);
-               bag->Set("override_enable_event_handler", m_OverrideEnableEventHandler);
-       }
-}
-
-void Service::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
-{
-       DynamicObject::InternalDeserialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               m_DisplayName = bag->Get("display_name");
-               m_Macros = bag->Get("macros");
-               m_HostDependencies = bag->Get("host_dependencies");
-               m_ServiceDependencies = bag->Get("service_dependencies");
-               m_Groups = bag->Get("groups");
-               m_CheckCommand = bag->Get("check_command");
-               m_MaxCheckAttempts = bag->Get("max_check_attempts");
-               m_CheckPeriod = bag->Get("check_period");
-               m_CheckInterval = bag->Get("check_interval");
-               m_RetryInterval = bag->Get("retry_interval");
-               m_EventCommand = bag->Get("event_command");
-               m_Volatile = bag->Get("volatile");
-               m_ShortName = bag->Get("short_name");
-               m_HostName = bag->Get("host");
-               m_FlappingThreshold = bag->Get("flapping_threshold");
-               m_NotificationDescriptions = bag->Get("notifications");
-               m_EnableActiveChecks = bag->Get("enable_active_checks");
-               m_EnablePassiveChecks = bag->Get("enable_passive_checks");
-               m_EnableEventHandler = bag->Get("enable_event_handler");
-       }
-
-       if (attributeTypes & Attribute_State) {
-               m_NextCheck = bag->Get("next_check");
-               m_CurrentChecker = bag->Get("current_checker");
-               m_CheckAttempt = bag->Get("check_attempt");
-               m_State = bag->Get("state");
-               m_StateType = bag->Get("state_type");
-               m_LastState = bag->Get("last_state");
-               m_LastHardState = bag->Get("last_hard_state");
-               m_LastStateType = bag->Get("last_state_type");
-               m_LastReachable = bag->Get("last_reachable");
-               m_LastResult = bag->Get("last_result");
-               m_LastStateChange = bag->Get("last_state_change");
-               m_LastHardStateChange = bag->Get("last_hard_state_change");
-               m_LastStateOK = bag->Get("last_state_ok");
-               m_LastStateWarning = bag->Get("last_state_warning");
-               m_LastStateCritical = bag->Get("last_state_critical");
-               m_LastStateUnknown = bag->Get("last_state_unknown");
-               m_LastStateUnreachable = bag->Get("last_state_unreachable");
-               m_LastInDowntime = bag->Get("last_in_downtime");
-               m_ForceNextCheck = bag->Get("force_next_check");
-               m_Acknowledgement = bag->Get("acknowledgement");
-               m_AcknowledgementExpiry = bag->Get("acknowledgement_expiry");
-               m_Comments = bag->Get("comments");
-               m_Downtimes = bag->Get("downtimes");
-               m_EnableNotifications = bag->Get("enable_notifications");
-               m_ForceNextNotification = bag->Get("force_next_notification");
-               m_FlappingPositive = bag->Get("flapping_positive");
-               m_FlappingNegative = bag->Get("flapping_negative");
-               m_FlappingLastChange = bag->Get("flapping_lastchange");
-               m_EnableFlapping = bag->Get("enable_flapping");
-               m_EnablePerfdata = bag->Get("enable_perfdata");
-               m_OverrideEnableActiveChecks = bag->Get("override_enable_active_checks");
-               m_OverrideEnablePassiveChecks = bag->Get("override_enable_passive_checks");
-               m_OverrideCheckInterval = bag->Get("override_check_interval");
-               m_OverrideRetryInterval = bag->Get("override_retry_interval");
-               m_OverrideEnableEventHandler = bag->Get("override_enable_event_handler");
-       }
-}
index 8ed08d903d17ab87587a5cb9e3b8d36f33bf89fd..a2ce379970c7f1e306be6a47baecac5890946588 100644 (file)
 #define SERVICE_H
 
 #include "icinga/i2-icinga.h"
+#include "icinga/service.th"
 #include "icinga/macroresolver.h"
 #include "icinga/host.h"
 #include "icinga/timeperiod.h"
 #include "icinga/notification.h"
 #include "base/i2-base.h"
-#include "base/dynamicobject.h"
 #include "base/array.h"
 #include <boost/signals2.hpp>
 #include <boost/thread/once.hpp>
 namespace icinga
 {
 
-/**
- * The acknowledgement type of a service.
- *
- * @ingroup icinga
- */
-enum AcknowledgementType
-{
-       AcknowledgementNone = 0,
-       AcknowledgementNormal = 1,
-       AcknowledgementSticky = 2
-};
-
 /**
  * The type of a service comment.
  *
@@ -130,7 +118,7 @@ class EventCommand;
  *
  * @ingroup icinga
  */
-class I2_ICINGA_API Service : public DynamicObject, public MacroResolver
+class I2_ICINGA_API Service : public ReflectionObjectImpl<Service>, public MacroResolver
 {
 public:
        DECLARE_PTR_TYPEDEFS(Service);
@@ -140,37 +128,22 @@ public:
 
        static Service::Ptr GetByNamePair(const String& hostName, const String& serviceName);
 
-       static const int DefaultMaxCheckAttempts;
-       static const double DefaultCheckInterval;
-       static const double CheckIntervalDivisor;
-
-       String GetDisplayName(void) const;
        Host::Ptr GetHost(void) const;
-       Dictionary::Ptr GetMacros(void) const;
-       Array::Ptr GetHostDependencies(void) const;
-       Array::Ptr GetServiceDependencies(void) const;
-       Array::Ptr GetGroups(void) const;
-       String GetHostName(void) const;
-       String GetShortName(void) const;
 
        std::set<Host::Ptr> GetParentHosts(void) const;
        std::set<Service::Ptr> GetParentServices(void) const;
 
        bool IsHostCheck(void) const;
 
-       bool IsVolatile(void) const;
-
        bool IsReachable(void) const;
 
        AcknowledgementType GetAcknowledgement(void);
-       double GetAcknowledgementExpiry(void) const;
 
        void AcknowledgeProblem(const String& author, const String& comment, AcknowledgementType type, double expiry = 0, const String& authority = String());
        void ClearAcknowledgement(const String& authority = String());
 
        /* Checks */
        shared_ptr<CheckCommand> GetCheckCommand(void) const;
-       long GetMaxCheckAttempts(void) const;
        TimePeriod::Ptr GetCheckPeriod(void) const;
 
        double GetCheckInterval(void) const;
@@ -186,29 +159,6 @@ public:
        double GetNextCheck(void);
        void UpdateNextCheck(void);
 
-       void SetCurrentChecker(const String& checker);
-       String GetCurrentChecker(void) const;
-
-       void SetCurrentCheckAttempt(long attempt);
-       long GetCurrentCheckAttempt(void) const;
-
-       void SetState(ServiceState state);
-       ServiceState GetState(void) const;
-
-       void SetStateType(StateType type);
-       StateType GetStateType(void) const;
-
-       void SetLastState(ServiceState state);
-       ServiceState GetLastState(void) const;
-
-       void SetLastHardState(ServiceState state);
-       ServiceState GetLastHardState(void) const;
-
-       void SetLastStateType(StateType type);
-       StateType GetLastStateType(void) const;
-
-       void SetLastCheckResult(const Dictionary::Ptr& result);
-       Dictionary::Ptr GetLastCheckResult(void) const;
        bool HasBeenChecked(void) const;
 
        double GetLastCheck(void) const;
@@ -217,34 +167,12 @@ public:
        String GetLastCheckLongOutput(void) const;
        String GetLastCheckPerfData(void) const;
 
-       void SetLastStateChange(double ts);
-       double GetLastStateChange(void) const;
-
-       void SetLastHardStateChange(double ts);
-       double GetLastHardStateChange(void) const;
-
-       void SetLastStateOK(double ts);
-       double GetLastStateOK(void) const;
-       void SetLastStateWarning(double ts);
-       double GetLastStateWarning(void) const;
-       void SetLastStateCritical(double ts);
-       double GetLastStateCritical(void) const;
-       void SetLastStateUnknown(double ts);
-       double GetLastStateUnknown(void) const;
-       void SetLastStateUnreachable(double ts);
-       double GetLastStateUnreachable(void) const;
-
-       void SetLastReachable(bool reachable);
-       bool GetLastReachable(void) const;
-
        bool GetEnableActiveChecks(void) const;
        void SetEnableActiveChecks(bool enabled, const String& authority = String());
 
        bool GetEnablePassiveChecks(void) const;
        void SetEnablePassiveChecks(bool enabled, const String& authority = String());
 
-       bool GetEnablePerfdata(void) const;
-
        bool GetForceNextCheck(void) const;
        void SetForceNextCheck(bool forced, const String& authority = String());
 
@@ -292,7 +220,6 @@ public:
        /* Downtimes */
        static int GetNextDowntimeID(void);
 
-       Dictionary::Ptr GetDowntimes(void) const;
        int GetDowntimeDepth(void) const;
 
        String AddDowntime(const String& comment_id,
@@ -321,8 +248,6 @@ public:
        /* Comments */
        static int GetNextCommentID(void);
 
-       Dictionary::Ptr GetComments(void) const;
-
        String AddComment(CommentType entryType, const String& author,
            const String& text, double expireTime, const String& id = String(), const String& authority = String());
 
@@ -337,8 +262,6 @@ public:
        static bool IsCommentExpired(const Dictionary::Ptr& comment);
 
        /* Notifications */
-       Dictionary::Ptr GetNotificationDescriptions(void) const;
-
        bool GetEnableNotifications(void) const;
        void SetEnableNotifications(bool enabled, const String& authority = String());
 
@@ -363,12 +286,11 @@ public:
        void SetEnableEventHandler(bool enabled);
 
        /* Flapping Detection */
+       double GetFlappingCurrent(void) const;
+
        bool GetEnableFlapping(void) const;
        void SetEnableFlapping(bool enabled, const String& authority = String());
 
-       double GetFlappingCurrent(void) const;
-       double GetFlappingThreshold(void) const;
-
        bool IsFlapping(void) const;
        void UpdateFlappingStatus(bool stateChange);
 
@@ -377,94 +299,22 @@ protected:
 
        virtual void OnConfigLoaded(void);
 
-       virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
-       virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
-
 private:
-       String m_DisplayName;
-       Dictionary::Ptr m_Macros;
-       Array::Ptr m_HostDependencies;
-       Array::Ptr m_ServiceDependencies;
-       Array::Ptr m_Groups;
-       String m_ShortName;
-       Value m_Acknowledgement;
-       Value m_AcknowledgementExpiry;
-       String m_HostName;
-       Value m_Volatile;
-       Value m_EnablePerfdata;
-
-       /* Checks */
-       String m_CheckCommand;
-       Value m_MaxCheckAttempts;
-       String m_CheckPeriod;
-       Value m_CheckInterval;
-       Value m_OverrideCheckInterval;
-       Value m_RetryInterval;
-       Value m_OverrideRetryInterval;
-       double m_NextCheck;
-       String m_CurrentChecker;
-       Value m_CheckAttempt;
-       Value m_State;
-       Value m_StateType;
-       Value m_LastState;
-       Value m_LastHardState;
-       Value m_LastStateType;
-       Value m_LastReachable;
-       Dictionary::Ptr m_LastResult;
-       Value m_LastStateChange;
-       Value m_LastHardStateChange;
-       Value m_LastStateOK;
-       Value m_LastStateWarning;
-       Value m_LastStateCritical;
-       Value m_LastStateUnknown;
-       Value m_LastStateUnreachable;
-       bool m_LastInDowntime;
-       Value m_EnableActiveChecks;
-       Value m_OverrideEnableActiveChecks;
-       Value m_EnablePassiveChecks;
-       Value m_OverrideEnablePassiveChecks;
-       Value m_ForceNextCheck;
-
        bool m_CheckRunning;
        long m_SchedulingOffset;
 
        /* Downtimes */
-       Dictionary::Ptr m_Downtimes;
-
        static void DowntimesExpireTimerHandler(void);
-
        void RemoveExpiredDowntimes(void);
-
        void AddDowntimesToCache(void);
 
        /* Comments */
-       Dictionary::Ptr m_Comments;
-
        static void CommentsExpireTimerHandler(void);
-
        void RemoveExpiredComments(void);
-
        void AddCommentsToCache(void);
 
        /* Notifications */
-       Dictionary::Ptr m_NotificationDescriptions;
-
-       Value m_EnableNotifications;
-       Value m_ForceNextNotification;
-
        std::set<Notification::Ptr> m_Notifications;
-
-       /* Event Handler */
-       Value m_EnableEventHandler;
-       Value m_OverrideEnableEventHandler;
-       String m_EventCommand;
-
-       /* Flapping */
-       Value m_EnableFlapping;
-       long m_FlappingPositive;
-       long m_FlappingNegative;
-       Value m_FlappingLastChange;
-       Value m_FlappingThreshold;
 };
 
 }
diff --git a/lib/icinga/service.ti b/lib/icinga/service.ti
new file mode 100644 (file)
index 0000000..4b2e631
--- /dev/null
@@ -0,0 +1,134 @@
+#include "icinga/host.h"
+#include "icinga/icingaapplication.h"
+#include "base/dynamicobject.h"
+#include <boost/smart_ptr/make_shared.hpp>
+
+namespace icinga
+{
+
+code {{{
+/**
+ * The acknowledgement type of a service.
+ *
+ * @ingroup icinga
+ */
+enum AcknowledgementType
+{
+       AcknowledgementNone = 0,
+       AcknowledgementNormal = 1,
+       AcknowledgementSticky = 2
+};
+}}}
+
+class Service : DynamicObject
+{
+       [config] String display_name {
+               get {{{
+                       if (m_DisplayName.IsEmpty())
+                               return GetShortName();
+                       else
+                               return m_DisplayName;
+               }}}
+       };
+       [config] Dictionary::Ptr macros;
+       [config] Array::Ptr host_dependencies;
+       [config] Array::Ptr service_dependencies;
+       [config] Array::Ptr groups;
+       [config, protected] String check_command (CheckCommandRaw);
+       [config] int max_check_attempts {
+               default {{{ return 3; }}}
+       };
+       [config, protected] String check_period (CheckPeriodRaw);
+       [config] double check_interval (CheckIntervalRaw) {
+               default {{{ return 5 * 60; }}}
+       };
+       [config] double retry_interval (RetryIntervalRaw) {
+               default {{{ return 60; }}}
+       };
+       [config] String event_command (EventCommandRaw);
+       [config] bool volatile;
+       [config] String short_name {
+               default {{{ return GetName(); }}}
+       };
+       [config] String host (HostRaw);
+       [config] double flapping_threshold {
+               default {{{ return 30; }}}
+       };
+       [config] Dictionary::Ptr notifications (NotificationDescriptions);
+       [config] bool enable_active_checks (EnableActiveChecksRaw) {
+               default {{{ return true; }}}
+       };
+       [config] bool enable_passive_checks (EnablePassiveChecksRaw) {
+               default {{{ return true; }}}
+       };
+       [config] bool enable_event_handler (EnableEventHandlerRaw) {
+               default {{{ return true; }}}
+       };
+
+       [state] double next_check (NextCheckRaw);
+       [state] int check_attempt {
+               default {{{ return 1; }}}
+       };
+       [state, enum] ServiceState "state" {
+               default {{{ return StateUnknown; }}}
+       };
+       [state, enum] StateType state_type {
+               default {{{ return StateTypeSoft; }}}
+       };
+       [state, enum] ServiceState last_state {
+               default {{{ return StateUnknown; }}}
+       };
+       [state, enum] ServiceState last_hard_state {
+               default {{{ return StateUnknown; }}}
+       };
+       [state, enum] StateType last_state_type {
+               default {{{ return StateTypeSoft; }}}
+       };
+       [state] bool last_reachable {
+               default {{{ return true; }}}
+       };
+       [state] Dictionary::Ptr last_check_result;
+       [state] double last_state_change {
+               default {{{ return Application::GetStartTime(); }}}
+       };
+       [state] double last_hard_state_change {
+               default {{{ return Application::GetStartTime(); }}}
+       };
+       [state] double last_state_ok (LastStateOK);
+       [state] double last_state_warning;
+       [state] double last_state_critical;
+       [state] double last_state_unknown;
+       [state] double last_state_unreachable;
+       [state] bool last_in_downtime;
+       [state] bool force_next_check (ForceNextCheckRaw);
+       [state] int acknowledgement (AcknowledgementRaw) {
+               default {{{ return AcknowledgementNone; }}}
+       };
+       [state] double acknowledgement_expiry;
+       [state] Dictionary::Ptr comments {
+               default {{{ return boost::make_shared<Dictionary>(); }}}
+       };
+       [state] Dictionary::Ptr downtimes {
+               default {{{ return boost::make_shared<Dictionary>(); }}}
+       };
+       [state] bool enable_notifications (EnableNotificationsRaw) {
+               default {{{ return true; }}}
+       };
+       [state] bool force_next_notification (ForceNextNotificationRaw);
+       [state] int flapping_positive;
+       [state] int flapping_negative;
+       [state] double flapping_last_change;
+       [state] bool enable_flapping (EnableFlappingRaw) {
+               default {{{ return true; }}}
+       };
+       [state] bool enable_perfdata {
+               default {{{ return true; }}}
+       };
+       [state] Value override_enable_active_checks;
+       [state] Value override_enable_passive_checks;
+       [state] Value override_check_interval;
+       [state] Value override_retry_interval;
+       [state] Value override_enable_event_handler;
+};
+
+}
index 90dcfb22389b559c9616d858f4f9b7dd28adb753..3b8cf4c83fada5750241449b12e9abbdbefbb0b1 100644 (file)
@@ -31,14 +31,6 @@ using namespace icinga;
 
 REGISTER_TYPE(ServiceGroup);
 
-String ServiceGroup::GetDisplayName(void) const
-{
-       if (!m_DisplayName.IsEmpty())
-               return m_DisplayName;
-       else
-               return GetName();
-}
-
 std::set<Service::Ptr> ServiceGroup::GetMembers(void) const
 {
        return m_Members;
@@ -53,19 +45,3 @@ void ServiceGroup::RemoveMember(const Service::Ptr& service)
 {
        m_Members.erase(service);
 }
-
-void ServiceGroup::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
-{
-       DynamicObject::InternalSerialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config)
-               bag->Set("display_name", m_DisplayName);
-}
-
-void ServiceGroup::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
-{
-       DynamicObject::InternalDeserialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config)
-               m_DisplayName = bag->Get("display_name");
-}
index a5954783f4b2cc101c66da523633edf5d569bfde..e36b1a3316b618b0c741c245b3dad0ea3bf11ac3 100644 (file)
@@ -21,8 +21,8 @@
 #define SERVICEGROUP_H
 
 #include "icinga/i2-icinga.h"
+#include "icinga/servicegroup.th"
 #include "icinga/service.h"
-#include "base/dynamictype.h"
 
 namespace icinga
 {
@@ -32,24 +32,17 @@ namespace icinga
  *
  * @ingroup icinga
  */
-class I2_ICINGA_API ServiceGroup : public DynamicObject
+class I2_ICINGA_API ServiceGroup : public ReflectionObjectImpl<ServiceGroup>
 {
 public:
        DECLARE_PTR_TYPEDEFS(ServiceGroup);
        DECLARE_TYPENAME(ServiceGroup);
 
-       String GetDisplayName(void) const;
-
        std::set<Service::Ptr> GetMembers(void) const;
        void AddMember(const Service::Ptr& service);
        void RemoveMember(const Service::Ptr& service);
 
-protected:
-       virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
-       virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
-
 private:
-       String m_DisplayName;
        std::set<Service::Ptr> m_Members;
 };
 
diff --git a/lib/icinga/servicegroup.ti b/lib/icinga/servicegroup.ti
new file mode 100644 (file)
index 0000000..613b14c
--- /dev/null
@@ -0,0 +1,13 @@
+#include "base/dynamicobject.h"
+
+namespace icinga
+{
+
+class ServiceGroup : DynamicObject
+{
+       [config] String display_name {
+               default {{{ return GetName(); }}}
+       };
+};
+
+}
\ No newline at end of file
index 878211c674a34d3b23235d3d80e23af56148a86e..f362ff13b392628fcae7d1b00b16f097e41f7271 100644 (file)
@@ -53,32 +53,19 @@ void TimePeriod::Start(void)
        Dump();
 }
 
-String TimePeriod::GetDisplayName(void) const
-{
-        if (!m_DisplayName.IsEmpty())
-                return m_DisplayName;
-        else
-                return GetName();
-}
-
-Dictionary::Ptr TimePeriod::GetRanges(void) const
-{
-       return m_Ranges;
-}
-
 void TimePeriod::AddSegment(double begin, double end)
 {
        ASSERT(OwnsLock());
 
        Log(LogDebug, "icinga", "Adding segment '" + Utility::FormatDateTime("%c", begin) + "' <-> '" + Utility::FormatDateTime("%c", end) + "' to TimePeriod '" + GetName() + "'");
 
-       if (m_ValidBegin.IsEmpty() || begin < m_ValidBegin)
-               m_ValidBegin = begin;
+       if (GetValidBegin().IsEmpty() || begin < GetValidBegin())
+               SetValidBegin(begin);
 
-       if (m_ValidEnd.IsEmpty() || end > m_ValidEnd)
-               m_ValidEnd = end;
+       if (GetValidEnd().IsEmpty() || end > GetValidEnd())
+               SetValidEnd(end);
 
-       Array::Ptr segments = m_Segments;
+       Array::Ptr segments = GetSegments();
 
        if (segments) {
                /* Try to merge the new segment into an existing segment. */
@@ -106,7 +93,7 @@ void TimePeriod::AddSegment(double begin, double end)
 
        if (!segments) {
                segments = boost::make_shared<Array>();
-               m_Segments = segments;
+               SetSegments(segments);
        }
 
        segments->Add(segment);
@@ -123,13 +110,13 @@ void TimePeriod::RemoveSegment(double begin, double end)
 
        Log(LogDebug, "icinga", "Removing segment '" + Utility::FormatDateTime("%c", begin) + "' <-> '" + Utility::FormatDateTime("%c", end) + "' from TimePeriod '" + GetName() + "'");
 
-       if (m_ValidBegin.IsEmpty() || begin < m_ValidBegin)
-               m_ValidBegin = begin;
+       if (GetValidBegin().IsEmpty() || begin < GetValidBegin())
+               SetValidBegin(begin);
 
-       if (m_ValidEnd.IsEmpty() || end > m_ValidEnd)
-               m_ValidEnd = end;
+       if (GetValidEnd().IsEmpty() || end > GetValidEnd())
+               SetValidEnd(end);
 
-       Array::Ptr segments = m_Segments;
+       Array::Ptr segments = GetSegments();
 
        if (!segments)
                return;
@@ -160,7 +147,7 @@ void TimePeriod::RemoveSegment(double begin, double end)
                newSegments->Add(segment);
        }
 
-       m_Segments = newSegments;
+       SetSegments(newSegments);
 
        Dump();
 }
@@ -171,12 +158,12 @@ void TimePeriod::PurgeSegments(double end)
 
        Log(LogDebug, "icinga", "Purging segments older than '" + Utility::FormatDateTime("%c", end) + "' from TimePeriod '" + GetName() + "'");
 
-       if (m_ValidBegin.IsEmpty() || end < m_ValidBegin)
+       if (GetValidBegin().IsEmpty() || end < GetValidBegin())
                return;
 
-       m_ValidBegin = end;
+       SetValidBegin(end);
 
-       Array::Ptr segments = m_Segments;
+       Array::Ptr segments = GetSegments();
 
        if (!segments)
                return;
@@ -190,16 +177,16 @@ void TimePeriod::PurgeSegments(double end)
                        newSegments->Add(segment);
        }
 
-       m_Segments = newSegments;
+       SetSegments(newSegments);
 }
 
 void TimePeriod::UpdateRegion(double begin, double end, bool clearExisting)
 {
        if (!clearExisting) {
-               if (begin < m_ValidEnd)
-                       begin = m_ValidEnd;
+               if (begin < GetValidEnd())
+                       begin = GetValidEnd();
 
-               if (end < m_ValidEnd)
+               if (end < GetValidEnd())
                        return;
        }
 
@@ -229,10 +216,10 @@ bool TimePeriod::IsInside(double ts) const
 {
        ObjectLock olock(this);
 
-       if (m_ValidBegin.IsEmpty() || ts < m_ValidBegin || m_ValidEnd.IsEmpty() || ts > m_ValidEnd)
+       if (GetValidBegin().IsEmpty() || ts < GetValidBegin() || GetValidEnd().IsEmpty() || ts > GetValidEnd())
                return true; /* Assume that all invalid regions are "inside". */
 
-       Array::Ptr segments = m_Segments;
+       Array::Ptr segments = GetSegments();
 
        if (segments) {
                ObjectLock dlock(segments);
@@ -249,7 +236,7 @@ double TimePeriod::FindNextTransition(double begin)
 {
        ObjectLock olock(this);
 
-       Array::Ptr segments = m_Segments;
+       Array::Ptr segments = GetSegments();
 
        double closestTransition = -1;
 
@@ -278,7 +265,7 @@ void TimePeriod::UpdateTimerHandler(void)
                        ObjectLock olock(tp);
                        tp->PurgeSegments(now - 3600);
 
-                       valid_end = tp->m_ValidEnd;
+                       valid_end = tp->GetValidEnd();
                }
 
                tp->UpdateRegion(valid_end, now + 24 * 3600, false);
@@ -311,10 +298,10 @@ Array::Ptr TimePeriod::EvenMinutesTimePeriodUpdate(const TimePeriod::Ptr&, doubl
 
 void TimePeriod::Dump(void)
 {
-       Array::Ptr segments = m_Segments;
+       Array::Ptr segments = GetSegments();
 
        Log(LogDebug, "icinga", "Dumping TimePeriod '" + GetName() + "'");
-       Log(LogDebug, "icinga", "Valid from '" + Utility::FormatDateTime("%c", m_ValidBegin) + "' until '" + Utility::FormatDateTime("%c", m_ValidEnd));
+       Log(LogDebug, "icinga", "Valid from '" + Utility::FormatDateTime("%c", GetValidBegin()) + "' until '" + Utility::FormatDateTime("%c", GetValidEnd()));
 
        if (segments) {
                ObjectLock dlock(segments);
@@ -327,35 +314,3 @@ void TimePeriod::Dump(void)
 
        Log(LogDebug, "icinga", "---");
 }
-
-void TimePeriod::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
-{
-       DynamicObject::InternalSerialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               bag->Set("display_name", m_DisplayName);
-               bag->Set("ranges", m_Ranges);
-       }
-
-       if (attributeTypes & Attribute_State) {
-               bag->Set("valid_begin", m_ValidBegin);
-               bag->Set("valid_end", m_ValidEnd);
-               bag->Set("segments", m_Segments);
-       }
-}
-
-void TimePeriod::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
-{
-       DynamicObject::InternalDeserialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               m_DisplayName = bag->Get("display_name");
-               m_Ranges = bag->Get("ranges");
-       }
-
-       if (attributeTypes & Attribute_State) {
-               m_ValidBegin = bag->Get("valid_begin");
-               m_ValidEnd = bag->Get("valid_end");
-               m_Segments = bag->Get("segments");
-       }
-}
index 8b9b2fd25bde232fc2238b75ddb49c0d428194a9..921b4b5e3142d80a576914759b834937aeb05418 100644 (file)
@@ -21,7 +21,7 @@
 #define TIMEPERIOD_H
 
 #include "icinga/i2-icinga.h"
-#include "base/dynamicobject.h"
+#include "icinga/timeperiod.th"
 #include "base/array.h"
 
 namespace icinga
@@ -32,15 +32,12 @@ namespace icinga
  *
  * @ingroup icinga
  */
-class I2_ICINGA_API TimePeriod : public DynamicObject
+class I2_ICINGA_API TimePeriod : public ReflectionObjectImpl<TimePeriod>
 {
 public:
        DECLARE_PTR_TYPEDEFS(TimePeriod);
        DECLARE_TYPENAME(TimePeriod);
 
-       String GetDisplayName(void) const;
-       Dictionary::Ptr GetRanges(void) const;
-
        virtual void Start(void);
 
        void UpdateRegion(double begin, double end, bool clearExisting);
@@ -51,17 +48,7 @@ public:
        static Array::Ptr EmptyTimePeriodUpdate(const TimePeriod::Ptr& tp, double begin, double end);
        static Array::Ptr EvenMinutesTimePeriodUpdate(const TimePeriod::Ptr& tp, double begin, double end);
 
-protected:
-       virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
-       virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
-
 private:
-       String m_DisplayName;
-       Dictionary::Ptr m_Ranges;
-       Value m_ValidBegin;
-       Value m_ValidEnd;
-       Array::Ptr m_Segments;
-
        void AddSegment(double s, double end);
        void AddSegment(const Dictionary::Ptr& segment);
        void RemoveSegment(double begin, double end);
diff --git a/lib/icinga/timeperiod.ti b/lib/icinga/timeperiod.ti
new file mode 100644 (file)
index 0000000..3999318
--- /dev/null
@@ -0,0 +1,17 @@
+#include "base/dynamicobject.h"
+
+namespace icinga
+{
+
+class TimePeriod : DynamicObject
+{
+       [config] String display_name {
+               default {{{ return GetName(); }}}
+       };
+       [config] Dictionary::Ptr ranges;
+       [state] Value valid_begin;
+       [state] Value valid_end;
+       [state] Array::Ptr segments;
+};
+
+}
\ No newline at end of file
index 07157005fab2b79df7f5936aa18582820a6ef3b3..d02f12c5210b553bdce81047c70cc9d06712eaa9 100644 (file)
@@ -62,66 +62,9 @@ void User::Stop(void)
        }
 }
 
-String User::GetDisplayName(void) const
-{
-       if (!m_DisplayName.IsEmpty())
-               return m_DisplayName;
-       else
-               return GetName();
-}
-
-Array::Ptr User::GetGroups(void) const
-{
-       return m_Groups;
-}
-
-Dictionary::Ptr User::GetMacros(void) const
-{
-       return m_Macros;
-}
-
-bool User::GetEnableNotifications(void) const
-{
-       if (m_EnableNotifications.IsEmpty())
-               return true;
-       else
-               return m_EnableNotifications;
-}
-
-void User::SetEnableNotifications(bool enabled)
-{
-       m_EnableNotifications = enabled;
-}
-
 TimePeriod::Ptr User::GetNotificationPeriod(void) const
 {
-       return TimePeriod::GetByName(m_NotificationPeriod);
-}
-
-unsigned long User::GetNotificationTypeFilter(void) const
-{
-       if (m_NotificationTypeFilter.IsEmpty())
-               return ~(unsigned long)0; /* All types. */
-       else
-               return m_NotificationTypeFilter;
-}
-
-unsigned long User::GetNotificationStateFilter(void) const
-{
-       if (m_NotificationStateFilter.IsEmpty())
-               return ~(unsigned long)0; /* All states. */
-       else
-               return m_NotificationStateFilter;
-}
-
-void User::SetLastNotification(double ts)
-{
-       m_LastNotification = ts;
-}
-
-double User::GetLastNotification(void) const
-{
-       return m_LastNotification;
+       return TimePeriod::GetByName(GetNotificationPeriodRaw());
 }
 
 bool User::ResolveMacro(const String& macro, const Dictionary::Ptr&, String *result) const
@@ -152,41 +95,3 @@ bool User::ResolveMacro(const String& macro, const Dictionary::Ptr&, String *res
                return false;
        }
 }
-
-void User::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
-{
-       DynamicObject::InternalSerialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               bag->Set("display_name", m_DisplayName);
-               bag->Set("macros", m_Macros);
-               bag->Set("groups", m_Groups);
-               bag->Set("notification_period", m_NotificationPeriod);
-               bag->Set("notification_type_filter", m_NotificationTypeFilter);
-               bag->Set("notification_state_filter", m_NotificationStateFilter);
-       }
-
-       if (attributeTypes & Attribute_State) {
-               bag->Set("enable_notifications", m_EnableNotifications);
-               bag->Set("last_notification", m_LastNotification);
-       }
-}
-
-void User::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
-{
-       DynamicObject::InternalDeserialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config) {
-               m_DisplayName = bag->Get("display_name");
-               m_Macros = bag->Get("macros");
-               m_Groups = bag->Get("groups");
-               m_NotificationPeriod = bag->Get("notification_period");
-               m_NotificationTypeFilter = bag->Get("notification_type_filter");
-               m_NotificationStateFilter = bag->Get("notification_state_filter");
-       }
-
-       if (attributeTypes & Attribute_State) {
-               m_EnableNotifications = bag->Get("enable_notifications");
-               m_LastNotification = bag->Get("last_notification");
-       }
-}
index bf47d47ab80ae0e91c456a8e714aff087ba63cb7..a458b4d1f4526e76063f8ae17672831b635c0ff6 100644 (file)
@@ -21,9 +21,9 @@
 #define USER_H
 
 #include "icinga/i2-icinga.h"
+#include "icinga/user.th"
 #include "icinga/macroresolver.h"
 #include "icinga/timeperiod.h"
-#include "base/dynamicobject.h"
 #include "base/array.h"
 
 namespace icinga
@@ -34,25 +34,14 @@ namespace icinga
  *
  * @ingroup icinga
  */
-class I2_ICINGA_API User : public DynamicObject, public MacroResolver
+class I2_ICINGA_API User : public ReflectionObjectImpl<User>, public MacroResolver
 {
 public:
        DECLARE_PTR_TYPEDEFS(User);
        DECLARE_TYPENAME(User);
 
-       String GetDisplayName(void) const;
-       Array::Ptr GetGroups(void) const;
-
        /* Notifications */
-       bool GetEnableNotifications(void) const;
-       void SetEnableNotifications(bool enabled);
        TimePeriod::Ptr GetNotificationPeriod(void) const;
-       unsigned long GetNotificationTypeFilter(void) const;
-       unsigned long GetNotificationStateFilter(void) const;
-       void SetLastNotification(double ts);
-       double GetLastNotification(void) const;
-
-       Dictionary::Ptr GetMacros(void) const;
 
        virtual bool ResolveMacro(const String& macro, const Dictionary::Ptr& cr, String *result) const;
 
@@ -60,19 +49,6 @@ protected:
        virtual void Stop(void);
 
        virtual void OnConfigLoaded(void);
-
-       virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
-       virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
-
-private:
-       String m_DisplayName;
-       Dictionary::Ptr m_Macros;
-       Array::Ptr m_Groups;
-       Value m_EnableNotifications;
-       String m_NotificationPeriod;
-       Value m_NotificationTypeFilter;
-       Value m_NotificationStateFilter;
-       double m_LastNotification;
 };
 
 }
diff --git a/lib/icinga/user.ti b/lib/icinga/user.ti
new file mode 100644 (file)
index 0000000..977d389
--- /dev/null
@@ -0,0 +1,24 @@
+#include "base/dynamicobject.h"
+
+namespace icinga
+{
+
+class User : DynamicObject
+{
+       [config] String display_name {
+               default {{{ return GetName(); }}}
+       };
+       [config] Dictionary::Ptr macros;
+       [config] Array::Ptr groups;
+       [config] String notification_period (NotificationPeriodRaw);
+       [config] int notification_type_filter {
+               default {{{ return ~(int)0; }}}
+       };
+       [config] int notification_state_filter {
+               default {{{ return ~(int)0; }}}
+       };
+       [state] bool enable_notifications;
+       [state] double last_notification;
+};
+
+}
\ No newline at end of file
index f378f133272ce6de64d7de909c6c982b2ba01f80..c06c52c308edfd04a81ecdbe3d24054a3cf7793d 100644 (file)
@@ -30,14 +30,6 @@ using namespace icinga;
 
 REGISTER_TYPE(UserGroup);
 
-String UserGroup::GetDisplayName(void) const
-{
-       if (!m_DisplayName.IsEmpty())
-               return m_DisplayName;
-       else
-               return GetName();
-}
-
 std::set<User::Ptr> UserGroup::GetMembers(void) const
 {
        return m_Members;
@@ -52,19 +44,3 @@ void UserGroup::RemoveMember(const User::Ptr& user)
 {
        m_Members.erase(user);
 }
-
-void UserGroup::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
-{
-       DynamicObject::InternalSerialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config)
-               bag->Set("display_name", m_DisplayName);
-}
-
-void UserGroup::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
-{
-       DynamicObject::InternalDeserialize(bag, attributeTypes);
-
-       if (attributeTypes & Attribute_Config)
-               m_DisplayName = bag->Get("display_name");
-}
index fbbff94558da2b81c5880942d1c1fcde65cb084d..5b02dd0eb24e18d39206b844a5657c5b06dc87d3 100644 (file)
@@ -21,8 +21,8 @@
 #define USERGROUP_H
 
 #include "icinga/i2-icinga.h"
+#include "icinga/usergroup.th"
 #include "icinga/user.h"
-#include "base/dynamicobject.h"
 
 namespace icinga
 {
@@ -32,24 +32,17 @@ namespace icinga
  *
  * @ingroup icinga
  */
-class I2_ICINGA_API UserGroup : public DynamicObject
+class I2_ICINGA_API UserGroup : public ReflectionObjectImpl<UserGroup>
 {
 public:
        DECLARE_PTR_TYPEDEFS(UserGroup);
        DECLARE_TYPENAME(UserGroup);
 
-       String GetDisplayName(void) const;
-
        std::set<User::Ptr> GetMembers(void) const;
        void AddMember(const User::Ptr& user);
        void RemoveMember(const User::Ptr& user);
 
-protected:
-       virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
-       virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
-
 private:
-       String m_DisplayName;
        std::set<User::Ptr> m_Members;
 };
 
diff --git a/lib/icinga/usergroup.ti b/lib/icinga/usergroup.ti
new file mode 100644 (file)
index 0000000..c6f7f28
--- /dev/null
@@ -0,0 +1,13 @@
+#include "base/dynamicobject.h"
+
+namespace icinga
+{
+
+class UserGroup : DynamicObject
+{
+       [config] String display_name {
+               default {{{ return GetName(); }}}
+       };
+};
+
+}
\ No newline at end of file
index e0173a47c74268c0ef8fc74992339ea24e6bcd8e..64c0e86b22259a711e715b2082e2ed67be6d6513 100644 (file)
@@ -50,7 +50,7 @@ scripts_argv (const char *file, char *const argv[], int argc, char **new_argv)
 /* Execute FILE, searching in the `PATH' environment variable if it contains
    no slashes, with arguments ARGV and environment from ENVP.  */
 int
-execvpe (file, argv, envp)
+icinga2_execvpe (file, argv, envp)
      const char *file;
      char *const argv[];
      char *const envp[];
index 803d6a8dc644aebd28c67273f5b4dd09fed33754..b0e16a699c67f36e482cefb61f7c07628e684578 100644 (file)
 #ifndef EXECVPE_H
 #define EXECVPE_H
 
-#include "config.h"
-
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
 
-#if !defined(_MSC_VER) && !defined(HAVE_EXECVPE)
-int execvpe(const char *file, char *const argv[], char *const envp[]);
-#endif /* !defined(_MSC_VER) && !defined(HAVE_EXECVPE) */
+#ifndef _MSC_VER
+int icinga2_execvpe(const char *file, char *const argv[], char *const envp[]);
+#endif /* _MSC_VER */
 
 #ifdef __cplusplus
 }
index e41f1e141d56ccd0f979fd4410cbc00cf7d27d2f..bf14d4707978f04b9912b0ce82f277adf6c2c0af 100644 (file)
@@ -1,5 +1,6 @@
 SUBDIRS = \
          migration \
+         mkclass \
          mkembedconfig
 
 sbin_SCRIPTS = icinga2-enable-feature
diff --git a/tools/mkclass/.gitignore b/tools/mkclass/.gitignore
new file mode 100644 (file)
index 0000000..02a8e78
--- /dev/null
@@ -0,0 +1,5 @@
+mkclass
+class_lexer.cc
+class_parser.cc
+class_parser.h
+class_parser.hh
\ No newline at end of file
diff --git a/tools/mkclass/Makefile.am b/tools/mkclass/Makefile.am
new file mode 100644 (file)
index 0000000..d29b384
--- /dev/null
@@ -0,0 +1,23 @@
+## Process this file with automake to produce Makefile.in
+
+noinst_PROGRAMS = \
+       mkclass
+
+EXTRA_DIST = \
+       class_lexer.cc \
+       class_parser.cc \
+       class_parser.h
+
+AM_YFLAGS = -d
+
+.hh.h:
+       if [ -e $(srcdir)/$< ]; then cp $(srcdir)/$< $(srcdir)/$@; fi
+
+class_lexer.cc: class_parser.h
+
+mkclass_SOURCES = \
+       classcompiler.cpp \
+       classcompiler.h \
+       class_lexer.ll \
+       class_parser.yy \
+       mkclass.cpp
diff --git a/tools/mkclass/base.int b/tools/mkclass/base.int
new file mode 100644 (file)
index 0000000..db8c9e2
--- /dev/null
@@ -0,0 +1,27 @@
+#include "base/dynamicobject.h"
+
+
+
+#include "base/logger.h"
+
+class Logger : DynamicObject
+{
+       [config] String severity;
+};
+
+class StreamLogger : Logger { };
+
+class FileLogger : StreamLogger
+{
+       [config] String path;
+};
+
+class ConsoleLogger : StreamLogger { };
+
+class SyslogLogger : Logger { };
+
+class Script : DynamicObject
+{
+       [config] String language;
+       [config] String code;
+};
diff --git a/tools/mkclass/class_lexer.ll b/tools/mkclass/class_lexer.ll
new file mode 100644 (file)
index 0000000..9bfd935
--- /dev/null
@@ -0,0 +1,144 @@
+%{
+/******************************************************************************
+ * 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 "classcompiler.h"
+ #include "class_parser.h"
+
+using namespace icinga;
+
+#define YY_EXTRA_TYPE ClassCompiler *
+#define YY_USER_ACTION                                                         \
+do {                                                                                   \
+       yylloc->path = yyextra->GetPath();                      \
+       yylloc->first_line = yylineno;                          \
+       yylloc->first_column = yycolumn;                        \
+       yylloc->last_line = yylineno;                           \
+       yylloc->last_column = yycolumn + yyleng - 1;\
+       yycolumn += yyleng;                                                     \
+} while (0);
+
+#define YY_INPUT(buf, result, max_size)                        \
+do {                                                   \
+       result = yyextra->ReadInput(buf, max_size);     \
+} while (0)
+
+struct lex_buf {
+       char *buf;
+       size_t size;
+};
+
+static void lb_init(lex_buf *lb)
+{
+       lb->buf = NULL;
+       lb->size = 0;
+}
+
+static void lb_cleanup(lex_buf *lb)
+{
+       free(lb->buf);
+}
+
+static void lb_append_char(lex_buf *lb, char new_char)
+{
+       const size_t block_size = 64;
+
+       size_t old_blocks = (lb->size + (block_size - 1)) / block_size;
+       size_t new_blocks = ((lb->size + 1) + (block_size - 1)) / block_size;
+
+       if (old_blocks != new_blocks) {
+               char *new_buf = (char *)realloc(lb->buf, new_blocks * block_size);
+
+               if (new_buf == NULL && new_blocks > 0)
+                       throw std::bad_alloc();
+
+               lb->buf = new_buf;
+       }
+
+       lb->size++;
+       lb->buf[lb->size - 1] = new_char;
+}
+
+static char *lb_steal(lex_buf *lb)
+{
+       lb_append_char(lb, '\0');
+
+       char *buf = lb->buf;
+       lb->buf = NULL;
+       lb->size = 0;
+       return buf;
+}
+%}
+
+%option reentrant noyywrap yylineno
+%option bison-bridge bison-locations
+%option never-interactive nounistd
+
+%x HEREDOC
+
+%%
+       lex_buf string_buf;
+
+\{\{\{                         { lb_init(&string_buf); BEGIN(HEREDOC); }
+
+<HEREDOC>\}\}\}                        {
+       BEGIN(INITIAL);
+
+       lb_append_char(&string_buf, '\0');
+
+       yylval->text = lb_steal(&string_buf);
+
+       return T_STRING;
+                               }
+
+<HEREDOC>(.|\n)                        { lb_append_char(&string_buf, yytext[0]); }
+
+[ \t\r\n]                      /* ignore whitespace */
+
+#include                       { return T_INCLUDE; }
+class                          { return T_CLASS; }
+namespace                      { return T_NAMESPACE; }
+code                           { return T_CODE; }
+config                         { yylval->num = FAConfig; return T_FIELD_ATTRIBUTE; }
+state                          { yylval->num = FAState; return T_FIELD_ATTRIBUTE; }
+enum                           { yylval->num = FAEnum; return T_FIELD_ATTRIBUTE; }
+get_protected          { yylval->num = FAGetProtected; return T_FIELD_ATTRIBUTE; }
+set_protected          { yylval->num = FASetProtected; return T_FIELD_ATTRIBUTE; }
+protected                      { yylval->num = FAGetProtected | FASetProtected; return T_FIELD_ATTRIBUTE; }
+default                                { yylval->num = FTDefault; return T_FIELD_ACCESSOR_TYPE; }
+get                                    { yylval->num = FTGet; return T_FIELD_ACCESSOR_TYPE; }
+set                                    { yylval->num = FTSet; return T_FIELD_ACCESSOR_TYPE; }
+\"[^\"]+\"                     { yylval->text = strdup(yytext + 1); yylval->text[strlen(yylval->text) - 1] = '\0'; return T_STRING; }
+\<[^>]+\>                              { yylval->text = strdup(yytext + 1); yylval->text[strlen(yylval->text) - 1] = '\0'; return T_ANGLE_STRING; }
+[a-zA-Z_][:a-zA-Z0-9\-_]*      { yylval->text = strdup(yytext); return T_IDENTIFIER; }
+
+.                              return yytext[0];
+
+%%
+
+void ClassCompiler::InitializeScanner(void)
+{
+       yylex_init(&m_Scanner);
+       yyset_extra(this, m_Scanner);
+}
+
+void ClassCompiler::DestroyScanner(void)
+{
+       yylex_destroy(m_Scanner);
+}
diff --git a/tools/mkclass/class_parser.yy b/tools/mkclass/class_parser.yy
new file mode 100644 (file)
index 0000000..fb02035
--- /dev/null
@@ -0,0 +1,310 @@
+%code requires {
+/******************************************************************************
+ * 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 "classcompiler.h"
+ #include <iostream>
+ #include <vector>
+
+using namespace icinga;
+
+#define YYLTYPE icinga::ClassDebugInfo
+
+}
+
+%pure-parser
+
+%locations
+%defines
+%error-verbose
+
+%parse-param { ClassCompiler *context }
+%lex-param { void *scanner }
+
+%union {
+       char *text;
+       int num;
+       Field *field;
+       std::vector<Field> *fields;
+       Klass *klass;
+       FieldAccessor *fieldaccessor;
+       std::vector<FieldAccessor> *fieldaccessors;
+}
+
+%token T_INCLUDE "include (T_INCLUDE)"
+%token T_CLASS "class (T_CLASS)"
+%token T_CODE "code (T_CODE)"
+%token T_NAMESPACE "namespace (T_NAMESPACE)"
+%token T_STRING "string (T_STRING)"
+%token T_ANGLE_STRING "angle_string (T_ANGLE_STRING)"
+%token T_FIELD_ATTRIBUTE "field_attribute (T_FIELD_ATTRIBUTE)"
+%token T_IDENTIFIER "identifier (T_IDENTIFIER)"
+%token T_GET "get (T_GET)"
+%token T_SET "set (T_SET)"
+%token T_DEFAULT "default (T_DEFAULT)"
+%token T_FIELD_ACCESSOR_TYPE "field_accessor_type (T_FIELD_ACCESSOR_TYPE)"
+%type <text> T_IDENTIFIER
+%type <text> T_STRING
+%type <text> T_ANGLE_STRING
+%type <text> identifier
+%type <text> alternative_name_specifier
+%type <text> inherits_specifier
+%type <text> include
+%type <text> angle_include
+%type <text> code
+%type <num> T_FIELD_ATTRIBUTE
+%type <num> field_attributes
+%type <num> field_attribute_list
+%type <num> T_FIELD_ACCESSOR_TYPE
+%type <field> class_field
+%type <fields> class_fields
+%type <klass> class
+%type <fieldaccessors> field_accessor_list
+%type <fieldaccessors> field_accessors
+%type <fieldaccessor> field_accessor
+
+%{
+
+int yylex(YYSTYPE *lvalp, YYLTYPE *llocp, void *scanner);
+
+void yyerror(YYLTYPE *locp, ClassCompiler *, const char *err)
+{
+       std::cerr << "in " << locp->path << " at " << locp->first_line << ":" << locp->first_column << "-" << locp->last_line << ":" << locp->last_column << ": "
+                         << err
+                         << std::endl;
+}
+
+int yyparse(ClassCompiler *context);
+
+void ClassCompiler::Compile(void)
+{
+       try {
+               yyparse(this);
+       } catch (const std::exception& ex) {
+               std::cerr << "Exception: " << ex.what();
+       }
+}
+
+#define scanner (context->GetScanner())
+
+%}
+
+%%
+
+statements: /* empty */
+       | statements statement
+       ;
+
+statement: include
+       {
+               context->HandleInclude($1, yylloc);
+               free($1);
+       }
+       | angle_include
+       {
+               context->HandleAngleInclude($1, yylloc);
+               free($1);
+       }
+       | class
+       {
+               context->HandleClass(*$1, yylloc);
+               delete $1;
+       }
+       | namespace
+       | code
+       {
+               context->HandleCode($1, yylloc);
+               free($1);
+       }
+       ;
+
+include: T_INCLUDE T_STRING
+       {
+               $$ = $2;
+       }
+       ;
+
+angle_include: T_INCLUDE T_ANGLE_STRING
+       {
+               $$ = $2;
+       }
+       ;
+
+namespace: T_NAMESPACE identifier '{'
+       {
+               context->HandleNamespaceBegin($2, yylloc);
+               free($2);
+       }
+       statements '}'
+       {
+               context->HandleNamespaceEnd(yylloc);
+       }
+       ;
+
+code: T_CODE T_STRING
+       {
+               $$ = $2;
+       }
+       ;
+
+class: T_CLASS T_IDENTIFIER inherits_specifier '{' class_fields '}' ';'
+       {
+               $$ = new Klass();
+
+               $$->Name = $2;
+               free($2);
+
+               if ($3) {
+                       $$->Parent = $3;
+                       free($3);
+               }
+
+               $$->Fields = *$5;
+               delete $5;
+       }
+       ;
+
+inherits_specifier: /* empty */
+       {
+               $$ = NULL;
+       }
+       | ':' identifier
+       {
+               $$ = $2;
+       }
+       ;
+
+class_fields: /* empty */
+       {
+               $$ = new std::vector<Field>();
+       }
+       | class_fields class_field
+       {
+               $$->push_back(*$2);
+               delete $2;
+       }
+       ;
+
+class_field: field_attribute_list identifier identifier alternative_name_specifier field_accessor_list ';'
+       {
+               Field *field = new Field();
+
+               field->Attributes = $1;
+
+               field->Type = $2;
+               free($2);
+
+               field->Name = $3;
+               free($3);
+
+               if ($4) {
+                       field->AlternativeName = $4;
+                       free($4);
+               }
+
+               std::vector<FieldAccessor>::const_iterator it;
+               for (it = $5->begin(); it != $5->end(); it++) {
+                       switch (it->Type) {
+                               case FTGet:
+                                       field->GetAccessor = it->Accessor;
+                                       break;
+                               case FTSet:
+                                       field->SetAccessor = it->Accessor;
+                                       break;
+                               case FTDefault:
+                                       field->DefaultAccessor = it->Accessor;
+                                       break;
+                               }
+               }
+
+               delete $5;
+
+               $$ = field;
+       }
+       ;
+
+alternative_name_specifier: /* empty */
+       {
+               $$ = NULL;
+       }
+       | '(' identifier ')'
+       {
+               $$ = $2;
+       }
+       ;
+
+field_attribute_list: /* empty */
+       {
+               $$ = 0;
+       }
+       | '[' field_attributes ']'
+       {
+               $$ = $2;
+       }
+       ;
+
+field_attributes: /* empty */
+       {
+               $$ = 0;
+       }
+       | field_attributes ',' T_FIELD_ATTRIBUTE
+       {
+               $$ = $1 | $3;
+       }
+       | T_FIELD_ATTRIBUTE
+       {
+               $$ = $1;
+       }
+       ;
+
+field_accessor_list: /* empty */
+       {
+               $$ = new std::vector<FieldAccessor>();
+       }
+       | '{' field_accessors '}'
+       {
+               $$ = $2;
+       }
+       ;
+
+field_accessors: /* empty */
+       {
+               $$ = new std::vector<FieldAccessor>();
+       }
+       | field_accessors field_accessor
+       {
+               $$ = $1;
+               $$->push_back(*$2);
+               delete $2;
+       }
+       ;
+
+field_accessor: T_FIELD_ACCESSOR_TYPE T_STRING
+       {
+               $$ = new FieldAccessor(static_cast<FieldAccessorType>($1), $2);
+               free($2);
+       }
+       ;
+
+identifier: T_IDENTIFIER
+       | T_STRING
+       {
+               $$ = $1;
+       }
+       ;
diff --git a/tools/mkclass/classcompiler.cpp b/tools/mkclass/classcompiler.cpp
new file mode 100644 (file)
index 0000000..f0d5c57
--- /dev/null
@@ -0,0 +1,358 @@
+/******************************************************************************
+ * 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 "classcompiler.h"
+#include <iostream>
+#include <fstream>
+#include <stdexcept>
+
+using namespace icinga;
+
+ClassCompiler::ClassCompiler(const std::string& path, std::istream *input)
+       : m_Path(path), m_Input(input)
+{
+       InitializeScanner();
+}
+
+ClassCompiler::~ClassCompiler(void)
+{
+       DestroyScanner();
+}
+
+std::string ClassCompiler::GetPath(void) const
+{
+       return m_Path;
+}
+
+void *ClassCompiler::GetScanner(void)
+{
+       return m_Scanner;
+}
+
+size_t ClassCompiler::ReadInput(char *buffer, size_t max_size)
+{
+       m_Input->read(buffer, max_size);
+       return static_cast<size_t>(m_Input->gcount());
+}
+
+void ClassCompiler::HandleInclude(const std::string& path, const ClassDebugInfo& locp)
+{
+       std::cout << "#include \"" << path << "\"" << std::endl << std::endl;
+}
+
+void ClassCompiler::HandleAngleInclude(const std::string& path, const ClassDebugInfo& locp)
+{
+       std::cout << "#include <" << path << ">" << std::endl << std::endl;
+}
+
+void ClassCompiler::HandleNamespaceBegin(const std::string& name, const ClassDebugInfo& locp)
+{
+       std::cout << "namespace " << name << std::endl
+                         << "{" << std::endl << std::endl;
+}
+
+void ClassCompiler::HandleNamespaceEnd(const ClassDebugInfo& locp)
+{
+       std::cout << "}" << std::endl;
+}
+
+void ClassCompiler::HandleCode(const std::string& code, const ClassDebugInfo& locp)
+{
+       std::cout << code << std::endl;
+}
+
+void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo& locp)
+{
+       std::vector<Field>::const_iterator it;
+
+       if (klass.Name.find_first_of(':') == std::string::npos)
+               std::cout << "class " << klass.Name << ";" << std::endl << std::endl;
+
+       std::cout << "template<>" << std::endl
+                 << "class ReflectionObjectImpl<" << klass.Name << ">"
+                 << " : public " << (klass.Parent.empty() ? "ReflectionObject" : klass.Parent) << std::endl
+                 << "{" << std::endl
+                 << "public:" << std::endl
+                 << "\t" << "DECLARE_PTR_TYPEDEFS(ReflectionObjectImpl<" << klass.Name << ">);" << std::endl;
+
+       if (!klass.Fields.empty()) {
+               /* constructor */
+               std::cout << "public:" << std::endl
+                         << "\t" << "ReflectionObjectImpl<" << klass.Name << ">(void)" << std::endl
+                         << "\t" << "{" << std::endl;
+
+               for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
+                       std::cout << "\t\t" << "Set" << it->GetFriendlyName() << "(" << "GetDefault" << it->GetFriendlyName() << "());" << std::endl;
+               }
+
+               std::cout << "\t" << "}" << std::endl << std::endl;
+
+               /* GetFieldId */
+               std::cout << "public:" << std::endl
+                                 << "\t" << "virtual int GetFieldId(const String& name) const" << std::endl
+                                 << "\t" << "{" << std::endl
+                                 << "\t\t" << "int offset = ";
+
+               if (!klass.Parent.empty())
+                        std::cout << klass.Parent << "::GetFieldCount()";
+               else
+                       std::cout << "0";
+
+               std::cout << ";" << std::endl << std::endl;
+
+               int num = 0;
+               for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
+                       std::cout << "\t\t" << "if (name == \"" << it->Name << "\")" << std::endl
+                                         << "\t\t\t" << "return offset + " << num << ";" << std::endl;
+                       num++;
+               }
+
+               std::cout << std::endl
+                                 << "\t\t" << "return ";
+
+               if (!klass.Parent.empty())
+                        std::cout << klass.Parent << "::GetFieldId(name)";
+               else
+                       std::cout << "-1";
+
+               std::cout << ";" << std::endl
+                                 << "\t" << "}" << std::endl << std::endl;
+
+               /* GetFieldInfo */
+               std::cout << "public:" << std::endl
+                                 << "\t" << "virtual ReflectionField GetFieldInfo(int id) const" << std::endl
+                                 << "\t" << "{" << std::endl;
+
+               if (!klass.Parent.empty())
+                       std::cout << "\t\t" << "int real_id = id - " << klass.Parent << "::GetFieldCount();" << std::endl
+                                         << "\t\t" << "if (real_id < 0) { return " << klass.Parent << "::GetFieldInfo(id); }" << std::endl;
+
+               std::cout << "\t\t" << "switch (";
+
+               if (!klass.Parent.empty())
+                       std::cout << "real_id";
+               else
+                       std::cout << "id";
+
+               std::cout << ") {" << std::endl;
+
+               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 << ", " << "GetDefault" << it->GetFriendlyName() << "());" << std::endl;
+                       num++;
+               }
+
+               std::cout << "\t\t\t" << "default:" << std::endl
+                                 << "\t\t\t\t" << "throw std::runtime_error(\"Invalid field ID.\");" << std::endl
+                                 << "\t\t" << "}" << std::endl;
+
+               std::cout << "\t" << "}" << std::endl << std::endl;
+
+               /* GetFieldCount */
+               std::cout << "public:" << std::endl
+                                 << "\t" << "virtual int GetFieldCount(void) const" << std::endl
+                                 << "\t" << "{" << std::endl
+                                 << "\t\t" << "return " << klass.Fields.size();
+
+               if (!klass.Parent.empty())
+                       std::cout << " + " << klass.Parent + "::GetFieldCount()";
+
+               std::cout << ";" << std::endl
+                                 << "\t" << "}" << std::endl << std::endl;
+
+               /* SetField */
+               std::cout << "protected:" << std::endl
+                                 << "\t" << "virtual void SetField(int id, const Value& value)" << std::endl
+                                 << "\t" << "{" << std::endl;
+
+               if (!klass.Parent.empty())
+                       std::cout << "\t\t" << "int real_id = id - " << klass.Parent << "::GetFieldCount();" << std::endl
+                                         << "\t\t" << "if (real_id < 0) { " << klass.Parent << "::SetField(id, value); return; }" << std::endl;
+
+               std::cout << "\t\t" << "switch (";
+
+               if (!klass.Parent.empty())
+                       std::cout << "real_id";
+               else
+                       std::cout << "id";
+
+               std::cout << ") {" << std::endl;
+
+               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" << "Set" << it->GetFriendlyName() << "(";
+                       
+                       if (it->Attributes & FAEnum)
+                               std::cout << "static_cast<" << it->Type << ">(static_cast<int>(";
+
+                       std::cout << "value";
+                       
+                       if (it->Attributes & FAEnum)
+                               std::cout << "))";
+                       
+                       std::cout << ");" << std::endl
+                                         << "\t\t\t\t" << "break;" << std::endl;
+                       num++;
+               }
+
+               std::cout << "\t\t\t" << "default:" << std::endl
+                                 << "\t\t\t\t" << "throw std::runtime_error(\"Invalid field ID.\");" << std::endl
+                                 << "\t\t" << "}" << std::endl;
+
+               std::cout << "\t" << "}" << std::endl << std::endl;
+
+               /* GetField */
+               std::cout << "protected:" << std::endl
+                                 << "\t" << "virtual Value GetField(int id) const" << std::endl
+                                 << "\t" << "{" << std::endl;
+
+               if (!klass.Parent.empty())
+                       std::cout << "\t\t" << "int real_id = id - " << klass.Parent << "::GetFieldCount();" << std::endl
+                                         << "\t\t" << "if (real_id < 0) { return " << klass.Parent << "::GetField(id); }" << std::endl;
+
+               std::cout << "\t\t" << "switch (";
+
+               if (!klass.Parent.empty())
+                       std::cout << "real_id";
+               else
+                       std::cout << "id";
+
+               std::cout << ") {" << std::endl;
+
+               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 Get" << it->GetFriendlyName() << "();" << std::endl;
+                       num++;
+               }
+
+               std::cout << "\t\t\t" << "default:" << std::endl
+                                 << "\t\t\t\t" << "throw std::runtime_error(\"Invalid field ID.\");" << std::endl
+                                 << "\t\t" << "}" << std::endl;
+
+               std::cout << "\t" << "}" << std::endl << std::endl;
+
+               /* getters */
+               for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
+                       std::string prot;
+
+                       if (it->Attributes & FAGetProtected)
+                               prot = "protected";
+                       else
+                               prot = "public";
+
+                       std::cout << prot << ":" << std::endl
+                                         << "\t" << it->Type << " Get" << it->GetFriendlyName() << "(void) const" << std::endl
+                                         << "\t" << "{" << std::endl;
+
+                       if (it->GetAccessor.empty())
+                               std::cout << "\t\t" << "return m_" << it->GetFriendlyName() << ";" << std::endl;
+                       else
+                               std::cout << it->GetAccessor << std::endl;
+
+                       std::cout << "\t" << "}" << std::endl << std::endl;
+               }
+
+               /* setters */
+               for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
+                       std::string prot;
+
+                       if (it->Attributes & FASetProtected)
+                               prot = "protected";
+                       else if (it->Attributes & FAConfig)
+                               prot = "private";
+                       else
+                               prot = "public";
+
+                       std::cout << prot << ":" << std::endl
+                                         << "\t" << "void Set" << it->GetFriendlyName() << "(const " << it->Type << "& value)" << std::endl
+                                         << "\t" << "{" << std::endl;
+
+                       if (it->SetAccessor.empty())
+                               std::cout << "\t\t" << "m_" << it->GetFriendlyName() << " = value;" << std::endl;
+                       else
+                               std::cout << it->SetAccessor << std::endl;
+
+                       std::cout << "\t" << "}" << std::endl << std::endl;
+               }
+
+               /* default */
+               for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
+                       std::string prot;
+
+                       std::cout << "private:" << std::endl
+                                         << "\t" << it->Type << " GetDefault" << it->GetFriendlyName() << "(void) const" << std::endl
+                                         << "\t" << "{" << std::endl;
+
+                       if (it->DefaultAccessor.empty())
+                               std::cout << "\t\t" << "return Empty;" << std::endl;
+                       else
+                               std::cout << it->DefaultAccessor << std::endl;
+
+                       std::cout << "\t" << "}" << std::endl;
+               }
+
+               /* instance variables */
+               std::cout << "private:" << std::endl;
+
+               for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
+                       std::cout << "\t" << it->Type << " m_" << it->GetFriendlyName() << ";" << std::endl;
+               }
+       }
+
+       std::cout << "};" << std::endl << std::endl;
+}
+
+void ClassCompiler::CompileFile(const std::string& path)
+{
+       std::ifstream stream;
+       stream.open(path.c_str(), std::ifstream::in);
+
+       if (!stream)
+               throw std::invalid_argument("Could not open config file: " + path);
+
+       std::cerr << "Compiling class file: " + path << std::endl;
+
+       return CompileStream(path, &stream);
+}
+
+void ClassCompiler::CompileStream(const std::string& path, std::istream *stream)
+{
+       stream->exceptions(std::istream::badbit);
+
+       std::cout << "#include \"base/reflectionobject.h\"" << std::endl
+                         << "#include \"base/debug.h\"" << std::endl
+                         << "#include \"base/value.h\"" << std::endl
+                         << "#include \"base/array.h\"" << std::endl
+                         << "#include \"base/dictionary.h\"" << std::endl << std::endl
+                         << "#ifdef _MSC_VER" << std::endl
+                         << "#pragma warning( push )" << std::endl
+                         << "#pragma warning( disable : 4244 )" << std::endl
+                         << "#pragma warning( disable : 4800 )" << std::endl
+                         << "#endif /* _MSC_VER */" << std::endl << std::endl;
+
+       ClassCompiler ctx(path, stream);
+       ctx.Compile();
+
+       std::cout << "#ifdef _MSC_VER" << std::endl
+                         << "#pragma warning ( pop )" << std::endl
+                         << "#endif /* _MSC_VER */" << std::endl;
+}
diff --git a/tools/mkclass/classcompiler.h b/tools/mkclass/classcompiler.h
new file mode 100644 (file)
index 0000000..6b037b0
--- /dev/null
@@ -0,0 +1,150 @@
+/******************************************************************************
+ * 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.             *
+ ******************************************************************************/
+
+#ifndef CLASSCOMPILER_H
+#define CLASSCOMPILER_H
+
+#include <string>
+#include <istream>
+#include <vector>
+#include <algorithm>
+
+struct YYLTYPE;
+
+namespace icinga
+{
+
+struct ClassDebugInfo
+{
+       std::string path;
+       int first_line;
+       int first_column;
+       int last_line;
+       int last_column;
+};
+
+enum FieldAccessorType
+{
+       FTGet,
+       FTSet,
+       FTDefault
+};
+
+struct FieldAccessor
+{
+       FieldAccessorType Type;
+       std::string Accessor;
+
+       FieldAccessor(FieldAccessorType type, const std::string& accessor)
+               : Type(type), Accessor(accessor)
+       { }
+};
+
+enum FieldAttribute
+{
+       FAConfig = 1,
+       FAState = 2,
+       FAEnum = 4,
+       FAGetProtected = 8,
+       FASetProtected = 16
+};
+
+struct Field
+{
+       int Attributes;
+       std::string Type;
+       std::string Name;
+       std::string AlternativeName;
+       std::string GetAccessor;
+       std::string SetAccessor;
+       std::string DefaultAccessor;
+
+       std::string GetFriendlyName(void) const
+       {
+               if (!AlternativeName.empty())
+                       return AlternativeName;
+
+               bool cap = true;
+               std::string name = Name;
+
+               for (size_t i = 0; i < name.size(); i++) {
+                       if (name[i] == '_') {
+                               cap = true;
+                               continue;
+                       }
+
+                       if (cap) {
+                               name[i] = toupper(name[i]);
+                               cap = false;
+                       }
+               }
+
+               name.erase(
+                       std::remove(name.begin(), name.end(), '_'),
+                       name.end()
+                       );
+
+               /* TODO: figure out name */
+               return name;
+       }
+};
+
+struct Klass
+{
+       std::string Name;
+       std::string Parent;
+       std::vector<Field> Fields;
+};
+
+class ClassCompiler
+{
+public:
+       ClassCompiler(const std::string& path, std::istream *input);
+       ~ClassCompiler(void);
+
+       void Compile(void);
+
+       std::string GetPath(void) const;
+
+       void InitializeScanner(void);
+       void DestroyScanner(void);
+
+       void *GetScanner(void);
+
+       size_t ReadInput(char *buffer, size_t max_size);
+
+       void HandleInclude(const std::string& path, const ClassDebugInfo& locp);
+       void HandleAngleInclude(const std::string& path, const ClassDebugInfo& locp);
+       void HandleClass(const Klass& klass, const ClassDebugInfo& locp);
+       void HandleNamespaceBegin(const std::string& name, const ClassDebugInfo& locp);
+       void HandleNamespaceEnd(const ClassDebugInfo& locp);
+       void HandleCode(const std::string& code, const ClassDebugInfo& locp);
+
+       static void CompileFile(const std::string& path);
+       static void CompileStream(const std::string& path, std::istream *stream);
+
+private:
+       std::string m_Path;
+       std::istream *m_Input;
+       void *m_Scanner;
+};
+
+}
+
+#endif /* CLASSCOMPILER_H */
\ No newline at end of file
diff --git a/tools/mkclass/icinga.int b/tools/mkclass/icinga.int
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tools/mkclass/mkclass.cpp b/tools/mkclass/mkclass.cpp
new file mode 100644 (file)
index 0000000..27bd617
--- /dev/null
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * 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 "classcompiler.h"
+#include <iostream>
+
+using namespace icinga;
+
+int main(int argc, char **argv)
+{
+       if (argc < 1) {
+               std::cerr << "Syntax: " << argv[0] << " <file>" << std::endl;
+               return 1;
+       }
+
+       ClassCompiler::CompileFile(argv[1]);
+}
diff --git a/tools/mkclass/mkclass.filters b/tools/mkclass/mkclass.filters
new file mode 100644 (file)
index 0000000..d46f1b9
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="Quelldateien">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="Headerdateien">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+    <Filter Include="Ressourcendateien">
+      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="mkembedconfig.c">
+      <Filter>Quelldateien</Filter>
+    </ClCompile>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="packages.config" />
+  </ItemGroup>
+</Project>
\ No newline at end of file
diff --git a/tools/mkclass/mkclass.vcxproj b/tools/mkclass/mkclass.vcxproj
new file mode 100644 (file)
index 0000000..177338a
--- /dev/null
@@ -0,0 +1,222 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="..\..\packages\openssl.1.0.1.24\build\native\openssl.props" Condition="Exists('..\..\packages\openssl.1.0.1.24\build\native\openssl.props')" />
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|x64">
+      <Configuration>Debug</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{CBC9DD83-BAEB-4995-8D0B-F711898908E7}</ProjectGuid>
+    <Keyword>Win32Proj</Keyword>
+    <RootNamespace>mkclass</RootNamespace>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <CharacterSet>MultiByte</CharacterSet>
+    <PlatformToolset>v110</PlatformToolset>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <CharacterSet>MultiByte</CharacterSet>
+    <PlatformToolset>v110</PlatformToolset>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>MultiByte</CharacterSet>
+    <PlatformToolset>v110</PlatformToolset>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>MultiByte</CharacterSet>
+    <PlatformToolset>v110</PlatformToolset>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <LinkIncremental>true</LinkIncremental>
+    <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
+    <IntDir>$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <LinkIncremental>true</LinkIncremental>
+    <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
+    <IntDir>$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <LinkIncremental>false</LinkIncremental>
+    <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
+    <IntDir>$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <LinkIncremental>false</LinkIncremental>
+    <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
+    <IntDir>$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <PreprocessorDefinitions>_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <ClCompile>
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <PreprocessorDefinitions>_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <PreprocessorDefinitions>NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <PreprocessorDefinitions>NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <ClCompile Include="classcompiler.cpp" />
+    <ClCompile Include="class_lexer.cc" />
+    <ClCompile Include="class_parser.cc" />
+    <ClCompile Include="mkclass.cpp" />
+  </ItemGroup>
+  <ItemGroup>
+    <CustomBuild Include="class_parser.yy">
+      <FileType>Document</FileType>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">win_bison -d "%(FullPath)"
+del class_parser.cc
+ren class_parser.tab.cc class_parser.cc
+del class_parser.h
+ren class_parser.tab.hh class_parser.h</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">win_bison -d "%(FullPath)"
+del class_parser.cc
+ren class_parser.tab.cc class_parser.cc
+del class_parser.h
+ren class_parser.tab.hh class_parser.h</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">win_bison -d "%(FullPath)"
+del class_parser.cc
+ren class_parser.tab.cc class_parser.cc
+del class_parser.h
+ren class_parser.tab.hh class_parser.h</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">win_bison -d "%(FullPath)"
+del class_parser.cc
+ren class_parser.tab.cc class_parser.cc
+del class_parser.h
+ren class_parser.tab.hh class_parser.h</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">class_parser.cc;class_parser.h</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">class_parser.cc;class_parser.h</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">class_parser.cc;class_parser.h</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">class_parser.cc;class_parser.h</Outputs>
+    </CustomBuild>
+    <CustomBuild Include="class_lexer.ll">
+      <FileType>Document</FileType>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">win_flex "%(FullPath)"
+del class_lexer.cc
+ren lex.yy.c class_lexer.cc</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">class_lexer.cc</Outputs>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">win_flex "%(FullPath)"
+del class_lexer.cc
+ren lex.yy.c class_lexer.cc</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">class_lexer.cc</Outputs>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">win_flex "%(FullPath)"
+del class_lexer.cc
+ren lex.yy.c class_lexer.cc</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">class_lexer.cc</Outputs>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">win_flex "%(FullPath)"
+del class_lexer.cc
+ren lex.yy.c class_lexer.cc</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">class_lexer.cc</Outputs>
+    </CustomBuild>
+    <None Include="base.int" />
+    <None Include="icinga.int" />
+    <None Include="packages.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="classcompiler.h" />
+    <ClInclude Include="class_parser.h" />
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+    <Import Project="..\..\packages\boost.1.54.0.1\build\native\boost.targets" Condition="Exists('..\..\packages\boost.1.54.0.1\build\native\boost.targets')" />
+    <Import Project="..\..\packages\boost_thread.1.54.0.2\build\native\boost_thread.targets" Condition="Exists('..\..\packages\boost_thread.1.54.0.2\build\native\boost_thread.targets')" />
+    <Import Project="..\..\packages\boost_system.1.54.0.2\build\native\boost_system.targets" Condition="Exists('..\..\packages\boost_system.1.54.0.2\build\native\boost_system.targets')" />
+    <Import Project="..\..\packages\boost_exception.1.54.0.2\build\native\boost_exception.targets" Condition="Exists('..\..\packages\boost_exception.1.54.0.2\build\native\boost_exception.targets')" />
+    <Import Project="..\..\packages\boost_program_options.1.54.0.2\build\native\boost_program_options.targets" Condition="Exists('..\..\packages\boost_program_options.1.54.0.2\build\native\boost_program_options.targets')" />
+    <Import Project="..\..\packages\boost_unit_test_framework.1.54.0.2\build\native\boost_unit_test_framework.targets" Condition="Exists('..\..\packages\boost_unit_test_framework.1.54.0.2\build\native\boost_unit_test_framework.targets')" />
+    <Import Project="..\..\packages\zlib.redist.1.2.8.6\build\native\zlib.redist.targets" Condition="Exists('..\..\packages\zlib.redist.1.2.8.6\build\native\zlib.redist.targets')" />
+    <Import Project="..\..\packages\zlib.1.2.8.6\build\native\zlib.targets" Condition="Exists('..\..\packages\zlib.1.2.8.6\build\native\zlib.targets')" />
+    <Import Project="..\..\packages\openssl.redist.1.0.1.24\build\native\openssl.redist.targets" Condition="Exists('..\..\packages\openssl.redist.1.0.1.24\build\native\openssl.redist.targets')" />
+    <Import Project="..\..\packages\openssl.1.0.1.24\build\native\openssl.targets" Condition="Exists('..\..\packages\openssl.1.0.1.24\build\native\openssl.targets')" />
+    <Import Project="..\..\packages\boost_date_time.1.54.0.2\build\native\boost_date_time.targets" Condition="Exists('..\..\packages\boost_date_time.1.54.0.2\build\native\boost_date_time.targets')" />
+    <Import Project="..\..\packages\boost_chrono.1.54.0.2\build\native\boost_chrono.targets" Condition="Exists('..\..\packages\boost_chrono.1.54.0.2\build\native\boost_chrono.targets')" />
+  </ImportGroup>
+</Project>
\ No newline at end of file
diff --git a/tools/mkclass/packages.config b/tools/mkclass/packages.config
new file mode 100644 (file)
index 0000000..63dced5
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="boost" version="1.54.0.1" targetFramework="Native" />
+  <package id="boost_chrono" version="1.54.0.2" targetFramework="Native" />
+  <package id="boost_date_time" version="1.54.0.2" targetFramework="Native" />
+  <package id="boost_exception" version="1.54.0.2" targetFramework="Native" />
+  <package id="boost_program_options" version="1.54.0.2" targetFramework="Native" />
+  <package id="boost_system" version="1.54.0.2" targetFramework="Native" />
+  <package id="boost_thread" version="1.54.0.2" targetFramework="Native" />
+  <package id="boost_unit_test_framework" version="1.54.0.2" targetFramework="Native" />
+  <package id="openssl" version="1.0.1.24" targetFramework="Native" />
+  <package id="openssl.redist" version="1.0.1.24" targetFramework="Native" />
+  <package id="zlib" version="1.2.8.6" targetFramework="Native" />
+  <package id="zlib.redist" version="1.2.8.6" targetFramework="Native" />
+</packages>
\ No newline at end of file