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
22 * Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
27 $Date: 2010/10/07 17:53:39 $
34 #include "stg/tariff.h"
35 #include "stg/os_int.h"
36 #include "stg/tariff_conf.h"
44 #define TARIFF_NIGHT 1
46 class TARIFF_IMPL : public TARIFF {
48 explicit TARIFF_IMPL(const std::string & name)
52 explicit TARIFF_IMPL(const TARIFF_DATA & td)
56 virtual ~TARIFF_IMPL() {}
58 double GetPriceWithTraffType(uint64_t up,
62 double GetFreeMb() const { return tariffData.tariffConf.free; }
63 double GetPassiveCost() const { return tariffData.tariffConf.passiveCost; }
64 double GetFee() const { return tariffData.tariffConf.fee; }
65 double GetFree() const { return tariffData.tariffConf.free; }
66 PERIOD GetPeriod() const { return tariffData.tariffConf.period; }
67 CHANGE_POLICY GetChangePolicy() const { return tariffData.tariffConf.changePolicy; }
68 time_t GetChangePolicyTimeout() const { return tariffData.tariffConf.changePolicyTimeout; }
72 const std::string & GetName() const { return tariffData.tariffConf.name; }
73 void SetName(const std::string & name) { tariffData.tariffConf.name = name; }
75 int GetTraffType() const { return tariffData.tariffConf.traffType; }
76 int64_t GetTraffByType(uint64_t up, uint64_t down) const;
77 int GetThreshold(int dir) const;
78 const TARIFF_DATA & GetTariffData() const { return tariffData; }
80 TARIFF_IMPL & operator=(const TARIFF_DATA & td);
81 bool operator==(const TARIFF_IMPL & rhs) const { return GetName() == rhs.GetName(); }
82 bool operator!=(const TARIFF_IMPL & rhs) const { return GetName() != rhs.GetName(); }
83 std::string TariffChangeIsAllowed(const TARIFF & to, time_t currentTime) const;
86 TARIFF_DATA tariffData;
88 double GetPriceWithoutFreeMb(int dir, int64_t mb, time_t t) const;
89 int Interval(int dir, time_t t) const;