67 lines
2.0 KiB
C++
67 lines
2.0 KiB
C++
#ifndef TICKET_H_INCLUDED
|
|
#define TICKET_H_INCLUDED
|
|
|
|
#include <tuple>
|
|
#include <vector>
|
|
|
|
#include <QDebug>
|
|
#include <QDebugStateSaver>
|
|
#include <QStringList>
|
|
#include <QDateTime>
|
|
|
|
#define NOT_INITIALIZED (0)
|
|
#define VALID (1)
|
|
#define INVALID_FROM_DATETIME (2)
|
|
#define INVALID_UNTIL_DATETIME (3)
|
|
#define INVALID_PRICE (4)
|
|
#define STATUS_END (5)
|
|
|
|
class Ticket {
|
|
enum {CODE=0, CODE_STR=1, CODE_DESC=3};
|
|
public:
|
|
using Status = std::tuple<int, char const*, char const*>;
|
|
|
|
explicit Ticket();
|
|
explicit Ticket(QDateTime const &s, QDateTime const &e,
|
|
int durationMinutesNetto, int durationMinutesBrutto,
|
|
uint32_t price, Status status);
|
|
|
|
explicit operator bool() { return std::get<CODE>(m_status) == VALID; }
|
|
operator QString();
|
|
|
|
Status getStatus() const;
|
|
QDateTime getValidFrom() const;
|
|
QDateTime getValidUntil() const;
|
|
uint32_t getPrice() const;
|
|
|
|
Status setStatus(Status status);
|
|
void setValidFrom(QDateTime const &validFrom);
|
|
void setValidUntil(QDateTime const &validUnil);
|
|
void setPrice(uint32_t price);
|
|
|
|
bool isValid() { return operator bool(); }
|
|
|
|
static constexpr const Status s[STATUS_END] = {
|
|
{NOT_INITIALIZED , "NOT_INITIALIZED" , "Ticket not initialized" },
|
|
{VALID , "VALID" , "Ticket is valid" },
|
|
{INVALID_FROM_DATETIME , "INVALID_FROM_DATETIME" , "Ticket has invalid start datetime"},
|
|
{INVALID_UNTIL_DATETIME, "INVALID_UNTIL_DATETIME", "Ticket has invalid end datetime" },
|
|
{INVALID_PRICE , "INVALID_PRICE" , "PARKING NOT ALLOWED: Ticket has invalid price" }
|
|
};
|
|
|
|
private:
|
|
Status m_status;
|
|
|
|
QDateTime m_validFrom;
|
|
QDateTime m_validUntil;
|
|
|
|
int m_durationMinutesNetto;
|
|
int m_durationMinutesBrutto;
|
|
|
|
uint32_t m_price;
|
|
};
|
|
|
|
QDebug operator<<(QDebug debug, Ticket::Status const &status);
|
|
|
|
#endif // TICKET_H_INCLUDED
|