/** @file * @brief The abstract service class. This class represents all services. * * * * @copyright Intra2net AG * @license GPLv2 */ #ifndef SERVICE_H #define SERVICE_H #include "logger.hpp" #include #include #include #include #include class Service { private: std::string Protocol; std::string Hostname; std::string Login; std::string Password; std::string ActualIP; int UpdateInterval; int MaxUpdatesWithinInterval; int DNSCacheTTL; std::list LastUpdates; int ErrorCount; time_t ErrorServiceBlockedUntil; friend class boost::serialization::access; template void serialize(Archive & ar, const unsigned int version) { // protocol and hostname are the unique identifier for each service. ar & Protocol; ar & Hostname; // lastupdated and actual_ip must also be serialized, cause these are essential infos of each service. ar & LastUpdates; ar & ActualIP; ar & UpdateInterval; ar & MaxUpdatesWithinInterval; ar & DNSCacheTTL; } Logger::Ptr Log; public: typedef boost::shared_ptr Ptr; Service(); virtual ~Service(); virtual int perform_update(const std::string& ip) = 0; void update(const std::string& ip, const time_t current_time, bool changed_to_online); bool update_allowed(const time_t current_time, bool changed_to_online); void set_last_update(const time_t current_time); int get_update_interval()const; void set_update_interval(const int _update_interval); int get_max_updates_within_interval() const; void set_max_updates_within_interval(const int _max_updates_within_interval); int get_dns_cache_ttl() const; void set_dns_cache_ttl(const int _dns_cache_ttl); void set_protocol(const std::string& _protocol); std::string get_protocol() const; void set_hostname(const std::string& _hostname); std::string get_hostname() const; void set_login(const std::string& _login); std::string get_login() const; void set_password(const std::string& _password); std::string get_password() const; void set_last_updates(std::list _last_updates); const std::list get_last_updates() const; void set_actual_ip(const std::string& _actual_ip); std::string get_actual_ip() const; void set_logger(const Logger::Ptr& _log); Logger::Ptr get_logger() const; std::string get_service_name() const; bool operator== (const Service& other) const; bool operator!= (const Service& other) const; }; #endif