2 * @brief The abstract service class. This class represents all services.
6 * @copyright Intra2net AG
15 #include <boost/archive/text_oarchive.hpp>
16 #include <boost/archive/text_iarchive.hpp>
18 #include <boost/shared_ptr.hpp>
37 int MaxUpdatesWithinInterval;
38 int MaxEqualUpdatesInSuccession;
41 std::map<time_t,std::string> LastUpdates;
44 time_t ErrorServiceBlockedUntil;
46 friend class boost::serialization::access;
47 template<class Archive>
48 void serialize(Archive & ar, const unsigned int version)
50 // protocol and hostname are the unique identifier for each service.
53 // lastupdated and actual_ip must also be serialized, cause these are essential infos of each service.
57 ar & MaxUpdatesWithinInterval;
58 ar & MaxEqualUpdatesInSuccession;
66 typedef boost::shared_ptr<Service> Ptr;
72 virtual int perform_update(const std::string& ip) = 0;
74 void update(const std::string& ip, const time_t current_time, bool changed_to_online);
76 bool update_allowed(const time_t current_time, bool changed_to_online, const std::string& ip_host);
78 void set_last_update(const time_t current_time, const std::string& ip);
80 time_t get_last_update_time();
82 int get_update_interval()const;
83 void set_update_interval(const int _update_interval);
85 int get_max_updates_within_interval() const;
86 void set_max_updates_within_interval(const int _max_updates_within_interval);
88 int get_max_equal_updates_in_succession() const;
89 void set_max_equal_updates_in_succession(const int _max_equal_updates_in_succession);
91 int get_dns_cache_ttl() const;
92 void set_dns_cache_ttl(const int _dns_cache_ttl);
94 void set_protocol(const std::string& _protocol);
95 std::string get_protocol() const;
97 void set_hostname(const std::string& _hostname);
98 std::string get_hostname() const;
100 void set_login(const std::string& _login);
101 std::string get_login() const;
103 void set_password(const std::string& _password);
104 std::string get_password() const;
106 void set_last_updates(std::map<time_t,std::string> _last_updates);
107 const std::map<time_t,std::string> get_last_updates() const;
109 void set_actual_ip(const std::string& _actual_ip);
110 std::string get_actual_ip() const;
112 void set_logger(const Logger::Ptr& _log);
113 Logger::Ptr get_logger() const;
115 std::string get_service_name() const;
117 bool operator== (const Service& other) const;
118 bool operator!= (const Service& other) const;