From: JINMEI Tatuya Date: Wed, 3 Oct 2012 03:38:31 +0000 (-0700) Subject: [2203] changed the callback type of addRemoteConfig to boost::function. X-Git-Tag: trac2402_base^2~16^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4fa694dbee3372b8c310aca2c2dafc3ca7550e80;p=thirdparty%2Fkea.git [2203] changed the callback type of addRemoteConfig to boost::function. this will make it more convenient, e.g., by allowing the caller to pass boost::bind encapsulating a class object and a class method. boost::function is upper compatible to function pointer, so it doesn't ensure source-level compatibility. the functor overhead shouldn't matter in this context, and since this module already uses boost::function this change doesn't introduce additional dependency. --- diff --git a/src/lib/config/ccsession.cc b/src/lib/config/ccsession.cc index daec005dda..8516d6c863 100644 --- a/src/lib/config/ccsession.cc +++ b/src/lib/config/ccsession.cc @@ -338,7 +338,7 @@ getRelatedLoggers(ConstElementPtr loggers) { // Now find the wildcard names (the one that start with "*"). BOOST_FOREACH(ConstElementPtr cur_logger, loggers->listValue()) { - std::string cur_name = cur_logger->get("name")->stringValue(); + const std::string cur_name = cur_logger->get("name")->stringValue(); // If name is '*', or starts with '*.', replace * with root // logger name. if (cur_name == "*" || cur_name.length() > 1 && @@ -671,9 +671,7 @@ ModuleCCSession::fetchRemoteSpec(const std::string& module, bool is_filename) { std::string ModuleCCSession::addRemoteConfig(const std::string& spec_name, - void (*handler)(const std::string& module, - ConstElementPtr, - const ConfigData&), + RemoteHandler handler, bool spec_is_filename) { // First get the module name, specification and default config diff --git a/src/lib/config/ccsession.h b/src/lib/config/ccsession.h index e96a33d44b..4b99a44bd8 100644 --- a/src/lib/config/ccsession.h +++ b/src/lib/config/ccsession.h @@ -283,7 +283,7 @@ public: * the configuration manager must know it). If * spec_is_filename is true (the default), then a * filename is assumed, otherwise a module name. - * \param handler The handler function called whenever there's a change. + * \param handler The handler functor called whenever there's a change. * Called once initally from this function. May be NULL * if you don't want any handler to be called and you're * fine with requesting the data through @@ -296,11 +296,11 @@ public: * \return The name of the module specified in the given specification * file */ + typedef boost::function RemoteHandler; std::string addRemoteConfig(const std::string& spec_name, - void (*handler)(const std::string& module_name, - isc::data::ConstElementPtr - update, - const ConfigData& config_data) = NULL, + RemoteHandler handler = RemoteHandler(), bool spec_is_filename = true); /** @@ -513,9 +513,6 @@ private: const std::string& command, isc::data::ConstElementPtr args); - typedef void (*RemoteHandler)(const std::string&, - isc::data::ConstElementPtr, - const ConfigData&); std::map remote_module_configs_; std::map remote_module_handlers_;