From: Bjoern Sikora Date: Mon, 10 Aug 2009 10:50:02 +0000 (+0200) Subject: Fixed variable naming to I2N coding style. X-Git-Tag: v1.1~235 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=025abebba8db3312553ac6cc5f59606325263c6a;p=bpdyndnsd Fixed variable naming to I2N coding style. Now we have camel's as MemBer. _ .--' | / _ ^ | (_/ `\ | .--. .--. ) | / \ / \ / | /` ` '. | '-' / \ \ | |\ \ / \ /\| \ / `'-----'``.\ / ||| \\ | ((| ((| ||| ||| //_( //_( --- diff --git a/src/config.cpp b/src/config.cpp index 8281910..392e5cf 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -40,10 +40,10 @@ using namespace std; */ Config::Config(Logger::Ptr _log) : Log(new Logger) - , Daemon_mode(false) + , DaemonMode(false) , Loglevel(0) , Syslog(false) - , Config_path("/etc/bpdyndnsd") + , ConfigPath("/etc/bpdyndnsd") { // initialize Logger Log = _log; @@ -75,23 +75,23 @@ Config::Config(Logger::Ptr _log) // Define valid command line parameters Options_descriptionPtr _opt_desc_cmd(new po::options_description("Command line options")); - Opt_desc_cmd = _opt_desc_cmd; + OptDescCmd = _opt_desc_cmd; _opt_desc_cmd.reset(); - Opt_desc_cmd->add(opt_desc_cmd_only); - Opt_desc_cmd->add(opt_desc_generic); - Opt_desc_cmd->add(opt_desc_service); + OptDescCmd->add(opt_desc_cmd_only); + OptDescCmd->add(opt_desc_generic); + OptDescCmd->add(opt_desc_service); // Define valid config file options Options_descriptionPtr _opt_desc_conf_main(new po::options_description("Config file options")); - Opt_desc_conf_main = _opt_desc_conf_main; + OptDescConfMain = _opt_desc_conf_main; _opt_desc_conf_main.reset(); - Opt_desc_conf_main->add(opt_desc_generic); + OptDescConfMain->add(opt_desc_generic); // Define valid service file options Options_descriptionPtr _opt_desc_conf_service(new po::options_description("Service file options")); - Opt_desc_conf_service = _opt_desc_conf_service; + OptDescConfService = _opt_desc_conf_service; _opt_desc_conf_service.reset(); - Opt_desc_conf_service->add(opt_desc_service); + OptDescConfService->add(opt_desc_service); } @@ -104,7 +104,7 @@ Config::~Config() /** - * This function serializes all Service objects in Services and Old_services (where the update Timeout isn't expired) into a specified file. + * This function serializes all Service objects in Services and OldServices (where the update Timeout isn't expired) into a specified file. * @return 0 if all is fine, -1 otherwise. */ int Config::serialize_services() @@ -122,7 +122,7 @@ int Config::serialize_services() int current_time = time(NULL); - BOOST_FOREACH(Service::Ptr service, Old_services) + BOOST_FOREACH(Service::Ptr service, OldServices) { if ( ( service->get_lastupdated() + service->get_timeout() ) >= current_time ) // Update Timeout of service isn't expired. service_holder->add_service(service); @@ -174,13 +174,13 @@ int Config::deserialize_services() BOOST_FOREACH(Service::Ptr old_service, _old_services) { // Put the deserialized service into the Old_service member list. - Old_services.push_back(old_service); + OldServices.push_back(old_service); Log->print_service_object("Deserialized following Service object:", old_service->get_protocol(), old_service->get_hostname(), old_service->get_login() ,old_service->get_password() ,old_service->get_actual_ip(), old_service->get_lastupdated()); } BOOST_FOREACH(Service::Ptr service, Services) { - BOOST_FOREACH(Service::Ptr old_service, Old_services) + BOOST_FOREACH(Service::Ptr old_service, OldServices) { if ( *service == *old_service ) { @@ -193,7 +193,7 @@ int Config::deserialize_services() } } } - //TODO: debug output of Old_services (is element really removed from list if values were adopted???) + //TODO: debug output of OldServices (is element really removed from list if values were adopted???) Log->print_deserialized_objects_success(); } else @@ -215,28 +215,28 @@ int Config::parse_cmd_line(int argc, char *argv[]) { try { - po::store(po::parse_command_line(argc, argv, *this->Opt_desc_cmd), Variables_map); - po::notify(Variables_map); + po::store(po::parse_command_line(argc, argv, *this->OptDescCmd), VariablesMap); + po::notify(VariablesMap); - if ( Variables_map.count("help") ) + if ( VariablesMap.count("help") ) { - Log->print_usage(Opt_desc_cmd); + Log->print_usage(OptDescCmd); return 1; } - else if ( Variables_map.count("version") ) + else if ( VariablesMap.count("version") ) { Log->print_version(); return 1; } // Create a service object if all needed options are set on the command line - if ( Variables_map.count("protocol") && Variables_map.count("host") && Variables_map.count("login") && Variables_map.count("password") ) + if ( VariablesMap.count("protocol") && VariablesMap.count("host") && VariablesMap.count("login") && VariablesMap.count("password") ) { // Get the cmd parameter values for protocol host login and password - string protocol = Variables_map["protocol"].as(); - string host = Variables_map["host"].as(); - string login = Variables_map["login"].as(); - string password = Variables_map["password"].as(); + string protocol = VariablesMap["protocol"].as(); + string host = VariablesMap["host"].as(); + string login = VariablesMap["login"].as(); + string password = VariablesMap["password"].as(); //TODO: convert protocol option to lowercase @@ -246,36 +246,36 @@ int Config::parse_cmd_line(int argc, char *argv[]) else return 1; } - else if ( Variables_map.count("protocol") || Variables_map.count("host") || Variables_map.count("login") || Variables_map.count("password") ) + else if ( VariablesMap.count("protocol") || VariablesMap.count("host") || VariablesMap.count("login") || VariablesMap.count("password") ) { Log->print_missing_cmd_service_option(); - Log->print_usage(Opt_desc_cmd); + Log->print_usage(OptDescCmd); return 1; } - if ( Variables_map.count("config") ) + if ( VariablesMap.count("config") ) { - fs::path full_config_path = fs::system_complete(fs::path(Variables_map["config"].as())); - Config_path = full_config_path.string(); + fs::path full_config_path = fs::system_complete(fs::path(VariablesMap["config"].as())); + ConfigPath = full_config_path.string(); if ( !fs::exists(full_config_path) || !fs::is_directory(full_config_path) ) { // Config path doesn't exist or is not a directory - Log->print_error_config_path(Config_path); + Log->print_error_config_path(ConfigPath); return 1; } } - if ( Variables_map.count("loglevel") ) - Loglevel = Variables_map["loglevel"].as(); + if ( VariablesMap.count("loglevel") ) + Loglevel = VariablesMap["loglevel"].as(); - if ( Variables_map.count("syslog") ) - Syslog = Variables_map["syslog"].as(); + if ( VariablesMap.count("syslog") ) + Syslog = VariablesMap["syslog"].as(); } catch(po::unknown_option e) { Log->print_unknown_cmd_option(e.what()); - Log->print_usage(Opt_desc_cmd); + Log->print_usage(OptDescCmd); return 1; } return 0; @@ -326,7 +326,7 @@ int Config::load_service_config_file(const string& full_filename) try { po::variables_map vm; - po::parsed_options parsed_service_options = po::parse_config_file(service_config_file,*this->Opt_desc_conf_service,true); + po::parsed_options parsed_service_options = po::parse_config_file(service_config_file,*this->OptDescConfService,true); po::store(parsed_service_options,vm); po::notify(vm); @@ -382,15 +382,15 @@ int Config::load_main_config_file(const string& full_filename) { try { - po::parsed_options parsed_main_options = po::parse_config_file(main_config_file,*this->Opt_desc_conf_main,true); - po::store(parsed_main_options,Variables_map); - po::notify(Variables_map); + po::parsed_options parsed_main_options = po::parse_config_file(main_config_file,*this->OptDescConfMain,true); + po::store(parsed_main_options,VariablesMap); + po::notify(VariablesMap); - if(Variables_map.count("daemon_mode") && Variables_map.count("loglevel") && Variables_map.count("syslog")) + if(VariablesMap.count("daemon_mode") && VariablesMap.count("loglevel") && VariablesMap.count("syslog")) { - Daemon_mode = Variables_map["daemon_mode"].as(); - Loglevel = Variables_map["loglevel"].as(); - Syslog = Variables_map["syslog"].as(); + DaemonMode = VariablesMap["daemon_mode"].as(); + Loglevel = VariablesMap["loglevel"].as(); + Syslog = VariablesMap["syslog"].as(); } } catch ( po::unknown_option e ) // at the moment 04-08-2009 this exception is never thrown :-( @@ -419,7 +419,7 @@ int Config::load_main_config_file(const string& full_filename) */ int Config::load_config_from_files() { - fs::path full_config_path = fs::path(Config_path); + fs::path full_config_path = fs::path(ConfigPath); fs::directory_iterator end_iter; for ( fs::directory_iterator dir_itr(full_config_path) ; dir_itr != end_iter ; ++dir_itr ) @@ -446,7 +446,7 @@ int Config::load_config_from_files() } } // Config file successfully loaded - Log->print_conf_loaded(Config_path); + Log->print_conf_loaded(ConfigPath); return 0; } @@ -462,32 +462,32 @@ list Config::get_services() /** - * Getter method for member Opt_desc_cmd. + * Getter method for member OptDescCmd. * @return options_description*. */ Config::Options_descriptionPtr Config::get_opt_desc_cmd() { - return Opt_desc_cmd; + return OptDescCmd; } /** - * Getter method for member Opt_desc_conf_main. + * Getter method for member OptDescConfMain. * @return options_description*. */ Config::Options_descriptionPtr Config::get_opt_desc_conf_main() { - return Opt_desc_conf_main; + return OptDescConfMain; } /** - * Getter method for member Opt_desc_conf_service. + * Getter method for member OptDescConfService. * @return options_description*. */ Config::Options_descriptionPtr Config::get_opt_desc_conf_service() { - return Opt_desc_conf_service; + return OptDescConfService; } @@ -502,12 +502,12 @@ int Config::get_loglevel() /** - * Getter for member Daemon_mode. + * Getter for member DaemonMode. * @return TRUE if enabled, FALSE if disabled. */ bool Config::get_daemon_mode() { - return Daemon_mode; + return DaemonMode; } @@ -530,10 +530,10 @@ void Config::delete_services() */ void Config::delete_variables_map() { - Variables_map.clear(); + VariablesMap.clear(); po::variables_map _variables_map; - Variables_map = _variables_map; + VariablesMap = _variables_map; } diff --git a/src/config.h b/src/config.h index 076c3d0..c9a6985 100644 --- a/src/config.h +++ b/src/config.h @@ -25,21 +25,21 @@ private: typedef boost::shared_ptr Options_descriptionPtr; - Options_descriptionPtr Opt_desc_cmd; - Options_descriptionPtr Opt_desc_conf_main; - Options_descriptionPtr Opt_desc_conf_service; + Options_descriptionPtr OptDescCmd; + Options_descriptionPtr OptDescConfMain; + Options_descriptionPtr OptDescConfService; - boost::program_options::variables_map Variables_map; + boost::program_options::variables_map VariablesMap; std::list Services; // Represents all active Services. - std::list Old_services; // Represents all old Services where the timeout isn't expired (in case the same Service is redefined). + std::list OldServices; // Represents all old Services where the timeout isn't expired (in case the same Service is redefined). Logger::Ptr Log; - bool Daemon_mode; + bool DaemonMode; int Loglevel; bool Syslog; - std::string Config_path; + std::string ConfigPath; Service::Ptr create_service(const std::string&,const std::string&,const std::string&,const std::string&); int load_main_config_file(const std::string&); diff --git a/src/dhs.cpp b/src/dhs.cpp index 1b3e785..77950ca 100644 --- a/src/dhs.cpp +++ b/src/dhs.cpp @@ -19,8 +19,8 @@ using namespace std; */ DHS::DHS() : Timeout(0) - , Max_updates_per_timeout(0) - , Updates_within_timeout(0) + , MaxUpdatesWithinTimeout(0) + , ActualUpdatesWithinTimeout(0) { } @@ -33,8 +33,8 @@ DHS::DHS() */ DHS::DHS(const string& _protocol, const string& _hostname, const string& _login, const string& _password, const Logger::Ptr& _logger, const int _lastupdated, const int _timeout, const int _max_updates_per_timeout) : Timeout(_timeout) - , Max_updates_per_timeout(_max_updates_per_timeout) - , Updates_within_timeout(1) + , MaxUpdatesWithinTimeout(_max_updates_per_timeout) + , ActualUpdatesWithinTimeout(0) { set_protocol(_protocol); set_hostname(_hostname); @@ -77,8 +77,8 @@ void DHS::serialize(Archive & ar, const unsigned int version) { ar & boost::serialization::base_object(*this); ar & Timeout; - ar & Max_updates_per_timeout; - ar & Updates_within_timeout; + ar & MaxUpdatesWithinTimeout; + ar & ActualUpdatesWithinTimeout; } @@ -103,20 +103,20 @@ int DHS::get_timeout() /** - * Setter for member Max_updates_per_timeout. - * @param _max_updates_per_timeout Value to set Max_updates_per_timeout to. + * Setter for member MaxUpdatesWithinTimeout. + * @param _max_updates_per_timeout Value to set MaxUpdatesWithinTimeout to. */ void DHS::set_max_updates_per_timeout(const int _max_updates_per_timeout) { - Max_updates_per_timeout = _max_updates_per_timeout; + MaxUpdatesWithinTimeout = _max_updates_per_timeout; } /** - * Getter for member Max_updates_per_timeout. - * @return Value of Max_updates_per_timeout. + * Getter for member MaxUpdatesWithinTimeout. + * @return Value of MaxUpdatesWithinTimeout. */ int DHS::get_max_updates_per_timeout() const { - return Max_updates_per_timeout; + return MaxUpdatesWithinTimeout; } diff --git a/src/dhs.h b/src/dhs.h index 5b30e0a..7cc403e 100644 --- a/src/dhs.h +++ b/src/dhs.h @@ -25,9 +25,8 @@ class DHS : public Service private: int Timeout; - // TODO: Fix variable naming - int Max_updates_per_timeout; - int Updates_within_timeout; + int MaxUpdatesWithinTimeout; + int ActualUpdatesWithinTimeout; friend class boost::serialization::access; template diff --git a/src/ods.cpp b/src/ods.cpp index 5c43c94..0e6930e 100644 --- a/src/ods.cpp +++ b/src/ods.cpp @@ -19,8 +19,8 @@ using namespace std; */ ODS::ODS() : Timeout(0) - , Max_updates_per_timeout(0) - , Updates_within_timeout(0) + , MaxUpdatesWithinTimeout(0) + , ActualUpdatesWithinTimeout(0) { } @@ -32,11 +32,10 @@ ODS::ODS() * @param _password The corresponding password. */ ODS::ODS(const string& _protocol, const string& _hostname, const string& _login, const string& _password, const Logger::Ptr& _logger, const int _lastupdated, const int _timeout, const int _max_updates_per_timeout) - : Updates_within_timeout(1) + : Timeout(_timeout) + , MaxUpdatesWithinTimeout(_max_updates_per_timeout) + , ActualUpdatesWithinTimeout(0) { - Timeout = _timeout; - Max_updates_per_timeout = _max_updates_per_timeout; - set_protocol(_protocol); set_hostname(_hostname); set_login(_login); @@ -78,8 +77,8 @@ void ODS::serialize(Archive & ar, const unsigned int version) { ar & boost::serialization::base_object(*this); ar & Timeout; - ar & Max_updates_per_timeout; - ar & Updates_within_timeout; + ar & MaxUpdatesWithinTimeout; + ar & ActualUpdatesWithinTimeout; } @@ -107,9 +106,9 @@ int ODS::get_timeout() * Setter for member Max_updates_per_timeout. * @param _max_updates_per_timeout Value to set Max_updates_per_timeout to. */ -void ODS::set_max_updates_per_timeout(const int _max_updates_per_timeout) +void ODS::set_max_updates_within_timeout(const int _max_updates_per_timeout) { - Max_updates_per_timeout = _max_updates_per_timeout; + MaxUpdatesWithinTimeout = _max_updates_per_timeout; } @@ -117,7 +116,7 @@ void ODS::set_max_updates_per_timeout(const int _max_updates_per_timeout) * Getter for member Max_updates_per_timeout. * @return Value of Max_updates_per_timeout. */ -int ODS::get_max_updates_per_timeout() +int ODS::get_max_updates_within_timeout() { - return Max_updates_per_timeout; + return MaxUpdatesWithinTimeout; } diff --git a/src/ods.h b/src/ods.h index f2a7f75..dab37f2 100644 --- a/src/ods.h +++ b/src/ods.h @@ -25,9 +25,8 @@ class ODS : public Service private: int Timeout; - // TODO: Fix variable naming - int Max_updates_per_timeout; - int Updates_within_timeout; + int MaxUpdatesWithinTimeout; + int ActualUpdatesWithinTimeout; friend class boost::serialization::access; template @@ -46,8 +45,8 @@ public: void set_timeout(const int); int get_timeout(); - void set_max_updates_per_timeout(const int); - int get_max_updates_per_timeout(); + void set_max_updates_within_timeout(const int); + int get_max_updates_within_timeout(); void update(const std::string&); }; diff --git a/src/service.cpp b/src/service.cpp index d015a26..009aad3 100644 --- a/src/service.cpp +++ b/src/service.cpp @@ -18,7 +18,7 @@ Service::Service() , Hostname("") , Login("NOT SERIALIZED") , Password("NOT SERIALIZED") - , Actual_IP("0.0.0.0") + , ActualIP("0.0.0.0") , Lastupdated(0) , Log(new Logger()) { @@ -46,7 +46,7 @@ void Service::serialize(Archive & ar, const unsigned int version) ar & Hostname; // lastupdated and actual_ip must also be serialized, cause these are essential infos of each service. ar & Lastupdated; - ar & Actual_IP; + ar & ActualIP; } @@ -171,22 +171,22 @@ int Service::get_lastupdated() /** - * Setter for member Actual_IP. - * @param _actual_ip Value to set Actual_IP to. + * Setter for member ActualIP. + * @param _actual_ip Value to set ActualIP to. */ void Service::set_actual_ip(const std::string& _actual_ip) { - Actual_IP = _actual_ip; + ActualIP = _actual_ip; } /** - * Getter for member Actual_IP. - * @return Value of member Actual_IP. + * Getter for member ActualIP. + * @return Value of member ActualIP. */ std::string Service::get_actual_ip() { - return Actual_IP; + return ActualIP; } diff --git a/src/service.h b/src/service.h index 1b7e8f9..a996f63 100644 --- a/src/service.h +++ b/src/service.h @@ -28,7 +28,7 @@ private: std::string Login; std::string Password; - std::string Actual_IP; + std::string ActualIP; int Lastupdated; diff --git a/src/serviceholder.cpp b/src/serviceholder.cpp index 4f21ffb..8d620e6 100644 --- a/src/serviceholder.cpp +++ b/src/serviceholder.cpp @@ -39,7 +39,7 @@ Serviceholder::~Serviceholder() template void Serviceholder::serialize(Archive & ar, const unsigned int version) { - ar & Hold_services; + ar & HoldServices; } @@ -49,7 +49,7 @@ void Serviceholder::serialize(Archive & ar, const unsigned int version) */ void Serviceholder::add_service(Service::Ptr service) { - Hold_services.push_back(service); + HoldServices.push_back(service); } @@ -59,5 +59,5 @@ void Serviceholder::add_service(Service::Ptr service) */ std::list Serviceholder::get_hold_services() { - return Hold_services; + return HoldServices; } diff --git a/src/serviceholder.h b/src/serviceholder.h index bce8006..a46d2b8 100644 --- a/src/serviceholder.h +++ b/src/serviceholder.h @@ -23,10 +23,9 @@ class Serviceholder private: - friend class boost::serialization::access; - - std::list Hold_services; + std::list HoldServices; + friend class boost::serialization::access; template void serialize(Archive &, const unsigned int);