#ifndef TARIFF_SERVICE_H_INCLUDED #define TARIFF_SERVICE_H_INCLUDED #include #include #include "time_range.h" enum class ApplyService { NEVER = 0, MATCH_PREV_DAY = 1, MATCH_NEXT_DAY = 2, ALWAYS = 3 }; struct ATBTariffService { int m_id; QString m_weekDay; QDate m_date; TimeRange m_range; ApplyService m_serviceIf; explicit ATBTariffService() : m_id(-1) , m_serviceIf(ApplyService::NEVER) { } void setServiceIf(QString const &sif) { if (sif == "never") { m_serviceIf = ApplyService::NEVER; } else if (sif == "match_prev_day") { m_serviceIf = ApplyService::MATCH_PREV_DAY; } else if (sif == "match_next_day") { m_serviceIf = ApplyService::MATCH_NEXT_DAY; } else if (sif == "always") { m_serviceIf = ApplyService::ALWAYS; } else { qCritical() << "ERROR unknown servcie application" << sif; } } ApplyService serviceIf() const { return m_serviceIf; } QString serviceIfStr() const { if (m_serviceIf == ApplyService::NEVER) { return "never"; } if (m_serviceIf == ApplyService::ALWAYS) { return "always"; } if (m_serviceIf == ApplyService::MATCH_PREV_DAY) { return "match prev day"; } if (m_serviceIf == ApplyService::MATCH_NEXT_DAY) { return "match next day"; } return QString("ERROR unknown service application: %1").arg(static_cast(m_serviceIf)); } friend QDebug operator<<(QDebug debug, ATBTariffService const &ts) { QDebugStateSaver saver(debug); debug.nospace() << "\nTariffService:\n" << " week day: " << ts.m_weekDay << "\n" << " date: " << ts.m_date.toString(Qt::ISODate) << "\n" << " id: " << ts.m_id << "\n" << " start: " << ts.m_range.m_start << "\n" << " end: " << ts.m_range.m_end << "\n" << " duration: " << ts.m_range.m_duration << "\n" << " prepaid if: " << ts.serviceIfStr() << endl; return debug; } }; #endif // TARIFF_SERVICE_H_INCLUDED