From 36e9e9adbd624eaff13624fd56047e67cd593b7e Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Fri, 12 Jul 2013 15:13:05 +0200 Subject: [PATCH] custom attr: move into DynamicObject using GetCustom() --- components/compat/compatcomponent.cpp | 2 +- lib/base/dynamicobject.cpp | 6 ++++++ lib/base/dynamicobject.h | 3 +++ lib/icinga/host.cpp | 6 ------ lib/icinga/host.h | 2 -- lib/icinga/service.cpp | 6 ------ lib/icinga/service.h | 2 -- 7 files changed, 10 insertions(+), 17 deletions(-) diff --git a/components/compat/compatcomponent.cpp b/components/compat/compatcomponent.cpp index 683d8dd8a..695a9f624 100644 --- a/components/compat/compatcomponent.cpp +++ b/components/compat/compatcomponent.cpp @@ -624,7 +624,7 @@ void CompatComponent::DumpServiceObject(std::ostream& fp, const Service::Ptr& se void CompatComponent::DumpCustomAttributes(std::ostream& fp, const DynamicObject::Ptr& object) { - Dictionary::Ptr custom = object->Get("custom"); + Dictionary::Ptr custom = object->GetCustom(); if (!custom) return; diff --git a/lib/base/dynamicobject.cpp b/lib/base/dynamicobject.cpp index ed38d1322..6482a8b05 100644 --- a/lib/base/dynamicobject.cpp +++ b/lib/base/dynamicobject.cpp @@ -56,6 +56,7 @@ DynamicObject::DynamicObject(const Dictionary::Ptr& serializedObject) RegisterAttribute("__local", Attribute_Config, &m_Local); RegisterAttribute("__source", Attribute_Local, &m_Source); RegisterAttribute("methods", Attribute_Config, &m_Methods); + RegisterAttribute("custom", Attribute_Config, &m_Custom); if (!serializedObject->Contains("configTx")) BOOST_THROW_EXCEPTION(std::invalid_argument("Serialized object must contain a config snapshot.")); @@ -616,3 +617,8 @@ const DynamicObject::AttributeMap& DynamicObject::GetAttributes(void) const return m_Attributes; } + +Dictionary::Ptr DynamicObject::GetCustom(void) const +{ + return m_Custom; +} diff --git a/lib/base/dynamicobject.h b/lib/base/dynamicobject.h index 1308ab0a2..2b3e452d3 100644 --- a/lib/base/dynamicobject.h +++ b/lib/base/dynamicobject.h @@ -101,6 +101,8 @@ public: static double GetCurrentTx(void); + Dictionary::Ptr GetCustom(void) const; + protected: explicit DynamicObject(const Dictionary::Ptr& serializedObject); @@ -125,6 +127,7 @@ private: Attribute m_Local; Attribute m_Source; Attribute m_Methods; + Attribute m_Custom; bool m_Registered; /**< protected by the type mutex */ diff --git a/lib/icinga/host.cpp b/lib/icinga/host.cpp index 8ca6738d0..d41de5553 100644 --- a/lib/icinga/host.cpp +++ b/lib/icinga/host.cpp @@ -51,7 +51,6 @@ Host::Host(const Dictionary::Ptr& serializedUpdate) RegisterAttribute("display_name", Attribute_Config, &m_DisplayName); RegisterAttribute("hostgroups", Attribute_Config, &m_HostGroups); RegisterAttribute("macros", Attribute_Config, &m_Macros); - RegisterAttribute("custom", Attribute_Config, &m_Custom); RegisterAttribute("hostdependencies", Attribute_Config, &m_HostDependencies); RegisterAttribute("servicedependencies", Attribute_Config, &m_ServiceDependencies); RegisterAttribute("hostcheck", Attribute_Config, &m_HostCheck); @@ -105,11 +104,6 @@ Dictionary::Ptr Host::GetMacros(void) const return m_Macros; } -Dictionary::Ptr Host::GetCustom(void) const -{ - return m_Custom; -} - Array::Ptr Host::GetHostDependencies(void) const { return m_HostDependencies;; diff --git a/lib/icinga/host.h b/lib/icinga/host.h index 954380ee1..85b6469a8 100644 --- a/lib/icinga/host.h +++ b/lib/icinga/host.h @@ -88,7 +88,6 @@ public: Array::Ptr GetGroups(void) const; Dictionary::Ptr GetMacros(void) const; - Dictionary::Ptr GetCustom(void) const; Array::Ptr GetHostDependencies(void) const; Array::Ptr GetServiceDependencies(void) const; String GetHostCheck(void) const; @@ -128,7 +127,6 @@ private: Attribute m_DisplayName; Attribute m_HostGroups; Attribute m_Macros; - Attribute m_Custom; Attribute m_HostDependencies; Attribute m_ServiceDependencies; Attribute m_HostCheck; diff --git a/lib/icinga/service.cpp b/lib/icinga/service.cpp index f70e29a36..495e52d89 100644 --- a/lib/icinga/service.cpp +++ b/lib/icinga/service.cpp @@ -44,7 +44,6 @@ Service::Service(const Dictionary::Ptr& serializedObject) RegisterAttribute("display_name", Attribute_Config, &m_DisplayName); RegisterAttribute("macros", Attribute_Config, &m_Macros); - RegisterAttribute("custom", Attribute_Config, &m_Custom); RegisterAttribute("hostdependencies", Attribute_Config, &m_HostDependencies); RegisterAttribute("servicedependencies", Attribute_Config, &m_ServiceDependencies); RegisterAttribute("servicegroups", Attribute_Config, &m_ServiceGroups); @@ -167,11 +166,6 @@ Dictionary::Ptr Service::GetMacros(void) const return m_Macros; } -Dictionary::Ptr Service::GetCustom(void) const -{ - return m_Custom; -} - Array::Ptr Service::GetHostDependencies(void) const { return m_HostDependencies; diff --git a/lib/icinga/service.h b/lib/icinga/service.h index 153594702..9da59e9dd 100644 --- a/lib/icinga/service.h +++ b/lib/icinga/service.h @@ -112,7 +112,6 @@ public: String GetDisplayName(void) const; Host::Ptr GetHost(void) const; Dictionary::Ptr GetMacros(void) const; - Dictionary::Ptr GetCustom(void) const; Array::Ptr GetHostDependencies(void) const; Array::Ptr GetServiceDependencies(void) const; Array::Ptr GetGroups(void) const; @@ -311,7 +310,6 @@ private: Attribute m_DisplayName; Attribute m_Macros; - Attribute m_Custom; Attribute m_HostDependencies; Attribute m_ServiceDependencies; Attribute m_ServiceGroups; -- 2.40.0