From: Gunnar Beutner Date: Mon, 9 Jul 2012 14:38:01 +0000 (+0200) Subject: Verify object type in the CIB class constructors. X-Git-Tag: v0.0.1~283 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c7788f73c21424868cb5772cc1dcfff4b587a1d9;p=icinga2 Verify object type in the CIB class constructors. --- diff --git a/cib/host.h b/cib/host.h index 719bac86e..156aaeefa 100644 --- a/cib/host.h +++ b/cib/host.h @@ -9,7 +9,9 @@ class I2_CIB_API Host : public ConfigObjectAdapter public: Host(const ConfigObject::Ptr& configObject) : ConfigObjectAdapter(configObject) - { } + { + assert(GetType() == "host"); + } static bool Exists(const string& name); static Host GetByName(const string& name); diff --git a/cib/hostgroup.h b/cib/hostgroup.h index 3a5daf21e..025c1a819 100644 --- a/cib/hostgroup.h +++ b/cib/hostgroup.h @@ -9,7 +9,9 @@ class I2_CIB_API HostGroup : public ConfigObjectAdapter public: HostGroup(const ConfigObject::Ptr& configObject) : ConfigObjectAdapter(configObject) - { } + { + assert(GetType() == "hostgroup"); + } static bool Exists(const string& name); static HostGroup GetByName(const string& name); diff --git a/cib/service.h b/cib/service.h index 47978c73f..a75abc8a6 100644 --- a/cib/service.h +++ b/cib/service.h @@ -27,7 +27,9 @@ class I2_CIB_API Service : public ConfigObjectAdapter public: Service(const ConfigObject::Ptr& configObject) : ConfigObjectAdapter(configObject) - { } + { + assert(GetType() == "service"); + } static bool Exists(const string& name); static Service GetByName(const string& name); diff --git a/cib/servicegroup.h b/cib/servicegroup.h index 6bde52320..51cd09111 100644 --- a/cib/servicegroup.h +++ b/cib/servicegroup.h @@ -9,7 +9,9 @@ class I2_CIB_API ServiceGroup : public ConfigObjectAdapter public: ServiceGroup(const ConfigObject::Ptr& configObject) : ConfigObjectAdapter(configObject) - { } + { + assert(GetType() == "servicegroup"); + } static bool Exists(const string& name); static ServiceGroup GetByName(const string& name);