Corrected include's in header files.
authorBjoern Sikora <bjoern.sikora@intra2net.com>
Mon, 10 Aug 2009 10:25:41 +0000 (12:25 +0200)
committerBjoern Sikora <bjoern.sikora@intra2net.com>
Mon, 10 Aug 2009 10:25:41 +0000 (12:25 +0200)
Corrected typedef's in header files.

15 files changed:
src/config.cpp
src/config.h
src/dhs.cpp
src/dhs.h
src/logger.cpp
src/logger.h
src/main.cpp
src/ods.cpp
src/ods.h
src/service.cpp
src/service.h
src/serviceholder.cpp
src/serviceholder.h
src/updater.cpp
src/updater.h

index 62a0369..8281910 100644 (file)
@@ -9,6 +9,23 @@
 
 #include "config.h"
 
+#include "serviceholder.h"
+#include "dhs.h"
+#include "ods.h"
+
+#include <time.h>
+#include <iostream>
+#include <fstream>
+
+#include <boost/foreach.hpp>
+#include <boost/filesystem.hpp>
+#include <boost/regex.hpp>
+#include <boost/archive/text_oarchive.hpp>
+#include <boost/archive/text_iarchive.hpp>
+#include <boost/archive/archive_exception.hpp>
+#include <boost/serialization/export.hpp>
+#include <boost/serialization/shared_ptr.hpp>
+
 // Following boost macros are needed for serialization of derived classes through a base class pointer (Service *).
 BOOST_CLASS_EXPORT_GUID(ODS, "ODS")
 BOOST_CLASS_EXPORT_GUID(DHS, "DHS")
@@ -21,7 +38,7 @@ using namespace std;
 /**
  * Default Constructor. Available command line and config file options with their default values are defined here.
  */
-Config::Config(LoggerPtr _log)
+Config::Config(Logger::Ptr _log)
     : Log(new Logger)
     , Daemon_mode(false)
     , Loglevel(0)
@@ -96,16 +113,16 @@ int Config::serialize_services()
 
     // First of all we have to put all Service objects in a Serviceholder object.
 
-    ServiceholderPtr service_holder(new Serviceholder());
+    Serviceholder::Ptr service_holder(new Serviceholder());
 
-    BOOST_FOREACH(ServicePtr service, Services)
+    BOOST_FOREACH(Service::Ptr service, Services)
     {
         service_holder->add_service(service);
     }
 
     int current_time = time(NULL);
 
-    BOOST_FOREACH(ServicePtr service, Old_services)
+    BOOST_FOREACH(Service::Ptr service, Old_services)
     {
         if ( ( service->get_lastupdated() + service->get_timeout() ) >= current_time )  // Update Timeout of service isn't expired.
             service_holder->add_service(service);
@@ -122,7 +139,7 @@ int Config::serialize_services()
             boost::archive::text_oarchive oa(ofs);
             oa << _service_holder;
         }
-        catch( boost::archive_exception e )
+        catch( boost::archive::archive_exception e )
         {
             Log->print_exception_serialize(e.what());
             ofs.close();
@@ -149,21 +166,21 @@ int Config::deserialize_services()
         Serviceholder* _service_holder;
         boost::archive::text_iarchive ia(ifs);
         ia >> _service_holder;       // ends up in default constructor call for Serviceholder
-        ServiceholderPtr service_holder(_service_holder);
+        Serviceholder::Ptr service_holder(_service_holder);
         ifs.close();
 
-        list<ServicePtr> _old_services = service_holder->get_hold_services();
+        list<Service::Ptr> _old_services = service_holder->get_hold_services();
 
-        BOOST_FOREACH(ServicePtr old_service, _old_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);
             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, Services)
