]> git.stg.codes - stg.git/blob - include/stg/service_conf.h
Added resetable service conf.
[stg.git] / include / stg / service_conf.h
1 #ifndef SERVICE_CONF_H
2 #define SERVICE_CONF_H
3
4 #include <string>
5
6 #include "resetable.h"
7 #include "os_int.h"
8
9 struct SERVICE_CONF
10 {
11 SERVICE_CONF()
12     : name(), comment(), cost(0), payDay(0)
13 {}
14 SERVICE_CONF(const std::string & n)
15     : name(n), comment(), cost(0), payDay(0)
16 {}
17 SERVICE_CONF(const std::string & n, double c)
18     : name(n), comment(), cost(c), payDay(0)
19 {}
20 SERVICE_CONF(const std::string & n, double c, unsigned p)
21     : name(n), comment(), cost(c), payDay(static_cast<uint8_t>(p))
22 {}
23 SERVICE_CONF(const std::string & n, double c,
24              unsigned p, const std::string & com)
25     : name(n), comment(com), cost(c), payDay(static_cast<uint8_t>(p))
26 {}
27
28 std::string name;
29 std::string comment;
30 double      cost;
31 uint8_t     payDay;
32 };
33
34 struct SERVICE_CONF_RES
35 {
36 SERVICE_CONF_RES()
37     : name(), comment(),
38       cost(), payDay()
39 {}
40
41 SERVICE_CONF_RES & operator=(const SERVICE_CONF & conf)
42 {
43 name = conf.name;
44 comment = conf.comment;
45 cost = conf.cost;
46 payDay = conf.payDay;
47 return *this;
48 }
49
50 SERVICE_CONF GetData() const
51 {
52 SERVICE_CONF sc;
53 sc.name = name.data();
54 sc.comment = comment.data();
55 sc.cost = cost.data();
56 sc.payDay = payDay.data();
57 return sc;
58 }
59
60 RESETABLE<std::string> name;
61 RESETABLE<std::string> comment;
62 RESETABLE<double>      cost;
63 RESETABLE<uint8_t>     payDay;
64 };
65
66 inline
67 bool operator==(const SERVICE_CONF & a, const SERVICE_CONF & b)
68 {
69 return a.name == b.name;
70 }
71
72 #endif //SERVICE_CONF_H
73