This is the simple Serviceholder class needed for de/serialization purposes.
[bpdyndnsd] / src / service.cpp
CommitLineData
b1be615b 1/** @file
2bc1878a 2 * @brief The abstract service class. This class represents all services.
b1be615b
BS
3 *
4 *
5 *
6 * @copyright Intra2net AG
7 * @license GPLv2
8*/
9
4545a371
BS
10#include "service.h"
11
2bc1878a 12
85a0abf9
BS
13/**
14 * Default Constructor
15 */
4545a371 16Service::Service()
27baf279
BS
17 : Protocol("")
18 , Hostname("")
19 , Login("NOT SERIALIZED")
20 , Password("NOT SERIALIZED")
21 , Lastupdated(0)
22 , Actual_IP("0.0.0.0")
4545a371
BS
23{
24}
25
2bc1878a 26
85a0abf9 27/**
27baf279 28 * Default Destructor needed for deserialization.
85a0abf9 29 */
4545a371
BS
30Service::~Service()
31{
32}
33
34
2bc1878a
BS
35/**
36 * Although this is an abstract class, we need the serialize function that we can serialize derived classes through a Service *.
37 * @param ar Archive.
38 * @param version Version.
39 */
40template<class Archive>
41void Service::serialize(Archive & ar, const unsigned int version)
42{
3a89ac31
BS
43 // protocol and hostname are the unique identifier for each service.
44 ar & Protocol;
45 ar & Hostname;
27baf279 46 // lastupdated and actual_ip must also be serialized, cause these are essential infos of each service.
2bc1878a 47 ar & Lastupdated;
27baf279 48 ar & Actual_IP;
3a89ac31
BS
49}
50
51
52/**
53 * Setter for member Protocol.
54 * @param _protocol Value to set Protocol to.
55 */
56void Service::set_protocol(const string& _protocol)
57{
58 Protocol = _protocol;
59}
60
61
62/**
63 * Getter for memeber Protocol.
64 * @return Value of member Protocol.
65 */
66string Service::get_protocol()
67{
68 return Protocol;
69}
70
71
72/**
73 * Setter for member Hostname.
74 * @param _hostname Value to set Hostname to.
75 */
76void Service::set_hostname(const string& _hostname)
77{
78 Hostname = _hostname;
79}
80
81
82/**
83 * Getter for member Hostname.
84 * @return Value of member Hostname.
85 */
86string Service::get_hostname()
87{
88 return Hostname;
89}
90
91
92/**
93 * Setter for member Login.
94 * @param _login Value to set Login to.
95 */
96void Service::set_login(const string& _login)
97{
98 Login = _login;
99}
100
101
102/**
103 * Getter for member Login.
104 * @return Value of member Login.
105 */
106string Service::get_login()
107{
108 return Login;
109}
110
111
112/**
113 * Setter for member Password.
114 * @param _password Value to set Password to.
115 */
116void Service::set_password(const string& _password)
117{
118 Password = _password;
119}
120
121
122/**
123 * Getter for member Password.
124 * @return Value of member Password.
125 */
126string Service::get_password()
127{
128 return Password;
129}
130
131
132/**
133 * Setter for member Log.
134 * @param _log Shared pointer to Logger object.
135 */
136void Service::set_logger(const LoggerPtr& _log)
137{
138 Log = _log;
139}
140
141
142/**
143 * Getter for member Log.
144 * @return Shared pointer to Logger object.
145 */
146LoggerPtr Service::get_logger()
147{
148 return Log;
2bc1878a
BS
149}
150
151
152/**
153 * Setter for member Lastupdated.
154 * @param _lastupdated Value to set Lastupdated to.
155 */
156void Service::set_lastupdated(const int _lastupdated)
157{
158 Lastupdated = _lastupdated;
159}
160
161
162/**
163 * Getter for member Lastupdated.
164 * @return Value of member Lastupdated.
165 */
166int Service::get_lastupdated()
167{
168 return Lastupdated;
169}
170
171
172/**
27baf279
BS
173 * Setter for member Actual_IP.
174 * @param _actual_ip Value to set Actual_IP to.
175 */
176void Service::set_actual_ip(const std::string& _actual_ip)
177{
178 Actual_IP = _actual_ip;
179}
180
181
182/**
183 * Getter for member Actual_IP.
184 * @return Value of member Actual_IP.
185 */
186std::string Service::get_actual_ip()
187{
188 return Actual_IP;
189}
190
191
192
193/**
3a89ac31
BS
194 * Overloading of comparison operator.
195 * @param other Reference to other Service object.
196 * @return True if they equal, false if not.
2bc1878a 197 */
3a89ac31 198bool Service::operator== (const Service& other) const
2bc1878a 199{
3a89ac31
BS
200 if ( ( this->Protocol == other.Protocol ) && ( this->Hostname == other.Hostname ) )
201 return true;
202 return false;
2bc1878a
BS
203}
204
205
206/**
3a89ac31
BS
207 * Overloading of disparate operator.
208 * @param other Reference to other Service object.
209 * @return True if they differ, false if they are equal.
2bc1878a 210 */
3a89ac31 211bool Service::operator!= (const Service& other) const
2bc1878a 212{
3a89ac31 213 return !(*this == other);
2bc1878a 214}