]> granicus.if.org Git - icinga2/commitdiff
Use const references for shared ptrs.
authorGunnar Beutner <gunnar.beutner@netways.de>
Tue, 3 Apr 2012 09:39:26 +0000 (11:39 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Tue, 3 Apr 2012 09:39:26 +0000 (11:39 +0200)
base/application.cpp
base/application.h
base/component.cpp
base/component.h
base/confighive.cpp
base/confighive.h

index 929ccc07bfcc5079829f4cb08c12504dee1b5fee..099fe0440105fcc9fd56f3c9be8ae6e8a113ffb5 100644 (file)
@@ -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<string, Component::Ptr>::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<string, Component::Ptr>::iterator ci = m_Components.find(name);
 
@@ -261,12 +261,12 @@ void Application::SetArguments(const vector<string>& arguments)
        m_Arguments = arguments;
 }
 
-vector<string>& Application::GetArguments(void)
+const vector<string>& 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());
index b2ff04c9a1ae6e158e28c2d972853f1f66a8d019..99248cb88c8f21f0b941b124223f7b8b606d6b92 100644 (file)
@@ -24,7 +24,7 @@ public:
        virtual int Main(const vector<string>& args) = 0;
 
        void SetArguments(const vector<string>& arguments);
-       vector<string>& GetArguments(void);
+       const vector<string>& GetArguments(void);
 
        void RunEventLoop(void);
        bool Daemonize(void);
@@ -34,12 +34,12 @@ public:
 
        ConfigHive::Ptr GetConfigHive(void);
 
-       shared_ptr<Component> LoadComponent(string path, ConfigObject::Ptr componentConfig);
-       void UnloadComponent(string name);
-       shared_ptr<Component> GetComponent(string name);
-       void AddComponentSearchDir(string componentDirectory);
+       shared_ptr<Component> LoadComponent(const string& path, const ConfigObject::Ptr& componentConfig);
+       void UnloadComponent(const string& name);
+       shared_ptr<Component> GetComponent(const string& name);
+       void AddComponentSearchDir(const string& componentDirectory);
 
-       string GetExeDirectory(void);
+       const string& GetExeDirectory(void);
 };
 
 template<class T>
index d9b40a6de21fe33a7157b6afe3e3af3c9ae24a2e..90a2013c670a41747a314a31630c3dfbf80db2ea 100644 (file)
@@ -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;
 }
index 829e25db23b79105f6b8a22aa19afe51e892bfa2..4415a17e8bbdb15f462d66d6b64286a1737dffdf 100644 (file)
@@ -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;
index 03fc279cb1d39a72aa034ee94b880e50cb60bdba..9463b34832d016819bbf1446cbc790697334a487 100644 (file)
@@ -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);
index e837cf410d8fe5b3cea4bdd00be01af967d899df..6e5d527e0f23fd5559299d655498188054789c84 100644 (file)
@@ -24,8 +24,8 @@ public:
        typedef map<string, ConfigObject::Ptr>::iterator ObjectIterator;
        map< string, map<string, ConfigObject::Ptr> > 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<ConfigHiveEventArgs::Ptr> OnObjectCreated;