]> git.stg.codes - stg.git/blob - include/stg/service_conf.h
Merge branch 'fix-gts-auth-errors'
[stg.git] / include / stg / service_conf.h
1 /*
2  *    This program is free software; you can redistribute it and/or modify
3  *    it under the terms of the GNU General Public License as published by
4  *    the Free Software Foundation; either version 2 of the License, or
5  *    (at your option) any later version.
6  *
7  *    This program is distributed in the hope that it will be useful,
8  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
9  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  *    GNU General Public License for more details.
11  *
12  *    You should have received a copy of the GNU General Public License
13  *    along with this program; if not, write to the Free Software
14  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15  */
16
17 /*
18  *    Author : Maxim Mamontov <faust@stargazer.dp.ua>
19  */
20
21 #ifndef SERVICE_CONF_H
22 #define SERVICE_CONF_H
23
24 #include "resetable.h"
25 #include "os_int.h"
26
27 #include <string>
28
29 struct SERVICE_CONF
30 {
31 SERVICE_CONF()
32     : name(), comment(), cost(0), payDay(0)
33 {}
34 SERVICE_CONF(const std::string & n)
35     : name(n), comment(), cost(0), payDay(0)
36 {}
37 SERVICE_CONF(const std::string & n, double c)
38     : name(n), comment(), cost(c), payDay(0)
39 {}
40 SERVICE_CONF(const std::string & n, double c, unsigned p)
41     : name(n), comment(), cost(c), payDay(static_cast<uint8_t>(p))
42 {}
43 SERVICE_CONF(const std::string & n, double c,
44              unsigned p, const std::string & com)
45     : name(n), comment(com), cost(c), payDay(static_cast<uint8_t>(p))
46 {}
47
48 std::string name;
49 std::string comment;
50 double      cost;
51 uint8_t     payDay;
52 };
53
54 struct SERVICE_CONF_RES
55 {
56 SERVICE_CONF_RES()
57     : name(), comment(),
58       cost(), payDay()
59 {}
60
61 SERVICE_CONF_RES & operator=(const SERVICE_CONF & conf)
62 {
63 name = conf.name;
64 comment = conf.comment;
65 cost = conf.cost;
66 payDay = conf.payDay;
67 return *this;
68 }
69
70 SERVICE_CONF GetData() const
71 {
72 SERVICE_CONF sc;
73 sc.name = name.data();
74 sc.comment = comment.data();
75 sc.cost = cost.data();
76 sc.payDay = payDay.data();
77 return sc;
78 }
79
80 RESETABLE<std::string> name;
81 RESETABLE<std::string> comment;
82 RESETABLE<double>      cost;
83 RESETABLE<uint8_t>     payDay;
84 };
85
86 inline
87 bool operator==(const SERVICE_CONF & a, const SERVICE_CONF & b)
88 {
89 return a.name == b.name;
90 }
91
92 #endif //SERVICE_CONF_H
93