From c7788f73c21424868cb5772cc1dcfff4b587a1d9 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Mon, 9 Jul 2012 16:38:01 +0200 Subject: [PATCH] Verify object type in the CIB class constructors. --- cib/host.h | 4 +++- cib/hostgroup.h | 4 +++- cib/service.h | 4 +++- cib/servicegroup.h | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) 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);