From: Thomas Jarosch Date: Mon, 10 Aug 2009 08:13:45 +0000 (+0200) Subject: Added some code remarks X-Git-Tag: v1.1~240 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=b011a02ab38b75e193b68fd60c591b57faca49ca;p=bpdyndnsd Added some code remarks --- diff --git a/src/config.h b/src/config.h index 136dbea..a987930 100644 --- a/src/config.h +++ b/src/config.h @@ -10,6 +10,8 @@ #ifndef CONFIG_H #define CONFIG_H +// TODO: Only include needed header files in "config.h". +// Include the rest in config.cpp #include #include #include @@ -33,6 +35,7 @@ #include "dhs.h" #include "ods.h" +// TODO: What about putting this in the Logger/Service namespace instead of the global one? typedef boost::shared_ptr ServicePtr; typedef boost::shared_ptr LoggerPtr; typedef boost::shared_ptr ServiceholderPtr; @@ -42,7 +45,6 @@ class Config { private: - Options_descriptionPtr Opt_desc_cmd; Options_descriptionPtr Opt_desc_conf_main; Options_descriptionPtr Opt_desc_conf_service; diff --git a/src/dhs.cpp b/src/dhs.cpp index 1b3e0b3..2105c23 100644 --- a/src/dhs.cpp +++ b/src/dhs.cpp @@ -30,11 +30,10 @@ DHS::DHS() * @param _password The corresponding password. */ DHS::DHS(const string& _protocol, const string& _hostname, const string& _login, const string& _password, const LoggerPtr& _logger, const int _lastupdated, const int _timeout, const int _max_updates_per_timeout) - : Updates_within_timeout(1) + : Timeout(_timeout) + , Max_updates_per_timeout(_max_updates_per_timeout) + , Updates_within_timeout(1) { - Timeout = _timeout; - Max_updates_per_timeout = _max_updates_per_timeout; - set_protocol(_protocol); set_hostname(_hostname); set_login(_login); @@ -115,7 +114,7 @@ void DHS::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 DHS::get_max_updates_per_timeout() +int DHS::get_max_updates_per_timeout() const { return Max_updates_per_timeout; } diff --git a/src/dhs.h b/src/dhs.h index edda3f3..2c5ad8c 100644 --- a/src/dhs.h +++ b/src/dhs.h @@ -24,6 +24,7 @@ class DHS : public Service { private: int Timeout; + // TODO: Fix variable naming int Max_updates_per_timeout; int Updates_within_timeout; @@ -43,7 +44,7 @@ public: int get_timeout(); void set_max_updates_per_timeout(const int); - int get_max_updates_per_timeout(); + int get_max_updates_per_timeout() const; void update(const std::string&); }; diff --git a/src/main.cpp b/src/main.cpp index 4dbc914..ddf1950 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -113,6 +113,7 @@ void terminate(int param) void switch_to_offline(int param) { updater->get_logger()->print_caught_siguser1(); + // TODO: How about using an enum for online_mode instead of magic numbers? online_mode = 0; } @@ -162,6 +163,8 @@ int main(int argc, char *argv[]) updater = _updater; _updater.reset(); + // TODO: Why do errors return zero exit status? + // load the cmd options if ( updater->init_config_from_cmd(argc,argv) != 0 ) return 0; diff --git a/src/ods.h b/src/ods.h index 60272db..c319552 100644 --- a/src/ods.h +++ b/src/ods.h @@ -24,6 +24,7 @@ class ODS : public Service { private: int Timeout; + // TODO: Fix variable naming int Max_updates_per_timeout; int Updates_within_timeout; diff --git a/src/updater.cpp b/src/updater.cpp index 74b828c..46f2437 100644 --- a/src/updater.cpp +++ b/src/updater.cpp @@ -113,6 +113,7 @@ void Updater::reload_config() Conf->delete_variables_map(); // load only config files + // TODO: Error handling? init_config_from_files(); } @@ -136,7 +137,7 @@ void Updater::update_services() string ip = "192.168.1.1"; - BOOST_FOREACH( ServicePtr service, services ) + BOOST_FOREACH(ServicePtr &service, services ) { service->update(ip); } diff --git a/src/updater.h b/src/updater.h index 66bd6a9..63ebce9 100644 --- a/src/updater.h +++ b/src/updater.h @@ -15,6 +15,7 @@ #include "config.h" #include "logger.h" +// TODO: Global namespace? LoggerPtr will also clash with config.h typedef boost::shared_ptr ConfigPtr; typedef boost::shared_ptr LoggerPtr;