Add TariffTimeRange member to CalcState. Use in isParkingAllowed().
This commit is contained in:
parent
0b779b7846
commit
1467a69487
@ -3,6 +3,7 @@
|
||||
|
||||
#include <time.h>
|
||||
#include <inttypes.h>
|
||||
#include "tariff_time_range.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QDateTime>
|
||||
@ -63,8 +64,25 @@ struct CALCULATE_LIBRARY_API CalcState {
|
||||
|
||||
State m_status;
|
||||
QString m_desc;
|
||||
TariffTimeRange m_allowedTimeRange;
|
||||
|
||||
explicit CalcState() : m_status(State::SUCCESS), m_desc("") {}
|
||||
explicit CalcState()
|
||||
: m_status(State::SUCCESS)
|
||||
, m_desc("") {
|
||||
}
|
||||
|
||||
explicit CalcState(State state, QString desc = "")
|
||||
: m_status(state)
|
||||
, m_desc(desc) {
|
||||
}
|
||||
|
||||
explicit CalcState(State state, QString desc = "",
|
||||
QTime const &from = QTime(),
|
||||
QTime const &until = QTime())
|
||||
: m_status(state)
|
||||
, m_desc(desc)
|
||||
, m_allowedTimeRange(from, until) {
|
||||
}
|
||||
|
||||
explicit operator bool() const noexcept {
|
||||
return (m_status == State::SUCCESS);
|
||||
@ -108,6 +126,7 @@ struct CALCULATE_LIBRARY_API CalcState {
|
||||
break;
|
||||
case State::WRONG_ISO_TIME_FORMAT:
|
||||
s = "WRONG_ISO_TIME_FORMAT";
|
||||
break;
|
||||
case State::OUTSIDE_ALLOWED_PARKING_TIME:
|
||||
s = "OUTSIDE_ALLOWED_PARKING_TIME";
|
||||
}
|
||||
@ -116,6 +135,14 @@ struct CALCULATE_LIBRARY_API CalcState {
|
||||
|
||||
CalcState &set(State s) { m_status = s; return *this; }
|
||||
CalcState &setDesc(QString s) { m_desc = s; return *this; }
|
||||
|
||||
void setAllowedTimeRange(QTime const &from, QTime const &until) {
|
||||
m_allowedTimeRange.setTimeRange(from, until);
|
||||
}
|
||||
|
||||
TariffTimeRange getAllowedTimeRange() {
|
||||
return m_allowedTimeRange;
|
||||
}
|
||||
};
|
||||
|
||||
CalcState CALCULATE_LIBRARY_API init_tariff(parking_tariff_t **tariff,
|
||||
|
Loading…
Reference in New Issue
Block a user