Added some code remarks
authorThomas Jarosch <thomas.jarosch@intra2net.com>
Mon, 10 Aug 2009 08:13:45 +0000 (10:13 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Mon, 10 Aug 2009 08:24:41 +0000 (10:24 +0200)
src/config.h
src/dhs.cpp
src/dhs.h
src/main.cpp
src/ods.h
src/updater.cpp
src/updater.h

index 136dbea..a987930 100644 (file)
@@ -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 <boost/program_options.hpp>
 #include <boost/foreach.hpp>
 #include <boost/filesystem.hpp>
@@ -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<Service> ServicePtr;
 typedef boost::shared_ptr<Logger> LoggerPtr;
 typedef boost::shared_ptr<Serviceholder> 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;
index 1b3e0b3..2105c23 100644 (file)
@@ -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;
 }
index edda3f3..2c5ad8c 100644 (file)
--- 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&);
 };
index 4dbc914..ddf1950 100644 (file)
@@ -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;
index 60272db..c319552 100644 (file)
--- 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;
 
index 74b828c..46f2437 100644 (file)
@@ -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);
     }
index 66bd6a9..63ebce9 100644 (file)
@@ -15,6 +15,7 @@
 #include "config.h"
 #include "logger.h"
 
+// TODO: Global namespace? LoggerPtr will also clash with config.h
 typedef boost::shared_ptr<Config> ConfigPtr;
 typedef boost::shared_ptr<Logger> LoggerPtr;