* performance (see http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt11ch25s02.html).
*/
-const String CompatComponent::DefaultStatusPath = Application::GetLocalStateDir() + "/status.dat";
-const String CompatComponent::DefaultObjectsPath = Application::GetLocalStateDir() + "/objects.cache";
-const String CompatComponent::DefaultCommandPath = Application::GetLocalStateDir() + "/icinga.cmd";
-
/**
* Retrieves the status.dat path.
*
{
Value statusPath = GetConfig()->Get("status_path");
if (statusPath.IsEmpty())
- return DefaultStatusPath;
+ return Application::GetLocalStateDir() + "/status.dat";
else
return statusPath;
}
{
Value objectsPath = GetConfig()->Get("objects_path");
if (objectsPath.IsEmpty())
- return DefaultObjectsPath;
+ return Application::GetLocalStateDir() + "/objects.cache";
else
return objectsPath;
}
{
Value commandPath = GetConfig()->Get("command_path");
if (commandPath.IsEmpty())
- return DefaultCommandPath;
+ return Application::GetLocalStateDir() + "/icinga.cmd";
else
return commandPath;
}
void DumpServiceObject(ofstream& fp, const Service::Ptr& service);
void StatusTimerHandler(void);
-
- static const String DefaultStatusPath;
- static const String DefaultObjectsPath;
- static const String DefaultCommandPath;
};
}
using namespace icinga;
-map<String, ScriptFunction::Ptr> ScriptFunction::m_Functions;
-
ScriptFunction::ScriptFunction(const Callback& function)
: m_Callback(function)
{ }
void ScriptFunction::Register(const String& name, const ScriptFunction::Ptr& function)
{
- m_Functions[name] = function;
+ GetFunctions()[name] = function;
}
void ScriptFunction::Unregister(const String& name)
{
- m_Functions.erase(name);
+ GetFunctions().erase(name);
}
ScriptFunction::Ptr ScriptFunction::GetByName(const String& name)
{
map<String, ScriptFunction::Ptr>::iterator it;
- it = m_Functions.find(name);
+ it = GetFunctions().find(name);
- if (it == m_Functions.end())
+ if (it == GetFunctions().end())
return ScriptFunction::Ptr();
return it->second;
{
m_Callback(task, arguments);
}
+
+map<String, ScriptFunction::Ptr>& ScriptFunction::GetFunctions(void)
+{
+ static map<String, ScriptFunction::Ptr> functions;
+ return functions;
+}
private:
Callback m_Callback;
- static map<String, ScriptFunction::Ptr> m_Functions;
+ static map<String, ScriptFunction::Ptr>& GetFunctions(void);
};
/**