Add description for carry-over-settings
This commit is contained in:
parent
929a8a4a27
commit
3a18ee2d7c
61
library/include/mobilisis/tariff_carryover_settings.h
Normal file
61
library/include/mobilisis/tariff_carryover_settings.h
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
#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&,
|
||||||
|
QDateTime const &endTime, int paymentOptionIndex)>;
|
||||||
|
|
||||||
|
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())
|
||||||
|
, m_parkingTimeLimitChecker([](ATBTariffCarryOverSettings const&, QDateTime const &, int) { return false; })
|
||||||
|
, 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) {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool parkingTimeLimitExceeded(QDateTime const &endTime, int paymentOptionIndex) const {
|
||||||
|
return m_parkingTimeLimitChecker(*this, endTime, paymentOptionIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
Loading…
Reference in New Issue
Block a user