ScriptVariable::Unregister(name);
}
-RegisterFunctionHelper::RegisterFunctionHelper(const String& name, const ScriptFunction::Callback& function)
-{
- ScriptFunction::Register(name, new ScriptFunction(function));
-}
Callback m_Callback;
};
-/**
- * Helper class for registering ScriptFunction implementation classes.
- *
- * @ingroup base
- */
-class I2_BASE_API RegisterFunctionHelper
-{
-public:
- RegisterFunctionHelper(const String& name, const ScriptFunction::Callback& function);
-};
-
#define REGISTER_SCRIPTFUNCTION(name, callback) \
- I2_EXPORT icinga::RegisterFunctionHelper g_RegisterSF_ ## name(#name, WrapScriptFunction(callback))
+ namespace { namespace UNIQUE_NAME(sf) { namespace sf ## name { \
+ void RegisterFunction(void) { \
+ ScriptFunction::Ptr sf = new icinga::ScriptFunction(WrapScriptFunction(callback)); \
+ ScriptFunction::Register(#name, sf); \
+ } \
+ INITIALIZE_ONCE(RegisterFunction); \
+ } } }
}
return m_Callback(status, perfdata);
}
-RegisterStatsFunctionHelper::RegisterStatsFunctionHelper(const String& name, const StatsFunction::Callback& function)
-{
- StatsFunction::Ptr func = new StatsFunction(function);
- StatsFunctionRegistry::GetInstance()->Register(name, func);
-}
-
StatsFunctionRegistry *StatsFunctionRegistry::GetInstance(void)
{
return Singleton<StatsFunctionRegistry>::GetInstance();
static StatsFunctionRegistry *GetInstance(void);
};
-/**
- * Helper class for registering StatsFunction implementation classes.
- *
- * @ingroup base
- */
-class I2_BASE_API RegisterStatsFunctionHelper
-{
-public:
- RegisterStatsFunctionHelper(const String& name, const StatsFunction::Callback& function);
-};
-
#define REGISTER_STATSFUNCTION(name, callback) \
- I2_EXPORT icinga::RegisterStatsFunctionHelper g_RegisterStF_ ## name(#name, callback)
+ namespace { namespace UNIQUE_NAME(stf) { namespace stf ## name { \
+ void RegisterStatsFunction(void) \
+ { \
+ StatsFunction::Ptr stf = new StatsFunction(callback); \
+ StatsFunctionRegistry::GetInstance()->Register(#name, stf); \
+ } \
+ INITIALIZE_ONCE(RegisterStatsFunction); \
+ } } }
}
#include "base/logger.hpp"
#include "base/type.hpp"
#include "base/serializer.hpp"
-#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/trim.hpp>
-#include <boost/algorithm/string/classification.hpp>
#include <boost/foreach.hpp>
#include <boost/program_options.hpp>
#include <algorithm>
GetRegistry().erase(name);
}
-RegisterCLICommandHelper::RegisterCLICommandHelper(const String& name, const CLICommand::Ptr& command)
-{
- std::vector<String> vname;
- boost::algorithm::split(vname, name, boost::is_any_of("/"));
- CLICommand::Register(vname, command);
-}
-
std::vector<String> CLICommand::GetArgumentSuggestions(const String& argument, const String& word) const
{
return std::vector<String>();
#include "base/type.hpp"
#include <vector>
#include <boost/program_options.hpp>
+#include <boost/algorithm/string/split.hpp>
+#include <boost/algorithm/string/classification.hpp>
namespace icinga
{
static std::map<std::vector<String>, CLICommand::Ptr>& GetRegistry(void);
};
-/**
- * Helper class for registering CLICommand implementation classes.
- *
- * @ingroup base
- */
-class I2_CLI_API RegisterCLICommandHelper
-{
-public:
- RegisterCLICommandHelper(const String& name, const CLICommand::Ptr& command);
-};
-
#define REGISTER_CLICOMMAND(name, klass) \
namespace { namespace UNIQUE_NAME(cli) { \
- I2_EXPORT icinga::RegisterCLICommandHelper l_RegisterCLICommand(name, new klass()); \
+ void RegisterCommand(void) \
+ { \
+ std::vector<String> vname; \
+ boost::algorithm::split(vname, name, boost::is_any_of("/")); \
+ CLICommand::Register(vname, new klass()); \
+ } \
+ INITIALIZE_ONCE(RegisterCommand); \
} }
}
#include "base/objectlock.hpp"
#include "base/json.hpp"
#include <boost/foreach.hpp>
-#include <boost/algorithm/string/case_conv.hpp>
#include <iostream>
#include <fstream>
REGISTER_BLACKANDWHITELIST_CLICOMMAND(whitelist);
REGISTER_BLACKANDWHITELIST_CLICOMMAND(blacklist);
-RegisterBlackAndWhitelistCLICommandHelper::RegisterBlackAndWhitelistCLICommandHelper(const String& type)
-{
- String ltype = type;
- boost::algorithm::to_lower(ltype);
-
- std::vector<String> name;
- name.push_back("node");
- name.push_back(ltype);
- name.push_back("add");
- CLICommand::Register(name, new BlackAndWhitelistCommand(type, BlackAndWhitelistCommandAdd));
-
- name[2] = "remove";
- CLICommand::Register(name, new BlackAndWhitelistCommand(type, BlackAndWhitelistCommandRemove));
-
- name[2] = "list";
- CLICommand::Register(name, new BlackAndWhitelistCommand(type, BlackAndWhitelistCommandList));
-}
-
BlackAndWhitelistCommand::BlackAndWhitelistCommand(const String& type, BlackAndWhitelistCommandType command)
: m_Type(type), m_Command(command)
{ }
#define BLACKANDWHITELISTCOMMAND_H
#include "cli/clicommand.hpp"
+#include <boost/algorithm/string/case_conv.hpp>
namespace icinga
{
BlackAndWhitelistCommandType m_Command;
};
-/**
- * Helper class for registering repository CLICommand implementation classes.
- *
- * @ingroup cli
- */
-class I2_CLI_API RegisterBlackAndWhitelistCLICommandHelper
-{
-public:
- RegisterBlackAndWhitelistCLICommandHelper(const String& type);
-};
-
#define REGISTER_BLACKANDWHITELIST_CLICOMMAND(type) \
- namespace { namespace UNIQUE_NAME(blackandwhitelist) { \
- I2_EXPORT icinga::RegisterBlackAndWhitelistCLICommandHelper l_RegisterBlackAndWhitelistCLICommand_ ## type(#type); \
- } }
+ namespace { namespace UNIQUE_NAME(blackandwhitelist) { namespace blackandwhitelist ## type { \
+ void RegisterCommand(void) \
+ { \
+ String ltype = #type; \
+ boost::algorithm::to_lower(ltype); \
+\
+ std::vector<String> name; \
+ name.push_back("node"); \
+ name.push_back(ltype); \
+ name.push_back("add"); \
+ CLICommand::Register(name, new BlackAndWhitelistCommand(#type, BlackAndWhitelistCommandAdd)); \
+\
+ name[2] = "remove"; \
+ CLICommand::Register(name, new BlackAndWhitelistCommand(#type, BlackAndWhitelistCommandRemove)); \
+\
+ name[2] = "list"; \
+ CLICommand::Register(name, new BlackAndWhitelistCommand(#type, BlackAndWhitelistCommandList)); \
+ } \
+ INITIALIZE_ONCE(RegisterCommand); \
+ } } }
}
#include "base/application.hpp"
#include "base/utility.hpp"
#include <boost/foreach.hpp>
-#include <boost/algorithm/string/join.hpp>
-#include <boost/algorithm/string/case_conv.hpp>
#include <fstream>
#include <iostream>
REGISTER_REPOSITORY_CLICOMMAND(Zone);
REGISTER_REPOSITORY_CLICOMMAND(Endpoint);
-RegisterRepositoryCLICommandHelper::RegisterRepositoryCLICommandHelper(const String& type)
-{
- String ltype = type;
- boost::algorithm::to_lower(ltype);
-
- std::vector<String> name;
- name.push_back("repository");
- name.push_back(ltype);
- name.push_back("add");
- CLICommand::Register(name, new RepositoryObjectCommand(type, RepositoryCommandAdd));
-
- name[2] = "remove";
- CLICommand::Register(name, new RepositoryObjectCommand(type, RepositoryCommandRemove));
-
- name[2] = "list";
- CLICommand::Register(name, new RepositoryObjectCommand(type, RepositoryCommandList));
-}
-
RepositoryObjectCommand::RepositoryObjectCommand(const String& type, RepositoryCommandType command)
: m_Type(type), m_Command(command)
{ }
#define REPOSITORYOBJECTCOMMAND_H
#include "cli/clicommand.hpp"
+#include <boost/algorithm/string/case_conv.hpp>
namespace icinga
{
RepositoryCommandType m_Command;
};
-/**
- * Helper class for registering repository CLICommand implementation classes.
- *
- * @ingroup cli
- */
-class I2_CLI_API RegisterRepositoryCLICommandHelper
-{
-public:
- RegisterRepositoryCLICommandHelper(const String& type);
-};
-
#define REGISTER_REPOSITORY_CLICOMMAND(type) \
- namespace { namespace UNIQUE_NAME(repositoryobject) { \
- I2_EXPORT icinga::RegisterRepositoryCLICommandHelper l_RegisterRepositoryCLICommand_ ## type(#type); \
- } }
+ namespace { namespace UNIQUE_NAME(repositoryobject) { namespace repositoryobject ## type { \
+ void RegisterCommand(void) \
+ { \
+ String ltype = #type; \
+ boost::algorithm::to_lower(ltype); \
+\
+ std::vector<String> name; \
+ name.push_back("repository"); \
+ name.push_back(ltype); \
+ name.push_back("add"); \
+ CLICommand::Register(name, new RepositoryObjectCommand(#type, RepositoryCommandAdd)); \
+\
+ name[2] = "remove"; \
+ CLICommand::Register(name, new RepositoryObjectCommand(#type, RepositoryCommandRemove)); \
+\
+ name[2] = "list"; \
+ CLICommand::Register(name, new RepositoryObjectCommand(#type, RepositoryCommandList)); \
+ } \
+ INITIALIZE_ONCE(RegisterCommand); \
+ } } }
}
static DbTypeRegistry *GetInstance(void);
};
-/**
- * Helper class for registering DynamicObject implementation classes.
- *
- * @ingroup ido
- */
-class RegisterDbTypeHelper
-{
-public:
- RegisterDbTypeHelper(const String& name, const String& table, long tid, const String& idcolumn, const DbType::ObjectFactory& factory)
- {
- DbType::Ptr dbtype;
-
- dbtype = DbType::GetByID(tid);
-
- if (!dbtype)
- dbtype = new DbType(table, tid, idcolumn, factory);
-
- DbType::RegisterType(name, dbtype);
- }
-};
-
/**
* Factory function for DbObject-based classes.
*
}
#define REGISTER_DBTYPE(name, table, tid, idcolumn, type) \
- I2_EXPORT icinga::RegisterDbTypeHelper g_RegisterDBT_ ## name(#name, table, tid, idcolumn, DbObjectFactory<type>);
+ namespace { namespace UNIQUE_NAME(ido) { namespace ido ## name { \
+ void RegisterDbType(void) \
+ { \
+ DbType::Ptr dbtype = new DbType(table, tid, idcolumn, DbObjectFactory<type>); \
+ DbType::RegisterType(#name, dbtype); \
+ } \
+ INITIALIZE_ONCE(RegisterDbType); \
+ } } }
}
return m_Callback(origin, arguments);
}
-RegisterApiFunctionHelper::RegisterApiFunctionHelper(const String& name, const ApiFunction::Callback& function)
-{
- ApiFunction::Ptr func = new ApiFunction(function);
- ApiFunctionRegistry::GetInstance()->Register(name, func);
-}
-
ApiFunction::Ptr ApiFunction::GetByName(const String& name)
{
return ApiFunctionRegistry::GetInstance()->GetItem(name);
};
#define REGISTER_APIFUNCTION(name, ns, callback) \
- I2_EXPORT icinga::RegisterApiFunctionHelper g_RegisterAF_ ## name(#ns "::" #name, callback)
+ namespace { namespace UNIQUE_NAME(apif) { namespace apif ## name { \
+ void RegisterFunction(void) \
+ { \
+ ApiFunction::Ptr func = new ApiFunction(callback); \
+ ApiFunctionRegistry::GetInstance()->Register(#ns "::" #name, func); \
+ } \
+ INITIALIZE_ONCE(RegisterFunction); \
+ } } }
}