2024-09-02 16:45:35 +02:00
|
|
|
#ifndef ATB_TARIFF_CARRYOVER_SETTINGS_H_INCLUDED
|
|
|
|
#define ATB_TARIFF_CARRYOVER_SETTINGS_H_INCLUDED
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QDateTime>
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
|
|
|
|
struct ATBTariffCarryOverSettings {
|
|
|
|
|
|
|
|
// parking time limit not violated: return false, otherwise: return true.
|
|
|
|
using ParkingTimeLimitChecker = std::function<bool(ATBTariffCarryOverSettings const&,
|
2024-09-03 11:10:24 +02:00
|
|
|
QDateTime const &startTime,
|
|
|
|
QDateTime const &endTime,
|
|
|
|
int paymentOptionIndex)>;
|
2024-09-02 16:45:35 +02:00
|
|
|
|
|
|
|
int m_duration;
|
|
|
|
QTime m_start;
|
|
|
|
QTime m_end;
|
|
|
|
ParkingTimeLimitChecker m_parkingTimeLimitChecker;
|
|
|
|
|
|
|
|
QTime m_parking_time_limit;
|
|
|
|
QTime m_about_to_exceed_parking_time_limit;
|
|
|
|
|
|
|
|
explicit ATBTariffCarryOverSettings()
|
|
|
|
: m_duration(0)
|
|
|
|
, m_start(QTime())
|
|
|
|
, m_end(QTime())
|
2024-09-03 11:10:24 +02:00
|
|
|
, m_parkingTimeLimitChecker([](ATBTariffCarryOverSettings const&,
|
|
|
|
QDateTime const&, QDateTime const&, int) { return false; })
|
2024-09-02 16:45:35 +02:00
|
|
|
, m_parking_time_limit(QTime())
|
|
|
|
, m_about_to_exceed_parking_time_limit(QTime()) {}
|
|
|
|
|
|
|
|
explicit ATBTariffCarryOverSettings(int duration, QTime const &start,
|
|
|
|
QTime const &end,
|
|
|
|
QTime const &parking_time_limit,
|
|
|
|
QTime const &about_to_exceed_parking_time_limit,
|
|
|
|
ParkingTimeLimitChecker parkingTimeLimitChecker)
|
|
|
|
: m_duration(duration)
|
|
|
|
, m_start(start)
|
|
|
|
, m_end(end)
|
|
|
|
, m_parkingTimeLimitChecker(std::move(parkingTimeLimitChecker))
|
|
|
|
, m_parking_time_limit(parking_time_limit)
|
|
|
|
, m_about_to_exceed_parking_time_limit(about_to_exceed_parking_time_limit) {
|
|
|
|
}
|
|
|
|
|
2024-09-03 11:10:24 +02:00
|
|
|
bool parkingTimeLimitExceeded(QDateTime const &startTime,
|
|
|
|
QDateTime const &endTime,
|
|
|
|
int paymentOptionIndex) const {
|
|
|
|
return m_parkingTimeLimitChecker(*this, startTime, endTime, paymentOptionIndex);
|
2024-09-02 16:45:35 +02:00
|
|
|
}
|
|
|
|
|
2024-09-11 11:39:16 +02:00
|
|
|
QTime const &parkingTimeLimit() const { return m_parking_time_limit; }
|
|
|
|
QTime &parkingTimeLimit() { return m_parking_time_limit; }
|
|
|
|
|
2024-09-02 16:45:35 +02:00
|
|
|
friend QDebug operator<<(QDebug debug, ATBTariffCarryOverSettings const &co) {
|
|
|
|
QDebugStateSaver saver(debug);
|
|
|
|
|
|
|
|
debug.nospace()
|
|
|
|
<< " duration: " << co.m_duration << "\n"
|
|
|
|
<< " start: " << co.m_start.toString(Qt::ISODate) << "\n"
|
|
|
|
<< " end: " << co.m_end.toString(Qt::ISODate) << "\n"
|
|
|
|
<< " parking_time_limit: " << co.m_parking_time_limit.toString(Qt::ISODate) << endl;
|
|
|
|
|
|
|
|
return debug;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ATB_TARIFF_CARRYOVER_SETTINGS_H_INCLUDED
|