X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/90e389f6ec12e60a62c362296ffcf314feb5b03d..483782aff2b8842048b6535ef46d22bcbdb4ce55:/include/stg/tariff_conf.h diff --git a/include/stg/tariff_conf.h b/include/stg/tariff_conf.h index 31df4ec9..b554e14a 100644 --- a/include/stg/tariff_conf.h +++ b/include/stg/tariff_conf.h @@ -57,95 +57,117 @@ struct DIRPRICE_DATA singlePrice(0), noDiscount(0) {} - int hDay; - int mDay; - int hNight; - int mNight; - double priceDayA; - double priceNightA; - double priceDayB; - double priceNightB; - int threshold; - int singlePrice; // Do not use day/night division - int noDiscount; // Do not use threshold + int hDay; + int mDay; + int hNight; + int mNight; + double priceDayA; + double priceNightA; + double priceDayB; + double priceNightB; + int threshold; + int singlePrice; // Do not use day/night division + int noDiscount; // Do not use threshold }; //----------------------------------------------------------------------------- struct DIRPRICE_DATA_RES { - DIRPRICE_DATA_RES & operator= (const DIRPRICE_DATA & dpd) + DIRPRICE_DATA_RES() + : hDay(), + mDay(), + hNight(), + mNight(), + priceDayA(), + priceNightA(), + priceDayB(), + priceNightB(), + threshold(), + singlePrice(), + noDiscount() + {} + + DIRPRICE_DATA_RES & operator= (const DIRPRICE_DATA & rvalue) { - hDay = dpd.hDay; - mDay = dpd.mDay; - hNight = dpd.hNight; - mNight = dpd.mNight; - priceDayA = dpd.priceDayA; - priceNightA = dpd.priceNightA; - priceDayB = dpd.priceDayB; - priceNightB = dpd.priceNightB; - threshold = dpd.threshold; - singlePrice = dpd.singlePrice; - noDiscount = dpd.noDiscount; + hDay = rvalue.hDay; + mDay = rvalue.mDay; + hNight = rvalue.hNight; + mNight = rvalue.mNight; + priceDayA = rvalue.priceDayA; + priceNightA = rvalue.priceNightA; + priceDayB = rvalue.priceDayB; + priceNightB = rvalue.priceNightB; + threshold = rvalue.threshold; + singlePrice = rvalue.singlePrice; + noDiscount = rvalue.noDiscount; return *this; - }; + } - DIRPRICE_DATA GetData() + DIRPRICE_DATA GetData() const { DIRPRICE_DATA dd; - dd.hDay = hDay; - dd.hNight = hNight; - dd.mDay = mDay; - dd.mNight = mNight; - dd.noDiscount = noDiscount; - dd.priceDayA = priceDayA; - dd.priceDayB = priceDayB; - - dd.priceNightA = priceNightA; - dd.priceNightB = priceNightB; - dd.singlePrice = singlePrice; - dd.threshold = threshold; + dd.hDay = hDay.data(); + dd.hNight = hNight.data(); + dd.mDay = mDay.data(); + dd.mNight = mNight.data(); + dd.noDiscount = noDiscount.data(); + dd.priceDayA = priceDayA.data(); + dd.priceDayB = priceDayB.data(); + + dd.priceNightA = priceNightA.data(); + dd.priceNightB = priceNightB.data(); + dd.singlePrice = singlePrice.data(); + dd.threshold = threshold.data(); return dd; } - RESETABLE hDay; - RESETABLE mDay; - RESETABLE hNight; - RESETABLE mNight; - RESETABLE priceDayA; - RESETABLE priceNightA; - RESETABLE priceDayB; - RESETABLE priceNightB; - RESETABLE threshold; - RESETABLE singlePrice; - RESETABLE noDiscount; + RESETABLE hDay; + RESETABLE mDay; + RESETABLE hNight; + RESETABLE mNight; + RESETABLE priceDayA; + RESETABLE priceNightA; + RESETABLE priceDayB; + RESETABLE priceNightB; + RESETABLE threshold; + RESETABLE singlePrice; + RESETABLE noDiscount; }; //----------------------------------------------------------------------------- struct TARIFF_CONF { - double fee; // ÷ÅÌÉÞÉÎÁ ÁÂÏÎÐÌÁÔÙ - double free; // îÁ ËÁËÕÀ ÓÕÍÍÕ ÄÅÎÅÇ ÀÚÅÒ ËÁÞÁÅÔ ÂÅÓÐÌÁÔÎÏ - int traffType; // UP, DOWN, UP+DOWN, MAX - double passiveCost; // óÔÏÉÍÏÓÔØ ÚÁÍÏÒÏÚËÉ + double fee; + double free; + int traffType; + double passiveCost; std::string name; TARIFF_CONF() : fee(0), free(0), - traffType(TRAFF_UP_DOWN), // UP-DOWN + traffType(TRAFF_UP_DOWN), passiveCost(0), name() - {}; + {} TARIFF_CONF(const std::string & n) : fee(0), free(0), - traffType(TRAFF_UP_DOWN), // UP-DOWN + traffType(TRAFF_UP_DOWN), passiveCost(0), name(n) - {}; + {} }; //----------------------------------------------------------------------------- struct TARIFF_CONF_RES { + TARIFF_CONF_RES() + : fee(), + free(), + traffType(), + passiveCost(), + name() + {} + TARIFF_CONF_RES & operator=(const TARIFF_CONF & tc) { fee = tc.fee; @@ -154,30 +176,30 @@ struct TARIFF_CONF_RES passiveCost = tc.passiveCost; name = tc.name; return *this; - }; + } - TARIFF_CONF GetData() + TARIFF_CONF GetData() const { TARIFF_CONF tc; - tc.fee = fee; - tc.free = free; - tc.name = name; - tc.passiveCost = passiveCost; - tc.traffType = traffType; + tc.fee = fee.data(); + tc.free = free.data(); + tc.name = name.data(); + tc.passiveCost = passiveCost.data(); + tc.traffType = traffType.data(); return tc; } - RESETABLE fee; - RESETABLE free; - RESETABLE traffType; - RESETABLE passiveCost; - RESETABLE name; + RESETABLE fee; + RESETABLE free; + RESETABLE traffType; + RESETABLE passiveCost; + RESETABLE name; }; //----------------------------------------------------------------------------- struct TARIFF_DATA { - TARIFF_CONF tariffConf; - std::vector dirPrice; + TARIFF_CONF tariffConf; + std::vector dirPrice; TARIFF_DATA() : tariffConf(), @@ -199,12 +221,12 @@ struct TARIFF_DATA tariffConf = td.tariffConf; dirPrice = td.dirPrice; return *this; - }; + } }; //----------------------------------------------------------------------------- struct TARIFF_DATA_RES { - TARIFF_CONF_RES tariffConf; + TARIFF_CONF_RES tariffConf; std::vector dirPrice; TARIFF_DATA_RES() @@ -212,11 +234,11 @@ struct TARIFF_DATA_RES dirPrice(DIR_NUM) {} - TARIFF_DATA GetData() + TARIFF_DATA GetData() const { TARIFF_DATA td; td.tariffConf = tariffConf.GetData(); - for (int i = 0; i < DIR_NUM; i++) + for (size_t i = 0; i < DIR_NUM; i++) td.dirPrice[i] = dirPrice[i].GetData(); return td; }