From 3ee1dbc94c2d5853abc49b3a3254278830cddf27 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Fri, 15 Feb 2013 10:09:07 +0100 Subject: [PATCH] Implement event for registering/unregistering script functions. Fixes #3704 --- lib/base/scriptfunction.cpp | 5 +++++ lib/base/scriptfunction.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/lib/base/scriptfunction.cpp b/lib/base/scriptfunction.cpp index dff3903c1..3a8f5fafa 100644 --- a/lib/base/scriptfunction.cpp +++ b/lib/base/scriptfunction.cpp @@ -21,6 +21,9 @@ using namespace icinga; +boost::signal ScriptFunction::OnRegistered; +boost::signal 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 bc9fff7bd..4597acde6 100644 --- a/lib/base/scriptfunction.h +++ b/lib/base/scriptfunction.h @@ -48,6 +48,9 @@ public: static map& GetFunctions(void); + static boost::signal OnRegistered; + static boost::signal OnUnregistered; + private: Callback m_Callback; };