]> git.stg.codes - stg.git/blob - include/stg/tariff_conf.h
Fixed getting user's login.
[stg.git] / include / stg / tariff_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 : Boris Mikhailenko <stg34@stargazer.dp.ua>
19  */
20
21  /*
22  $Revision: 1.9 $
23  $Date: 2010/10/05 20:41:11 $
24  $Author: faust $
25  */
26
27 #ifndef TARIFF_CONF_H
28 #define TARIFF_CONF_H
29
30 #include "tariff.h"
31 #include "resetable.h"
32 #include "const.h"
33
34 #include <string>
35 #include <vector>
36
37 //-----------------------------------------------------------------------------
38 enum
39 {
40     TRAFF_UP = 0,
41     TRAFF_DOWN,
42     TRAFF_UP_DOWN,
43     TRAFF_MAX
44 };
45 //-----------------------------------------------------------------------------
46 struct DIRPRICE_DATA
47 {
48     DIRPRICE_DATA()
49         : hDay(0),
50           mDay(0),
51           hNight(0),
52           mNight(0),
53           priceDayA(0),
54           priceNightA(0),
55           priceDayB(0),
56           priceNightB(0),
57           threshold(0),
58           singlePrice(0),
59           noDiscount(0)
60         {}
61     int    hDay;
62     int    mDay;
63     int    hNight;
64     int    mNight;
65     double priceDayA;
66     double priceNightA;
67     double priceDayB;
68     double priceNightB;
69     int    threshold;
70     int    singlePrice; // Do not use day/night division
71     int    noDiscount; // Do not use threshold
72 };
73 //-----------------------------------------------------------------------------
74 struct DIRPRICE_DATA_RES
75 {
76     DIRPRICE_DATA_RES()
77         : hDay(),
78           mDay(),
79           hNight(),
80           mNight(),
81           priceDayA(),
82           priceNightA(),
83           priceDayB(),
84           priceNightB(),
85           threshold(),
86           singlePrice(),
87           noDiscount()
88         {}
89
90     DIRPRICE_DATA_RES & operator= (const DIRPRICE_DATA & rvalue)
91         {
92         hDay        = rvalue.hDay;
93         mDay        = rvalue.mDay;
94         hNight      = rvalue.hNight;
95         mNight      = rvalue.mNight;
96         priceDayA   = rvalue.priceDayA;
97         priceNightA = rvalue.priceNightA;
98         priceDayB   = rvalue.priceDayB;
99         priceNightB = rvalue.priceNightB;
100         threshold   = rvalue.threshold;
101         singlePrice = rvalue.singlePrice;
102         noDiscount  = rvalue.noDiscount;
103         return *this;
104         }
105
106     DIRPRICE_DATA GetData() const
107         {
108         DIRPRICE_DATA dd;
109         dd.hDay        = hDay.data();
110         dd.hNight      = hNight.data();
111         dd.mDay        = mDay.data();
112         dd.mNight      = mNight.data();
113         dd.noDiscount  = noDiscount.data();
114         dd.priceDayA   = priceDayA.data();
115         dd.priceDayB   = priceDayB.data();
116
117         dd.priceNightA = priceNightA.data();
118         dd.priceNightB = priceNightB.data();
119         dd.singlePrice = singlePrice.data();
120         dd.threshold   = threshold.data();
121         return dd;
122         }
123
124     RESETABLE<int>    hDay;
125     RESETABLE<int>    mDay;
126     RESETABLE<int>    hNight;
127     RESETABLE<int>    mNight;
128     RESETABLE<double> priceDayA;
129     RESETABLE<double> priceNightA;
130     RESETABLE<double> priceDayB;
131     RESETABLE<double> priceNightB;
132     RESETABLE<int>    threshold;
133     RESETABLE<int>    singlePrice;
134     RESETABLE<int>    noDiscount;
135 };
136 //-----------------------------------------------------------------------------
137 struct TARIFF_CONF
138 {
139     double         fee;
140     double         free;
141     int            traffType;
142     double         passiveCost;
143     std::string    name;
144     TARIFF::PERIOD period;
145
146     TARIFF_CONF()
147         : fee(0),
148           free(0),
149           traffType(TRAFF_UP_DOWN),
150           passiveCost(0),
151           name(),
152           period(TARIFF::MONTH)
153         {}
154
155     TARIFF_CONF(const std::string & n)
156         : fee(0),
157           free(0),
158           traffType(TRAFF_UP_DOWN),
159           passiveCost(0),
160           name(n),
161           period(TARIFF::MONTH)
162         {}
163 };
164 //-----------------------------------------------------------------------------
165 struct TARIFF_CONF_RES
166 {
167     TARIFF_CONF_RES()
168         : fee(),
169           free(),
170           traffType(),
171           passiveCost(),
172           name(),
173           period()
174         {}
175
176     TARIFF_CONF_RES & operator=(const TARIFF_CONF & tc)
177         {
178         fee         = tc.fee;
179         free        = tc.free;
180         traffType   = tc.traffType;
181         passiveCost = tc.passiveCost;
182         name        = tc.name;
183         period      = tc.period;
184         return *this;
185         }
186
187     TARIFF_CONF GetData() const
188         {
189         TARIFF_CONF tc;
190         tc.fee         = fee.data();
191         tc.free        = free.data();
192         tc.name        = name.data();
193         tc.passiveCost = passiveCost.data();
194         tc.traffType   = traffType.data();
195         tc.period      = period.data();
196         return tc;
197         }
198
199     RESETABLE<double>         fee;
200     RESETABLE<double>         free;
201     RESETABLE<int>            traffType;
202     RESETABLE<double>         passiveCost;
203     RESETABLE<std::string>    name;
204     RESETABLE<TARIFF::PERIOD> period;
205 };
206 //-----------------------------------------------------------------------------
207 struct TARIFF_DATA
208 {
209     TARIFF_CONF                tariffConf;
210     std::vector<DIRPRICE_DATA> dirPrice;
211
212     TARIFF_DATA()
213         : tariffConf(),
214           dirPrice(DIR_NUM)
215         {}
216
217     TARIFF_DATA(const std::string & name)
218         : tariffConf(name),
219           dirPrice(DIR_NUM)
220         {}
221
222     TARIFF_DATA(const TARIFF_DATA & td)
223         : tariffConf(td.tariffConf),
224           dirPrice(td.dirPrice)
225         {}
226
227     TARIFF_DATA & operator=(const TARIFF_DATA & td)
228         {
229         tariffConf = td.tariffConf;
230         dirPrice = td.dirPrice;
231         return *this;
232         }
233 };
234 //-----------------------------------------------------------------------------
235 struct TARIFF_DATA_RES
236 {
237     TARIFF_CONF_RES                tariffConf;
238     std::vector<DIRPRICE_DATA_RES> dirPrice;
239
240     TARIFF_DATA_RES()
241         : tariffConf(),
242           dirPrice(DIR_NUM)
243         {}
244
245     TARIFF_DATA GetData() const
246         {
247         TARIFF_DATA td;
248         td.tariffConf = tariffConf.GetData();
249         for (size_t i = 0; i < DIR_NUM; i++)
250             td.dirPrice[i] = dirPrice[i].GetData();
251         return td;
252         }
253 };
254 //-----------------------------------------------------------------------------
255 #endif