+        BOOST_FOREACH(Service::Ptr service, Services)
         {
-            BOOST_FOREACH(ServicePtr old_service, Old_services)
+            BOOST_FOREACH(Service::Ptr old_service, Old_services)
             {
                 if ( *service == *old_service )
                 {
@@ -223,7 +240,7 @@ int Config::parse_cmd_line(int argc, char *argv[])
 
             //TODO: convert protocol option to lowercase
 
-            ServicePtr service = create_service(protocol,host,login,password);
+            Service::Ptr service = create_service(protocol,host,login,password);
             if ( service )
                 Services.push_back(service);
             else
@@ -273,22 +290,22 @@ int Config::parse_cmd_line(int argc, char *argv[])
  * @param password 
  * @return A pointer to the created Service object.
  */
-ServicePtr Config::create_service(const string &protocol,const string &hostname, const string &login, const string &password)
+Service::Ptr Config::create_service(const string &protocol,const string &hostname, const string &login, const string &password)
 {
     if(protocol == "dhs")
     {
-        ServicePtr service_dhs(new DHS(protocol,hostname,login,password,Log,0,60,1));
+        Service::Ptr service_dhs(new DHS(protocol,hostname,login,password,Log,0,60,1));
         return service_dhs;
     }
     else if(protocol == "ods")
     {
-        ServicePtr service_ods(new ODS(protocol,hostname,login,password,Log,0,60,1));
+        Service::Ptr service_ods(new ODS(protocol,hostname,login,password,Log,0,60,1));
         return service_ods;
     }
     else
     {
         Log->print_unknown_protocol(protocol);
-        ServicePtr service;
+        Service::Ptr service;
         return service;
     }
 }
@@ -324,7 +341,7 @@ int Config::load_service_config_file(const string& full_filename)
                 // TODO: convert protocol to lowercase
                 //protocol = tolower(protocol.c_str());
 
-                ServicePtr service = create_service(protocol,host,login,password);
+                Service::Ptr service = create_service(protocol,host,login,password);
                 if ( service )
                 {
                     Services.push_back(service);
@@ -438,7 +455,7 @@ int Config::load_config_from_files()
  * Getter method for Service list member.
  * @return Pointer to a list of Service's.
  */
-list<ServicePtr> Config::get_services()
+list<Service::Ptr> Config::get_services()
 {
     return this->Services;
 }
@@ -448,7 +465,7 @@ list<ServicePtr> Config::get_services()
  * Getter method for member Opt_desc_cmd.
  * @return options_description*.
  */
-Options_descriptionPtr Config::get_opt_desc_cmd()
+Config::Options_descriptionPtr Config::get_opt_desc_cmd()
 {
     return Opt_desc_cmd;
 }
@@ -458,7 +475,7 @@ Options_descriptionPtr Config::get_opt_desc_cmd()
  * Getter method for member Opt_desc_conf_main.
  * @return options_description*.
  */
-Options_descriptionPtr Config::get_opt_desc_conf_main()
+Config::Options_descriptionPtr Config::get_opt_desc_conf_main()
 {
     return Opt_desc_conf_main;
 }
@@ -468,7 +485,7 @@ Options_descriptionPtr Config::get_opt_desc_conf_main()
  * Getter method for member Opt_desc_conf_service.
  * @return options_description*.
  */
-Options_descriptionPtr Config::get_opt_desc_conf_service()
+Config::Options_descriptionPtr Config::get_opt_desc_conf_service()
 {
     return Opt_desc_conf_service;
 }
@@ -499,7 +516,7 @@ bool Config::get_daemon_mode()
  */
 void Config::delete_services()
 {
-    BOOST_FOREACH( ServicePtr service, Services )
+    BOOST_FOREACH( Service::Ptr service, Services )
     {
         service.reset();
     }
index a987930..076c3d0 100644 (file)
 #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 <boost/regex.hpp>
-#include <boost/shared_ptr.hpp>
-#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>
-#include <fstream>
-
-#include <time.h>
 
 #include "service.h"
 #include "logger.h"
-#include "serviceholder.h"
 
-#include "dhs.h"
-#include "ods.h"
+#include <boost/program_options.hpp>
+#include <boost/shared_ptr.hpp>
 
-// 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;
-typedef boost::shared_ptr<boost::program_options::options_description> Options_descriptionPtr;
 
 class Config
 {
-
 private:
+
+    typedef boost::shared_ptr<boost::program_options::options_description> Options_descriptionPtr;
+
     Options_descriptionPtr Opt_desc_cmd;
     Options_descriptionPtr Opt_desc_conf_main;
     Options_descriptionPtr Opt_desc_conf_service;
+
     boost::program_options::variables_map Variables_map;
 
-    std::list<ServicePtr> Services;         // Represents all active Services.
-    std::list<ServicePtr> Old_services;     // Represents all old Services where the timeout isn't expired (in case the same Service is redefined).
+    std::list<Service::Ptr> Services;         // Represents all active Services.
+    std::list<Service::Ptr> Old_services;     // Represents all old Services where the timeout isn't expired (in case the same Service is redefined).
 
-    LoggerPtr Log;
+    Logger::Ptr Log;
 
     bool Daemon_mode;
     int Loglevel;
     bool Syslog;
     std::string Config_path;
 
-    ServicePtr create_service(const std::string&,const std::string&,const std::string&,const std::string&);
+    Service::Ptr create_service(const std::string&,const std::string&,const std::string&,const std::string&);
     int load_main_config_file(const std::string&);
     int load_service_config_file(const std::string&);
 
 public:
 
-    Config(LoggerPtr);
+    typedef boost::shared_ptr<Config> Ptr;
+
+    Config(Logger::Ptr);
 
     ~Config();
 
@@ -78,7 +61,7 @@ public:
 
     int load_config_from_files();
 
-    std::list<ServicePtr> get_services();
+    std::list<Service::Ptr> get_services();
 
     Options_descriptionPtr get_opt_desc_cmd();
 
index 2105c23..1b3e785 100644 (file)
@@ -9,6 +9,8 @@
 
 #include "dhs.h"
 
+#include <time.h>
+
 using namespace std;
 
 
@@ -29,7 +31,7 @@ DHS::DHS()
  * @param _login The login name.
  * @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)
+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)
index 2c5ad8c..5b30e0a 100644 (file)
--- a/src/dhs.h
+++ b/src/dhs.h
 #define DHS_H
 
 #include <string>
-#include <time.h>
 
 #include "service.h"
 #include "logger.h"
 
 #include <boost/serialization/array.hpp>
+#include <boost/shared_ptr.hpp>
 
-typedef boost::shared_ptr<Logger> LoggerPtr;
 
 class DHS : public Service
 {
+
 private:
+
     int Timeout;
     // TODO: Fix variable naming
     int Max_updates_per_timeout;
@@ -34,9 +35,11 @@ private:
 
 public:
 
+    typedef boost::shared_ptr<DHS> Ptr;
+
     DHS();
 
-    DHS(const std::string&, const std::string&, const std::string&, const std::string&, const LoggerPtr&, const int, const int, const int);
+    DHS(const std::string&, const std::string&, const std::string&, const std::string&, const Logger::Ptr&, const int, const int, const int);
 
     ~DHS();
 
index 0523442..e3499b2 100644 (file)
@@ -10,6 +10,9 @@
 
 #include "logger.h"
 
+#include <syslog.h>
+#include <sstream>
+
 namespace po = boost::program_options;
 
 using namespace std;
@@ -599,7 +602,7 @@ void Logger::print_service_object(const string& message, const string& protocol,
  * Caught exception while serialize.
  * @param exception Exception message.
  */
-void print_exception_serialize(const string& exception)
+void Logger::print_exception_serialize(const string& exception)
 {
     cout << "Error while trying to serialize Serviceholder object: " << exception << endl;
 }
index 471fa4e..caf7083 100644 (file)
 #ifndef LOGGER_H
 #define LOGGER_H
 
-#include <syslog.h>
-#include <sstream>
-
-typedef boost::shared_ptr<boost::program_options::options_description> Options_descriptionPtr;
+#include <string>
 
+#include <boost/program_options.hpp>
+#include <boost/shared_ptr.hpp>
 
 class Logger
 {
+
 private:
+
+    typedef boost::shared_ptr<boost::program_options::options_description> Options_descriptionPtr;
+
     int Loglevel;
     bool Syslog;
 
 public:
 
+    typedef boost::shared_ptr<Logger> Ptr;
+
     Logger();
 
     ~Logger();
index ddf1950..8b75bdd 100644 (file)
 #define OBJECT_FILE "/home/bjoern/intranator/bpdyndnsd/objects.ser"
 
 #include <iostream>
+#include <fstream>
 #include <list>
 #include <string>
-
 #include <boost/foreach.hpp>
+#include <sys/types.h>
+#include <signal.h>
+
+#include "updater.h"
 
-#include "updater.cpp"
 #include "config.cpp"
+#include "dhs.cpp"
 #include "logger.cpp"
-
+#include "ods.cpp"
 #include "service.cpp"
 #include "serviceholder.cpp"
+#include "updater.cpp"
 
-#include "dhs.cpp"
-#include "ods.cpp"
-
-#include <sys/types.h>
-#include <signal.h>
 
 using namespace std;
 
-typedef boost::shared_ptr<Updater> UpdaterPtr;
-
-UpdaterPtr updater;
+Updater::Ptr updater;
 bool online_mode = 1;
 
 /**
@@ -159,7 +157,7 @@ int init_signals()
 int main(int argc, char *argv[])
 {
     // initialize Updater
-    UpdaterPtr _updater(new Updater);
+    Updater::Ptr _updater(new Updater);
     updater = _updater;
     _updater.reset();
 
index fc0b908..5c43c94 100644 (file)
@@ -9,6 +9,8 @@
 
 #include "ods.h"
 
+#include <time.h>
+
 using namespace std;
 
 
@@ -29,7 +31,7 @@ ODS::ODS()
  * @param _login The login name.
  * @param _password The corresponding password.
  */
-ODS::ODS(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)
+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;
index c319552..f2a7f75 100644 (file)
--- a/src/ods.h
+++ b/src/ods.h
 #define ODS_H
 
 #include <string>
-#include <time.h>
 
 #include "service.h"
 #include "logger.h"
 
 #include <boost/serialization/array.hpp>
+#include <boost/shared_ptr.hpp>
 
-typedef boost::shared_ptr<Logger> LoggerPtr;
 
 class ODS : public Service
 {
+
 private:
+
     int Timeout;
     // TODO: Fix variable naming
     int Max_updates_per_timeout;
@@ -34,9 +35,11 @@ private:
 
 public:
 
+    typedef boost::shared_ptr<ODS> Ptr;
+
     ODS();
 
-    ODS(const std::string&, const std::string&, const std::string&, const std::string&, const LoggerPtr&, const int, const int, const int);
+    ODS(const std::string&, const std::string&, const std::string&, const std::string&, const Logger::Ptr&, const int, const int, const int);
 
     ~ODS();
 
index 5bfda4a..d015a26 100644 (file)
@@ -134,7 +134,7 @@ string Service::get_password()
  * Setter for member Log.
  * @param _log Shared pointer to Logger object.
  */
-void Service::set_logger(const LoggerPtr& _log)
+void Service::set_logger(const Logger::Ptr& _log)
 {
     Log = _log;
 }
@@ -144,7 +144,7 @@ void Service::set_logger(const LoggerPtr& _log)
  * Getter for member Log.
  * @return Shared pointer to Logger object.
  */
-LoggerPtr Service::get_logger()
+Logger::Ptr Service::get_logger()
 {
     return Log;
 }
index ebdd22f..1b7e8f9 100644 (file)
 #ifndef SERVICE_H
 #define SERVICE_H
 
+#include "logger.h"
+
 #include <string>
 
 #include <boost/serialization/array.hpp>
+#include <boost/shared_ptr.hpp>
 
-#include "logger.h"
-
-typedef boost::shared_ptr<Logger> LoggerPtr;
 
 class Service
 {
 private:
+
     std::string Protocol;
     std::string Hostname;
 
@@ -35,9 +36,12 @@ private:
     template<class Archive>
     void serialize(Archive &, const unsigned int);
 
-    LoggerPtr Log;
+    Logger::Ptr Log;
 
 public:
+
+    typedef boost::shared_ptr<Service> Ptr;
+
     Service();
 
     virtual ~Service();
@@ -65,8 +69,8 @@ public:
     void set_actual_ip(const std::string&);
     std::string get_actual_ip();
 
-    void set_logger(const LoggerPtr&);
-    LoggerPtr get_logger();
+    void set_logger(const Logger::Ptr&);
+    Logger::Ptr get_logger();
 
     bool operator== (const Service&) const;
     bool operator!= (const Service&) const;
index f2eaa57..4f21ffb 100644 (file)
@@ -9,6 +9,8 @@
 
 #include "serviceholder.h"
 
+#include <boost/serialization/list.hpp>
+
 using namespace std;
 
 
@@ -45,7 +47,7 @@ void Serviceholder::serialize(Archive & ar, const unsigned int version)
  * Add Service * to internal list.
  * @param service Pointer to Service object.
  */
-void Serviceholder::add_service(ServicePtr service)
+void Serviceholder::add_service(Service::Ptr service)
 {
     Hold_services.push_back(service);
 }
@@ -55,7 +57,7 @@ void Serviceholder::add_service(ServicePtr service)
  * Needed after deserialization to get the valid list of Service* back.
  * @return The list of Service*.
  */
-std::list<ServicePtr> Serviceholder::get_hold_services()
+std::list<Service::Ptr> Serviceholder::get_hold_services()
 {
     return Hold_services;
 }
index eddb647..bce8006 100644 (file)
 #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<Service> ServicePtr;
-
 class Serviceholder
 {
+
 private:
+
     friend class boost::serialization::access;
 
-    std::list<ServicePtr> Hold_services;
+    std::list<Service::Ptr> Hold_services;
 
     template<class Archive>
     void serialize(Archive &, const unsigned int);
 
 public:
 
+    typedef boost::shared_ptr<Serviceholder> Ptr;
+
     Serviceholder();
 
-    Serviceholder(LoggerPtr);
+    Serviceholder(Logger::Ptr);
 
     ~Serviceholder();
 
-    void add_service(ServicePtr);
+    void add_service(Service::Ptr);
 
-    std::list<ServicePtr> get_hold_services();
+    std::list<Service::Ptr> get_hold_services();
 };
 
 #endif
index 46f2437..94c6e00 100644 (file)
@@ -9,6 +9,8 @@
 
 #include "updater.h"
 
+#include <boost/foreach.hpp>
+
 using namespace std;
 
 /**
@@ -17,11 +19,11 @@ using namespace std;
 Updater::Updater()
 {
     // Initialize program wide Logger, at this point we don't know where to log and with which loglevel.
-    LoggerPtr _log(new Logger);
+    Logger::Ptr _log(new Logger);
     Log = _log;
 
     // initialize Config
-    ConfigPtr _config(new Config(Log));
+    Config::Ptr _config(new Config(Log));
     Conf = _config;
 }
 
@@ -82,7 +84,7 @@ int Updater::init_config_from_files()
  * Getter for member Config.
  * @return Member Config.
  */
-ConfigPtr Updater::get_config()
+Config::Ptr Updater::get_config()
 {
     return Conf;
 }
@@ -92,7 +94,7 @@ ConfigPtr Updater::get_config()
  * Getter for member Logger.
  * @return Member Logger.
  */
-LoggerPtr Updater::get_logger()
+Logger::Ptr Updater::get_logger()
 {
     return Log;
 }
@@ -133,11 +135,11 @@ void Updater::init_log_facility()
  */
 void Updater::update_services()
 {
-    list<ServicePtr> services = this->Conf->get_services();
+    list<Service::Ptr> services = this->Conf->get_services();
 
     string ip = "192.168.1.1";
 
-    BOOST_FOREACH(ServicePtr &service, services )
+    BOOST_FOREACH(Service::Ptr &service, services )
     {
         service->update(ip);
     }
index 63ebce9..cb5371d 100644 (file)
 #ifndef UPDATER_H
 #define UPDATER_H
 
-#include <boost/foreach.hpp>
-
 #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;
+#include <boost/shared_ptr.hpp>
+
 
 class Updater
 {
+
 private:
-    ConfigPtr Conf;
-    LoggerPtr Log;
+
+    Config::Ptr Conf;
+    Logger::Ptr Log;
 
 public:
+
+    typedef boost::shared_ptr<Updater> Ptr;
+
     Updater();
 
     ~Updater();
@@ -36,9 +38,9 @@ public:
 
     int init_config_from_files();
 
-    ConfigPtr get_config();
+    Config::Ptr get_config();
 
-    LoggerPtr get_logger();
+    Logger::Ptr get_logger();
 
     void reload_config();