]> git.stg.codes - stg.git/blob - projects/stargazer/tariff.h
Добавление исходников
[stg.git] / projects / stargazer / tariff.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  *    Date: 07.11.2007
19  */
20
21 /*
22  *    Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
23  */
24
25 /*
26  $Revision: 1.9 $
27  $Date: 2010/10/07 17:53:39 $
28  $Author: faust $
29  */
30
31 #ifndef TARIFF_H
32 #define TARIFF_H
33
34 #include <string>
35 #include <list>
36
37 #include "os_int.h"
38 #include "tariff_conf.h"
39
40 #define TARIFF_DAY     0
41 #define TARIFF_NIGHT   1
42
43 class TARIFF
44 {
45 public:
46     TARIFF()
47         : tariffData()
48     {};
49     TARIFF(const std::string & name)
50         : tariffData(name)
51     {};
52     TARIFF(const TARIFF_DATA & td)
53         : tariffData(td)
54     {};
55     TARIFF(const TARIFF & t)
56         : tariffData(t.tariffData)
57     {};
58     ~TARIFF() {};
59
60     double  GetPriceWithTraffType(uint64_t up,
61                                   uint64_t down,
62                                   int dir,
63                                   time_t t) const;
64     double  GetFreeMb() const { return tariffData.tariffConf.free; };
65     void    GetDirPrice(int dir, DIRPRICE_DATA * dd) const;
66     double  GetPassiveCost() const { return tariffData.tariffConf.passiveCost; };
67     double  GetFee() const { return tariffData.tariffConf.fee; };
68     double  GetFree() const { return tariffData.tariffConf.free; };
69
70     void    PrintTariff() const;
71
72     const   std::string & GetName() const { return tariffData.tariffConf.name; };
73     void    SetName(const std::string & name) { tariffData.tariffConf.name = name; };
74
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     void    GetTariffData(TARIFF_DATA * td) const;
79
80     TARIFF & operator=(const TARIFF_DATA & td);
81     TARIFF & operator=(const TARIFF & t);
82     bool     operator==(const TARIFF & rhs) const { return GetName() == rhs.GetName(); };
83     bool     operator!=(const TARIFF & rhs) const { return GetName() != rhs.GetName(); };
84
85 private:
86     TARIFF_DATA     tariffData;
87
88     double  GetPriceWithoutFreeMb(int dir, int mb, time_t t) const;
89     int     Interval(int dir, time_t t) const;
90 };
91 //-----------------------------------------------------------------------------
92
93 #endif