]> git.stg.codes - stg.git/blob - include/tariff_conf.h
Удаляю версию для проверки закрытия тикета
[stg.git] / include / 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 "stg_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 & operator= (const DIRPRICE_DATA & dpd)
76         {
77         hDay        = dpd.hDay;
78         mDay        = dpd.mDay;
79         hNight      = dpd.hNight;
80         mNight      = dpd.mNight;
81         priceDayA   = dpd.priceDayA;
82         priceNightA = dpd.priceNightA;
83         priceDayB   = dpd.priceDayB;
84         priceNightB = dpd.priceNightB;
85         threshold   = dpd.threshold;
86         singlePrice = dpd.singlePrice;
87         noDiscount  = dpd.noDiscount;
88         return *this;
89         };
90
91     DIRPRICE_DATA GetData()
92         {
93         DIRPRICE_DATA dd;
94         dd.hDay        = hDay;
95         dd.hNight      = hNight;
96         dd.mDay        = mDay;
97         dd.mNight      = mNight;
98         dd.noDiscount  = noDiscount;
99         dd.priceDayA   = priceDayA;
100         dd.priceDayB   = priceDayB;
101
102         dd.priceNightA = priceNightA;
103         dd.priceNightB = priceNightB;
104         dd.singlePrice = singlePrice;
105         dd.threshold   = threshold;
106         return dd;
107         }
108
109     RESETABLE<int>     hDay;
110     RESETABLE<int>     mDay;
111     RESETABLE<int>     hNight;
112     RESETABLE<int>     mNight;
113     RESETABLE<double>  priceDayA;
114     RESETABLE<double>  priceNightA;
115     RESETABLE<double>  priceDayB;
116     RESETABLE<double>  priceNightB;
117     RESETABLE<int>     threshold;
118     RESETABLE<int>     singlePrice;
119     RESETABLE<int>     noDiscount;
120 };
121 //-----------------------------------------------------------------------------
122 struct TARIFF_CONF
123 {
124     double      fee;                 // ÷ÅÌÉÞÉÎÁ ÁÂÏÎÐÌÁÔÙ
125     double      free;                // îÁ ËÁËÕÀ ÓÕÍÍÕ ÄÅÎÅÇ ÀÚÅÒ ËÁÞÁÅÔ ÂÅÓÐÌÁÔÎÏ
126     int         traffType;           // UP, DOWN, UP+DOWN, MAX
127     double      passiveCost;         // óÔÏÉÍÏÓÔØ ÚÁÍÏÒÏÚËÉ
128     std::string name;
129
130     TARIFF_CONF()
131         : fee(0),
132           free(0),
133           traffType(TRAFF_UP_DOWN),              // UP-DOWN
134           passiveCost(0),
135           name()
136         {};
137
138     TARIFF_CONF(const std::string & n)
139         : fee(0),
140           free(0),
141           traffType(TRAFF_UP_DOWN),              // UP-DOWN
142           passiveCost(0),
143           name(n)
144         {};
145 };
146 //-----------------------------------------------------------------------------
147 struct TARIFF_CONF_RES
148 {
149     TARIFF_CONF_RES & operator=(const TARIFF_CONF & tc)
150         {
151         fee         = tc.fee;
152         free        = tc.free;
153         traffType   = tc.traffType;
154         passiveCost = tc.passiveCost;
155         name        = tc.name;
156         return *this;
157         };
158
159     TARIFF_CONF GetData()
160         {
161         TARIFF_CONF tc;
162         tc.fee         = fee;
163         tc.free        = free;
164         tc.name        = name;
165         tc.passiveCost = passiveCost;
166         tc.traffType   = traffType;
167         return tc;
168         }
169
170     RESETABLE<double>       fee;
171     RESETABLE<double>       free;
172     RESETABLE<int>          traffType;
173     RESETABLE<double>       passiveCost;
174     RESETABLE<std::string>  name;
175 };
176 //-----------------------------------------------------------------------------
177 struct TARIFF_DATA
178 {
179     TARIFF_CONF                 tariffConf;
180     std::vector<DIRPRICE_DATA>  dirPrice;
181
182     TARIFF_DATA()
183         : tariffConf(),
184           dirPrice(DIR_NUM)
185         {}
186
187     TARIFF_DATA(const std::string & name)
188         : tariffConf(name),
189           dirPrice(DIR_NUM)
190         {}
191
192     TARIFF_DATA(const TARIFF_DATA & td)
193         : tariffConf(td.tariffConf),
194           dirPrice(td.dirPrice)
195         {}
196
197     TARIFF_DATA & operator=(const TARIFF_DATA & td)
198         {
199         tariffConf = td.tariffConf;
200         dirPrice = td.dirPrice;
201         return *this;
202         };
203 };
204 //-----------------------------------------------------------------------------
205 struct TARIFF_DATA_RES
206 {
207     TARIFF_CONF_RES     tariffConf;
208     std::vector<DIRPRICE_DATA_RES> dirPrice;
209
210     TARIFF_DATA_RES()
211         : tariffConf(),
212           dirPrice(DIR_NUM)
213         {}
214
215     TARIFF_DATA GetData()
216         {
217         TARIFF_DATA td;
218         td.tariffConf = tariffConf.GetData();
219         for (int i = 0; i < DIR_NUM; i++)
220             td.dirPrice[i] = dirPrice[i].GetData();
221         return td;
222         }
223 };
224 //-----------------------------------------------------------------------------
225 #endif