[icinga-checkins] icinga.org: icinga2/master: Implement event for registering/ unregistering script functions.

git at icinga.org git at icinga.org
Fri Feb 15 10:10:44 CET 2013


Module: icinga2
Branch: master
Commit: 3ee1dbc94c2d5853abc49b3a3254278830cddf27
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=3ee1dbc94c2d5853abc49b3a3254278830cddf27

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Fri Feb 15 10:09:07 2013 +0100

Implement event for registering/unregistering script functions.

Fixes #3704

---

 lib/base/scriptfunction.cpp |    5 +++++
 lib/base/scriptfunction.h   |    3 +++
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/lib/base/scriptfunction.cpp b/lib/base/scriptfunction.cpp
index dff3903..3a8f5fa 100644
--- a/lib/base/scriptfunction.cpp
+++ b/lib/base/scriptfunction.cpp
@@ -21,6 +21,9 @@
 
 using namespace icinga;
 
+boost::signal<void (const String&, const ScriptFunction::Ptr&)> ScriptFunction::OnRegistered;
+boost::signal<void (const String&)> ScriptFunction::OnUnregistered;
+
 ScriptFunction::ScriptFunction(const Callback& function)
 	: m_Callback(function)
 { }
@@ -28,11 +31,13 @@ ScriptFunction::ScriptFunction(const Callback& function)
 void ScriptFunction::Register(const String& name, const ScriptFunction::Ptr& function)
 {
 	GetFunctions()[name] = function;
+	Application::GetEQ().Post(boost::bind(boost::ref(OnRegistered), name, function));
 }
 
 void ScriptFunction::Unregister(const String& name)
 {
 	GetFunctions().erase(name);
+	Application::GetEQ().Post(boost::bind(boost::ref(OnUnregistered), name));
 }
 
 ScriptFunction::Ptr ScriptFunction::GetByName(const String& name)
diff --git a/lib/base/scriptfunction.h b/lib/base/scriptfunction.h
index bc9fff7..4597acd 100644
--- a/lib/base/scriptfunction.h
+++ b/lib/base/scriptfunction.h
@@ -48,6 +48,9 @@ public:
 
 	static map<String, ScriptFunction::Ptr>& GetFunctions(void);
 
+	static boost::signal<void (const String&, const ScriptFunction::Ptr&)> OnRegistered;
+	static boost::signal<void (const String&)> OnUnregistered;
+
 private:
 	Callback m_Callback;
 };





More information about the icinga-checkins mailing list