Implement event for registering/unregistering script functions.

Fixes #3704
This commit is contained in:
Gunnar Beutner 2013-02-15 10:09:07 +01:00
parent 2e7e0c6473
commit 3ee1dbc94c
2 changed files with 8 additions and 0 deletions

View File

@ -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)

View File

@ -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;
};