]> git.stg.codes - stg.git/blobdiff - include/stg/tariff.h
Ticket 26. The SETTINGS_IMPL & operator() declaration added.
[stg.git] / include / stg / tariff.h
index 1b6413b302f3c56417d32683d530850dcc6eb5f9..5d01cba08886be4087aced98c1305b072e16ef05 100644 (file)
@@ -41,6 +41,7 @@ public:
 
     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,
@@ -117,4 +118,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