Each Service has Protocol, Hostname, Login, Password, Shared_Ptr to Logging facility...
[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
BS
16Service::Service()
17{
18}
19
2bc1878a 20
85a0abf9
BS
21/**
22 * Default Destructor
23 */
4545a371
BS
24Service::~Service()
25{
26}
27
28
2bc1878a
BS
29/**
30 * Although this is an abstract class, we need the serialize function that we can serialize derived classes through a Service *.
31 * @param ar Archive.
32 * @param version Version.
33 */
34template<class Archive>
35void Service::serialize(Archive & ar, const unsigned int version)
36{
3a89ac31
BS
37 // protocol and hostname are the unique identifier for each service.
38 ar & Protocol;
39 ar & Hostname;
40 // lastupdated must also be serialized, cause this is essential info of each service.
2bc1878a 41 ar & Lastupdated;
3a89ac31
BS
42}
43
44
45/**
46 * Setter for member Protocol.
47 * @param _protocol Value to set Protocol to.
48 */
49void Service::set_protocol(const string& _protocol)
50{
51 Protocol = _protocol;
52}
53
54
55/**
56 * Getter for memeber Protocol.
57 * @return Value of member Protocol.
58 */
59string Service::get_protocol()
60{
61 return Protocol;
62}
63
64
65/**
66 * Setter for member Hostname.
67 * @param _hostname Value to set Hostname to.
68 */
69void Service::set_hostname(const string& _hostname)
70{
71 Hostname = _hostname;
72}
73
74
75/**
76 * Getter for member Hostname.
77 * @return Value of member Hostname.
78 */
79string Service::get_hostname()
80{
81 return Hostname;
82}
83
84
85/**
86 * Setter for member Login.
87 * @param _login Value to set Login to.
88 */
89void Service::set_login(const string& _login)
90{
91 Login = _login;
92}
93
94
95/**
96 * Getter for member Login.
97 * @return Value of member Login.
98 */
99string Service::get_login()
100{
101 return Login;
102}
103
104
105/**
106 * Setter for member Password.
107 * @param _password Value to set Password to.
108 */
109void Service::set_password(const string& _password)
110{
111 Password = _password;
112}
113
114
115/**
116 * Getter for member Password.
117 * @return Value of member Password.
118 */
119string Service::get_password()
120{
121 return Password;
122}
123
124
125/**
126 * Setter for member Log.
127 * @param _log Shared pointer to Logger object.
128 */
129void Service::set_logger(const LoggerPtr& _log)
130{
131 Log = _log;
132}
133
134
135/**
136 * Getter for member Log.
137 * @return Shared pointer to Logger object.
138 */
139LoggerPtr Service::get_logger()
140{
141 return Log;
2bc1878a
BS
142}
143
144
145/**
146 * Setter for member Lastupdated.
147 * @param _lastupdated Value to set Lastupdated to.
148 */
149void Service::set_lastupdated(const int _lastupdated)
150{
151 Lastupdated = _lastupdated;
152}
153
154
155/**
156 * Getter for member Lastupdated.
157 * @return Value of member Lastupdated.
158 */
159int Service::get_lastupdated()
160{
161 return Lastupdated;
162}
163
164
165/**
3a89ac31
BS
166 * Overloading of comparison operator.
167 * @param other Reference to other Service object.
168 * @return True if they equal, false if not.
2bc1878a 169 */
3a89ac31 170bool Service::operator== (const Service& other) const
2bc1878a 171{
3a89ac31
BS
172 if ( ( this->Protocol == other.Protocol ) && ( this->Hostname == other.Hostname ) )
173 return true;
174 return false;
2bc1878a
BS
175}
176
177
178/**
3a89ac31
BS
179 * Overloading of disparate operator.
180 * @param other Reference to other Service object.
181 * @return True if they differ, false if they are equal.
2bc1878a 182 */
3a89ac31 183bool Service::operator!= (const Service& other) const
2bc1878a 184{
3a89ac31 185 return !(*this == other);
2bc1878a 186}