From: Gunnar Beutner Date: Tue, 3 Apr 2012 09:39:26 +0000 (+0200) Subject: Use const references for shared ptrs. X-Git-Tag: v0.0.1~653 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b30284c64c66bbbdc414c6f9e690863380a4e8bc;p=icinga2 Use const references for shared ptrs. --- diff --git a/base/application.cpp b/base/application.cpp index 929ccc07b..099fe0440 100644 --- a/base/application.cpp +++ b/base/application.cpp @@ -175,7 +175,7 @@ ConfigHive::Ptr Application::GetConfigHive(void) return m_ConfigHive; } -Component::Ptr Application::LoadComponent(string path, ConfigObject::Ptr componentConfig) +Component::Ptr Application::LoadComponent(const string& path, const ConfigObject::Ptr& componentConfig) { Component::Ptr component; Component *(*pCreateComponent)(); @@ -217,7 +217,7 @@ Component::Ptr Application::LoadComponent(string path, ConfigObject::Ptr compone return component; } -Component::Ptr Application::GetComponent(string name) +Component::Ptr Application::GetComponent(const string& name) { map::iterator ci = m_Components.find(name); @@ -227,7 +227,7 @@ Component::Ptr Application::GetComponent(string name) return ci->second; } -void Application::UnloadComponent(string name) +void Application::UnloadComponent(const string& name) { map::iterator ci = m_Components.find(name); @@ -261,12 +261,12 @@ void Application::SetArguments(const vector& arguments) m_Arguments = arguments; } -vector& Application::GetArguments(void) +const vector& Application::GetArguments(void) { return m_Arguments; } -string Application::GetExeDirectory(void) +const string& Application::GetExeDirectory(void) { static string ExePath; @@ -344,7 +344,7 @@ string Application::GetExeDirectory(void) return ExePath; } -void Application::AddComponentSearchDir(string componentDirectory) +void Application::AddComponentSearchDir(const string& componentDirectory) { #ifdef _WIN32 SetDllDirectory(componentDirectory.c_str()); diff --git a/base/application.h b/base/application.h index b2ff04c9a..99248cb88 100644 --- a/base/application.h +++ b/base/application.h @@ -24,7 +24,7 @@ public: virtual int Main(const vector& args) = 0; void SetArguments(const vector& arguments); - vector& GetArguments(void); + const vector& GetArguments(void); void RunEventLoop(void); bool Daemonize(void); @@ -34,12 +34,12 @@ public: ConfigHive::Ptr GetConfigHive(void); - shared_ptr LoadComponent(string path, ConfigObject::Ptr componentConfig); - void UnloadComponent(string name); - shared_ptr GetComponent(string name); - void AddComponentSearchDir(string componentDirectory); + shared_ptr LoadComponent(const string& path, const ConfigObject::Ptr& componentConfig); + void UnloadComponent(const string& name); + shared_ptr GetComponent(const string& name); + void AddComponentSearchDir(const string& componentDirectory); - string GetExeDirectory(void); + const string& GetExeDirectory(void); }; template diff --git a/base/component.cpp b/base/component.cpp index d9b40a6de..90a2013c6 100644 --- a/base/component.cpp +++ b/base/component.cpp @@ -12,7 +12,7 @@ Application::Ptr Component::GetApplication(void) return m_Application.lock(); } -void Component::SetConfig(ConfigObject::Ptr componentConfig) +void Component::SetConfig(const ConfigObject::Ptr& componentConfig) { m_Config = componentConfig; } diff --git a/base/component.h b/base/component.h index 829e25db2..4415a17e8 100644 --- a/base/component.h +++ b/base/component.h @@ -17,7 +17,7 @@ public: void SetApplication(const Application::WeakPtr& application); Application::Ptr GetApplication(void); - void SetConfig(ConfigObject::Ptr componentConfig); + void SetConfig(const ConfigObject::Ptr& componentConfig); ConfigObject::Ptr GetConfig(void); virtual string GetName(void) = 0; diff --git a/base/confighive.cpp b/base/confighive.cpp index 03fc279cb..9463b3483 100644 --- a/base/confighive.cpp +++ b/base/confighive.cpp @@ -2,7 +2,7 @@ using namespace icinga; -void ConfigHive::AddObject(ConfigObject::Ptr object) +void ConfigHive::AddObject(const ConfigObject::Ptr& object) { string type = object->GetType(); TypeIterator ti = Objects.find(type); @@ -23,7 +23,7 @@ void ConfigHive::AddObject(ConfigObject::Ptr object) OnObjectCreated(ea); } -void ConfigHive::RemoveObject(ConfigObject::Ptr object) +void ConfigHive::RemoveObject(const ConfigObject::Ptr& object) { string type = object->GetType(); TypeIterator ti = Objects.find(type); diff --git a/base/confighive.h b/base/confighive.h index e837cf410..6e5d527e0 100644 --- a/base/confighive.h +++ b/base/confighive.h @@ -24,8 +24,8 @@ public: typedef map::iterator ObjectIterator; map< string, map > Objects; - void AddObject(ConfigObject::Ptr object); - void RemoveObject(ConfigObject::Ptr object); + void AddObject(const ConfigObject::Ptr& object); + void RemoveObject(const ConfigObject::Ptr& object); ConfigObject::Ptr GetObject(const string& type, const string& name = string()); event OnObjectCreated;