* Default Constructor. Available command line and config file options with their default values are defined here.
*/
Config::Config(LoggerPtr _log)
- : Daemon_mode(false)
+ : Log(new Logger)
+ , Daemon_mode(false)
, Loglevel(0)
, Syslog(false)
, Config_path("/etc/bpdyndnsd")
// Define valid service file options
Opt_desc_conf_service = new po::options_description("Service file options");
Opt_desc_conf_service->add(opt_desc_service);
-
- Log->print_constructor_call("Config");
}
delete Opt_desc_cmd;
delete Opt_desc_conf_main;
delete Opt_desc_conf_service;
-
- Log->print_destructor_call("Config");
}
BOOST_FOREACH(ServicePtr service, Services)
{
- service_holder->add_service(service.get());
+ service_holder->add_service(service);
}
// Then we can serialize this separate Object into one file.
ServiceholderPtr service_holder(_service_holder);
ifs.close();
- list<Service*> old_services = service_holder->get_hold_services();
+ list<ServicePtr> old_services = service_holder->get_hold_services();
- BOOST_FOREACH(Service* old_service, old_services)
+ BOOST_FOREACH(ServicePtr old_service, old_services)
{
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(ServicePtr service_ptr, Services)
+ BOOST_FOREACH(ServicePtr service, Services)
{
- Service * service = service_ptr.get();
- BOOST_FOREACH(Service* old_service, old_services)
+ BOOST_FOREACH(ServicePtr old_service, old_services)
{
if ( *service == *old_service )
{
service->set_lastupdated(old_service->get_lastupdated());
service->set_actual_ip(old_service->get_actual_ip());
- Log->print_service_object("New Service object with adopted values:", service_ptr->get_protocol(), service_ptr->get_hostname(), service_ptr->get_login() ,service_ptr->get_password() ,service_ptr->get_actual_ip(), service_ptr->get_lastupdated());
+ Log->print_service_object("New Service object with adopted values:", service->get_protocol(), service->get_hostname(), service->get_login() ,service->get_password() ,service->get_actual_ip(), service->get_lastupdated());
}
}
}
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/export.hpp>
+#include <boost/serialization/shared_ptr.hpp>
#include <string>
#include <iostream>
LoggerPtr Log;
bool Daemon_mode;
- std::string Logfile;
int Loglevel;
bool Syslog;
std::string Config_path;
* Default Constructor, needed for object serialization.
*/
DHS::DHS()
+ : Timeout(0)
+ , Max_updates_per_timeout(0)
{
}
set_password(_password);
set_logger(_logger);
set_lastupdated(_lastupdated);
-
- get_logger()->print_constructor_call("DHS");
}
*/
DHS::~DHS()
{
- get_logger()->print_destructor_call("DHS");
}
*/
Logger::Logger()
: Loglevel(0)
- , Syslog(0)
+ , Syslog(false)
{
set_log_facility(Loglevel,Syslog);
- print_constructor_call("Logger");
}
*/
Logger::~Logger()
{
- print_destructor_call("Logger");
}
void Logger::set_loglevel(const int _loglevel)
{
Loglevel = _loglevel;
+ cout << "Loglevel set" << endl;
}
* Default Constructor, needed for object serialization.
*/
ODS::ODS()
+ : Timeout(0)
+ , Max_updates_per_timeout(0)
{
}
set_password(_password);
set_logger(_logger);
set_lastupdated(_lastupdated);
-
- get_logger()->print_constructor_call("ODS");
}
*/
ODS::~ODS()
{
- get_logger()->print_destructor_call("ODS");
}
, Hostname("")
, Login("NOT SERIALIZED")
, Password("NOT SERIALIZED")
- , Lastupdated(0)
, Actual_IP("0.0.0.0")
+ , Lastupdated(0)
+ , Log(new Logger())
{
}
* Add Service * to internal list.
* @param service Pointer to Service object.
*/
-void Serviceholder::add_service(Service * service)
+void Serviceholder::add_service(ServicePtr service)
{
Hold_services.push_back(service);
}
* Needed after deserialization to get the valid list of Service* back.
* @return The list of Service*.
*/
-std::list<Service*> Serviceholder::get_hold_services()
+std::list<ServicePtr> Serviceholder::get_hold_services()
{
return Hold_services;
}
#include <list>
#include "service.h"
-#include "logger.h"
#include <boost/serialization/array.hpp>
#include <boost/serialization/list.hpp>
#include <boost/shared_ptr.hpp>
-typedef boost::shared_ptr<Logger> LoggerPtr;
+typedef boost::shared_ptr<Service> ServicePtr;
class Serviceholder
{
private:
friend class boost::serialization::access;
- std::list<Service*> Hold_services;
+ std::list<ServicePtr> Hold_services;
template<class Archive>
void serialize(Archive &, const unsigned int);
- int Test;
-
public:
Serviceholder();
~Serviceholder();
- void add_service(Service *);
+ void add_service(ServicePtr);
- std::list<Service*> get_hold_services();
+ std::list<ServicePtr> get_hold_services();
};
#endif
*/
Updater::Updater()
{
- // initialize Logger
+ // Initialize program wide Logger, at this point we don't know where to log and with which loglevel.
LoggerPtr _log(new Logger);
Log = _log;
// initialize Config
ConfigPtr _config(new Config(Log));
Conf = _config;
-
- Log->print_constructor_call("Updater");
}
*/
Updater::~Updater()
{
- Log->print_destructor_call("Updater");
}