X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/32215800f291d9653aa7f0f5c101956a8e3dd6b2..fcd0d9d5cd2d5e911366df52cc31efd82dae4503:/include/stg/tariff.h?ds=sidebyside diff --git a/include/stg/tariff.h b/include/stg/tariff.h index a2f6b42c..1371190b 100644 --- a/include/stg/tariff.h +++ b/include/stg/tariff.h @@ -58,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; @@ -68,6 +69,31 @@ public: virtual const TARIFF_DATA & GetTariffData() const = 0; }; +inline +std::string TARIFF::ChangePolicyToString(TARIFF::CHANGE_POLICY change_policy) +{ +switch (change_policy) + { + case ALLOW: return "allow"; + case TO_CHEAP: return "to_cheap"; + case TO_EXPENSIVE: return "to_expensive"; + case DENY: return "deny"; + } +return "allow"; // Classic behaviour. +} + +inline +TARIFF::CHANGE_POLICY TARIFF::StringToChangePolicy(const std::string& value) +{ +if (strcasecmp(value.c_str(), "to_cheap") == 0) + return TO_CHEAP; +if (strcasecmp(value.c_str(), "to_expensive") == 0) + return TO_EXPENSIVE; +if (strcasecmp(value.c_str(), "deny") == 0) + return DENY; +return ALLOW; // Classic behaviour. +} + inline std::string TARIFF::PeriodToString(TARIFF::PERIOD period) {