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