]> git.stg.codes - stg.git/blobdiff - include/stg/tariff.h
Ticket 37. The GetChangePolicy() virtual function is declared in the class TARIFF.
[stg.git] / include / stg / tariff.h
index 1b6413b302f3c56417d32683d530850dcc6eb5f9..4f36e6f85522098bab767d5d823f0681995b5728 100644 (file)
@@ -32,15 +32,21 @@ struct TARIFF_DATA;
 
 class TARIFF {
 public:
+    enum CHANGE_POLICY { ALLOW = 0, TO_CHEAP, TO_EXPENSIVE, DENY };
+
     enum PERIOD { DAY = 0, MONTH };
 
     enum TRAFF_TYPE { TRAFF_UP = 0, TRAFF_DOWN, TRAFF_UP_DOWN, TRAFF_MAX };
 
+    static std::string ChangePolicyToString(CHANGE_POLICY change_policy);
+    static CHANGE_POLICY StringToChangePolicy(const std::string& value);
+
     static std::string PeriodToString(PERIOD period);
     static PERIOD StringToPeriod(const std::string& value);
 
     static std::string TraffTypeToString(TRAFF_TYPE type);
     static TRAFF_TYPE StringToTraffType(const std::string& value);
+    static TRAFF_TYPE IntToTraffType(int value);
 
     virtual ~TARIFF() {}
     virtual double  GetPriceWithTraffType(uint64_t up,
@@ -52,6 +58,7 @@ public:
     virtual double  GetFee() const = 0;
     virtual double  GetFree() const = 0;
     virtual PERIOD  GetPeriod() const = 0;
+    virtual CHANGE_POLICY  GetChangePolicy() const = 0;
 
     virtual const   std::string & GetName() const = 0;
     virtual void    SetName(const std::string & name) = 0;
@@ -117,4 +124,12 @@ std::istream & operator>>(std::istream & stream, TARIFF::TRAFF_TYPE & traffType)
     return stream;
 }
 
+inline
+TARIFF::TRAFF_TYPE TARIFF::IntToTraffType(int value)
+{
+    if (value < 0 || value > TRAFF_MAX)
+        return TRAFF_UP_DOWN;
+    return static_cast<TRAFF_TYPE>(value);
+}
+
 #endif