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 : Boris Mikhailenko <stg34@stargazer.dp.ua>
23 $Date: 2010/10/05 20:41:11 $
31 #include "resetable.h"
37 //-----------------------------------------------------------------------------
62 int singlePrice; // Do not use day/night division
63 int noDiscount; // Do not use threshold
65 //-----------------------------------------------------------------------------
66 struct DIRPRICE_DATA_RES
82 DIRPRICE_DATA_RES & operator= (const DIRPRICE_DATA & rvalue)
86 hNight = rvalue.hNight;
87 mNight = rvalue.mNight;
88 priceDayA = rvalue.priceDayA;
89 priceNightA = rvalue.priceNightA;
90 priceDayB = rvalue.priceDayB;
91 priceNightB = rvalue.priceNightB;
92 threshold = rvalue.threshold;
93 singlePrice = rvalue.singlePrice;
94 noDiscount = rvalue.noDiscount;
98 DIRPRICE_DATA GetData() const
101 hDay.maybeSet(dd.hDay);
102 hNight.maybeSet(dd.hNight);
103 mDay.maybeSet(dd.mDay);
104 mNight.maybeSet(dd.mNight);
105 noDiscount.maybeSet(dd.noDiscount);
106 priceDayA.maybeSet(dd.priceDayA);
107 priceDayB.maybeSet(dd.priceDayB);
108 priceNightA.maybeSet(dd.priceNightA);
109 priceNightB.maybeSet(dd.priceNightB);
110 singlePrice.maybeSet(dd.singlePrice);
111 threshold.maybeSet(dd.threshold);
115 void Splice(const DIRPRICE_DATA_RES & rhs)
117 hDay.splice(rhs.hDay);
118 mDay.splice(rhs.mDay);
119 hNight.splice(rhs.hNight);
120 mNight.splice(rhs.mNight);
121 priceDayA.splice(rhs.priceDayA);
122 priceNightA.splice(rhs.priceNightA);
123 priceDayB.splice(rhs.priceDayB);
124 priceNightB.splice(rhs.priceNightB);
125 threshold.splice(rhs.threshold);
126 singlePrice.splice(rhs.singlePrice);
127 noDiscount.splice(rhs.noDiscount);
132 RESETABLE<int> hNight;
133 RESETABLE<int> mNight;
134 RESETABLE<double> priceDayA;
135 RESETABLE<double> priceNightA;
136 RESETABLE<double> priceDayB;
137 RESETABLE<double> priceNightB;
138 RESETABLE<int> threshold;
139 RESETABLE<int> singlePrice;
140 RESETABLE<int> noDiscount;
142 //-----------------------------------------------------------------------------
147 TARIFF::TRAFF_TYPE traffType;
150 TARIFF::PERIOD period;
151 TARIFF::CHANGE_POLICY changePolicy;
156 traffType(TARIFF::TRAFF_UP_DOWN),
159 period(TARIFF::MONTH),
160 changePolicy(TARIFF::ALLOW)
163 TARIFF_CONF(const std::string & n)
166 traffType(TARIFF::TRAFF_UP_DOWN),
169 period(TARIFF::MONTH),
170 changePolicy(TARIFF::ALLOW)
173 //-----------------------------------------------------------------------------
174 struct TARIFF_CONF_RES
185 TARIFF_CONF_RES & operator=(const TARIFF_CONF & tc)
189 traffType = tc.traffType;
190 passiveCost = tc.passiveCost;
196 TARIFF_CONF GetData() const
199 fee.maybeSet(tc.fee);
200 free.maybeSet(tc.free);
201 name.maybeSet(tc.name);
202 passiveCost.maybeSet(tc.passiveCost);
203 traffType.maybeSet(tc.traffType);
204 period.maybeSet(tc.period);
208 RESETABLE<double> fee;
209 RESETABLE<double> free;
210 RESETABLE<TARIFF::TRAFF_TYPE> traffType;
211 RESETABLE<double> passiveCost;
212 RESETABLE<std::string> name;
213 RESETABLE<TARIFF::PERIOD> period;
215 //-----------------------------------------------------------------------------
218 TARIFF_CONF tariffConf;
219 std::vector<DIRPRICE_DATA> dirPrice;
226 TARIFF_DATA(const std::string & name)
231 TARIFF_DATA(const TARIFF_DATA & td)
232 : tariffConf(td.tariffConf),
233 dirPrice(td.dirPrice)
236 TARIFF_DATA & operator=(const TARIFF_DATA & td)
238 tariffConf = td.tariffConf;
239 dirPrice = td.dirPrice;
243 //-----------------------------------------------------------------------------
244 struct TARIFF_DATA_RES
246 TARIFF_CONF_RES tariffConf;
247 std::vector<DIRPRICE_DATA_RES> dirPrice;
254 TARIFF_DATA GetData() const
257 td.tariffConf = tariffConf.GetData();
258 for (size_t i = 0; i < DIR_NUM; i++)
259 td.dirPrice[i] = dirPrice[i].GetData();
263 //-----------------------------------------------------------------------------