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.
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.
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
18 * Author : Maxim Mamontov <faust@stargazer.dp.ua>
37 explicit ServiceConf(const std::string & n)
38 : name(n), cost(0), payDay(0)
40 ServiceConf(const std::string & n, double c)
41 : name(n), cost(c), payDay(0)
43 ServiceConf(const std::string & n, double c, unsigned p)
44 : name(n), cost(c), payDay(static_cast<uint8_t>(p))
46 ServiceConf(const std::string & n, double c,
47 unsigned p, const std::string & com)
48 : name(n), comment(com), cost(c), payDay(static_cast<uint8_t>(p))
51 ServiceConf(const ServiceConf&) = default;
52 ServiceConf& operator=(const ServiceConf&) = default;
53 ServiceConf(ServiceConf&&) = default;
54 ServiceConf& operator=(ServiceConf&&) = default;
56 bool operator==(const ServiceConf& rhs) const noexcept { return name == rhs.name; }
66 ServiceConfOpt() = default;
68 explicit ServiceConfOpt(const ServiceConf& rhs)
69 : name(rhs.name), comment(rhs.comment),
70 cost(rhs.cost), payDay(rhs.payDay)
73 ServiceConfOpt(const ServiceConfOpt&) = default;
74 ServiceConfOpt& operator=(const ServiceConfOpt&) = default;
75 ServiceConfOpt(ServiceConfOpt&&) = default;
76 ServiceConfOpt& operator=(ServiceConfOpt&&) = default;
78 ServiceConfOpt& operator=(const ServiceConf& conf)
81 comment = conf.comment;
87 void splice(const ServiceConfOpt& rhs)
89 STG::splice(name, rhs.name);
90 STG::splice(comment, rhs.comment);
91 STG::splice(cost, rhs.cost);
92 STG::splice(payDay, rhs.payDay);
95 ServiceConf get(const ServiceConf& defaultValue) const noexcept
98 res.name = name.value_or(defaultValue.name);
99 res.comment = comment.value_or(defaultValue.comment);
100 res.cost = cost.value_or(defaultValue.cost);
101 res.payDay = payDay.value_or(defaultValue.payDay);
105 std::optional<std::string> name;
106 std::optional<std::string> comment;
107 std::optional<double> cost;
108 std::optional<uint8_t> payDay;