X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/c02633d77cb05a5deb05440d77b12ccc5bc19b85..a91e9542b384905187890f161d4da5396996fcfd:/include/stg/tariff_conf.h diff --git a/include/stg/tariff_conf.h b/include/stg/tariff_conf.h index d7336157..0a4f988b 100644 --- a/include/stg/tariff_conf.h +++ b/include/stg/tariff_conf.h @@ -21,11 +21,12 @@ #pragma once #include "tariff.h" -#include "stg/optional.h" #include "const.h" +#include "splice.h" #include #include +#include namespace STG { @@ -105,47 +106,47 @@ struct DirPriceDataOpt void splice(const DirPriceDataOpt & rhs) noexcept { - hDay.splice(rhs.hDay); - mDay.splice(rhs.mDay); - hNight.splice(rhs.hNight); - mNight.splice(rhs.mNight); - priceDayA.splice(rhs.priceDayA); - priceNightA.splice(rhs.priceNightA); - priceDayB.splice(rhs.priceDayB); - priceNightB.splice(rhs.priceNightB); - threshold.splice(rhs.threshold); - singlePrice.splice(rhs.singlePrice); - noDiscount.splice(rhs.noDiscount); + STG::splice(hDay, rhs.hDay); + STG::splice(mDay, rhs.mDay); + STG::splice(hNight, rhs.hNight); + STG::splice(mNight, rhs.mNight); + STG::splice(priceDayA, rhs.priceDayA); + STG::splice(priceNightA, rhs.priceNightA); + STG::splice(priceDayB, rhs.priceDayB); + STG::splice(priceNightB, rhs.priceNightB); + STG::splice(threshold, rhs.threshold); + STG::splice(singlePrice, rhs.singlePrice); + STG::splice(noDiscount, rhs.noDiscount); } DirPriceData get(const DirPriceData& defaultValue) const noexcept { DirPriceData res; - res.hDay = hDay.get(defaultValue.hDay); - res.mDay = mDay.get(defaultValue.mDay); - res.hNight = hNight.get(defaultValue.hNight); - res.mNight = mNight.get(defaultValue.mNight); - res.priceDayA = priceDayA.get(defaultValue.priceDayA); - res.priceNightA = priceNightA.get(defaultValue.priceNightA); - res.priceDayB = priceDayB.get(defaultValue.priceDayB); - res.priceNightB = priceNightB.get(defaultValue.priceNightB); - res.threshold = threshold.get(defaultValue.threshold); - res.singlePrice = singlePrice.get(defaultValue.singlePrice); - res.noDiscount = noDiscount.get(defaultValue.noDiscount); + res.hDay = hDay.value_or(defaultValue.hDay); + res.mDay = mDay.value_or(defaultValue.mDay); + res.hNight = hNight.value_or(defaultValue.hNight); + res.mNight = mNight.value_or(defaultValue.mNight); + res.priceDayA = priceDayA.value_or(defaultValue.priceDayA); + res.priceNightA = priceNightA.value_or(defaultValue.priceNightA); + res.priceDayB = priceDayB.value_or(defaultValue.priceDayB); + res.priceNightB = priceNightB.value_or(defaultValue.priceNightB); + res.threshold = threshold.value_or(defaultValue.threshold); + res.singlePrice = singlePrice.value_or(defaultValue.singlePrice); + res.noDiscount = noDiscount.value_or(defaultValue.noDiscount); return res; } - Optional hDay; - Optional mDay; - Optional hNight; - Optional mNight; - Optional priceDayA; - Optional priceNightA; - Optional priceDayB; - Optional priceNightB; - Optional threshold; - Optional singlePrice; - Optional noDiscount; + std::optional hDay; + std::optional mDay; + std::optional hNight; + std::optional mNight; + std::optional priceDayA; + std::optional priceNightA; + std::optional priceDayB; + std::optional priceNightB; + std::optional threshold; + std::optional singlePrice; + std::optional noDiscount; }; //----------------------------------------------------------------------------- struct TariffConf @@ -220,25 +221,25 @@ struct TariffConfOpt TariffConf get(const TariffConf& defaultValue) const noexcept { TariffConf res; - res.fee = fee.get(defaultValue.fee); - res.free = free.get(defaultValue.free); - res.traffType = traffType.get(defaultValue.traffType); - res.passiveCost = passiveCost.get(defaultValue.passiveCost); - res.name = name.get(defaultValue.name); - res.period = period.get(defaultValue.period); - res.changePolicy = changePolicy.get(defaultValue.changePolicy); - res.changePolicyTimeout = changePolicyTimeout.get(defaultValue.changePolicyTimeout); + res.fee = fee.value_or(defaultValue.fee); + res.free = free.value_or(defaultValue.free); + res.traffType = traffType.value_or(defaultValue.traffType); + res.passiveCost = passiveCost.value_or(defaultValue.passiveCost); + res.name = name.value_or(defaultValue.name); + res.period = period.value_or(defaultValue.period); + res.changePolicy = changePolicy.value_or(defaultValue.changePolicy); + res.changePolicyTimeout = changePolicyTimeout.value_or(defaultValue.changePolicyTimeout); return res; } - Optional fee; - Optional free; - Optional traffType; - Optional passiveCost; - Optional name; - Optional period; - Optional changePolicy; - Optional changePolicyTimeout; + std::optional fee; + std::optional free; + std::optional traffType; + std::optional passiveCost; + std::optional name; + std::optional period; + std::optional changePolicy; + std::optional changePolicyTimeout; }; //----------------------------------------------------------------------------- struct TariffData