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>
38 int MaxUpdatesWithinInterval;
39 int MaxEqualUpdatesInSuccession;
42 std::map<time_t,std::string> LastUpdates;
45 time_t ErrorServiceBlockedUntil;
47 friend class boost::serialization::access;
48 template<class Archive>
49 void serialize(Archive & ar, const unsigned int version)
51 // protocol and hostname are the unique identifier for each service.
54 // lastupdated and actual_ip must also be serialized, cause these are essential infos of each service.
58 ar & MaxUpdatesWithinInterval;
59 ar & MaxEqualUpdatesInSuccession;
67 enum UpdateErrorCode { UpdateOk=0, GenericError=1, NoChange=2, Blocked=3 };
68 virtual UpdateErrorCode perform_update(const std::string& ip) = 0;
72 typedef boost::shared_ptr<Service> Ptr;
78 void update(const std::string& ip, const time_t current_time, bool changed_to_online);
80 bool update_allowed(const time_t current_time, bool changed_to_online, const std::string& ip_host);
82 void set_last_update(const time_t current_time, const std::string& ip);
84 time_t get_last_update_time();
86 int get_update_interval()const;
87 void set_update_interval(const int _update_interval);
89 int get_max_updates_within_interval() const;
90 void set_max_updates_within_interval(const int _max_updates_within_interval);
92 int get_max_equal_updates_in_succession() const;
93 void set_max_equal_updates_in_succession(const int _max_equal_updates_in_succession);
95 int get_dns_cache_ttl() const;
96 void set_dns_cache_ttl(const int _dns_cache_ttl);
98 void set_protocol(const std::string& _protocol);
99 std::string get_protocol() const;
101 void set_hostname(const std::string& _hostname);
102 std::string get_hostname() const;
104 void set_login(const std::string& _login);
105 std::string get_login() const;
107 void set_password(const std::string& _password);
108 std::string get_password() const;
110 void set_last_updates(std::map<time_t,std::string> _last_updates);
111 const std::map<time_t,std::string> get_last_updates() const;
113 void set_actual_ip(const std::string& _actual_ip);
114 std::string get_actual_ip() const;
116 void set_logger(const Logger::Ptr& _log);
117 Logger::Ptr get_logger() const;
119 std::string get_service_name() const;
121 bool operator== (const Service& other) const;
122 bool operator!= (const Service& other) const;