#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>
#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;
{
private:
-
Options_descriptionPtr Opt_desc_cmd;
Options_descriptionPtr Opt_desc_conf_main;
Options_descriptionPtr Opt_desc_conf_service;
* @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);
* 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;
}
{
private:
int Timeout;
+ // TODO: Fix variable naming
int Max_updates_per_timeout;
int Updates_within_timeout;
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&);
};
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;
}
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;
{
private:
int Timeout;
+ // TODO: Fix variable naming
int Max_updates_per_timeout;
int Updates_within_timeout;
Conf->delete_variables_map();
// load only config files
+ // TODO: Error handling?
init_config_from_files();
}
string ip = "192.168.1.1";
- BOOST_FOREACH( ServicePtr service, services )
+ BOOST_FOREACH(ServicePtr &service, services )
{
service->update(ip);
}
#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;