mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 05:34:48 +02:00
Implement event for registering/unregistering script functions.
Fixes #3704
This commit is contained in:
parent
2e7e0c6473
commit
3ee1dbc94c
@ -21,6 +21,9 @@
|
|||||||
|
|
||||||
using namespace icinga;
|
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)
|
ScriptFunction::ScriptFunction(const Callback& function)
|
||||||
: m_Callback(function)
|
: m_Callback(function)
|
||||||
{ }
|
{ }
|
||||||
@ -28,11 +31,13 @@ ScriptFunction::ScriptFunction(const Callback& function)
|
|||||||
void ScriptFunction::Register(const String& name, const ScriptFunction::Ptr& function)
|
void ScriptFunction::Register(const String& name, const ScriptFunction::Ptr& function)
|
||||||
{
|
{
|
||||||
GetFunctions()[name] = function;
|
GetFunctions()[name] = function;
|
||||||
|
Application::GetEQ().Post(boost::bind(boost::ref(OnRegistered), name, function));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptFunction::Unregister(const String& name)
|
void ScriptFunction::Unregister(const String& name)
|
||||||
{
|
{
|
||||||
GetFunctions().erase(name);
|
GetFunctions().erase(name);
|
||||||
|
Application::GetEQ().Post(boost::bind(boost::ref(OnUnregistered), name));
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptFunction::Ptr ScriptFunction::GetByName(const String& name)
|
ScriptFunction::Ptr ScriptFunction::GetByName(const String& name)
|
||||||
|
@ -48,6 +48,9 @@ public:
|
|||||||
|
|
||||||
static map<String, ScriptFunction::Ptr>& GetFunctions(void);
|
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:
|
private:
|
||||||
Callback m_Callback;
|
Callback m_Callback;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user