Add Interpolation, Prepaid and CarryOver structures to streamline Json-File layout.
This commit is contained in:
parent
c153652b3d
commit
507b5d1b9c
70
library/include/mobilisis/tariff_carryover.h
Normal file
70
library/include/mobilisis/tariff_carryover.h
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
#ifndef TARIFF_CARRYOVER_H_INCLUDED
|
||||||
|
#define TARIFF_CARRYOVER_H_INCLUDED
|
||||||
|
|
||||||
|
#include <QTime>
|
||||||
|
|
||||||
|
struct ATBCarryOver {
|
||||||
|
struct week {
|
||||||
|
int day;
|
||||||
|
bool seemless;
|
||||||
|
bool never;
|
||||||
|
QTime static_start;
|
||||||
|
QTime static_end;
|
||||||
|
} carryover[8];
|
||||||
|
|
||||||
|
int id;
|
||||||
|
|
||||||
|
|
||||||
|
friend QDebug operator<<(QDebug debug, ATBCarryOver const &co) {
|
||||||
|
QDebugStateSaver saver(debug);
|
||||||
|
|
||||||
|
debug.nospace()
|
||||||
|
<< " id:" << co.id << "\n"
|
||||||
|
<< " **** Monday **** \n"
|
||||||
|
<< " day: " << co.carryover[(int)Qt::Monday].day << "\n"
|
||||||
|
<< " static_start: " << co.carryover[(int)Qt::Monday].static_start.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " static_end: " << co.carryover[(int)Qt::Monday].static_end.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " anytime: " << co.carryover[(int)Qt::Monday].seemless << "\n"
|
||||||
|
<< " never: " << co.carryover[(int)Qt::Monday].never << "\n"
|
||||||
|
<< " **** Tuesday **** \n"
|
||||||
|
<< " day: " << co.carryover[(int)Qt::Tuesday].day << "\n"
|
||||||
|
<< " static_start: " << co.carryover[(int)Qt::Tuesday].static_start.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " static_end: " << co.carryover[(int)Qt::Tuesday].static_end.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " anytime: " << co.carryover[(int)Qt::Tuesday].seemless << "\n"
|
||||||
|
<< " never: " << co.carryover[(int)Qt::Tuesday].never << "\n"
|
||||||
|
<< " **** Wednesday **** \n"
|
||||||
|
<< " day: " << co.carryover[(int)Qt::Wednesday].day << "\n"
|
||||||
|
<< " static_start: " << co.carryover[(int)Qt::Wednesday].static_start.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " static_end: " << co.carryover[(int)Qt::Wednesday].static_end.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " anytime: " << co.carryover[(int)Qt::Wednesday].seemless << "\n"
|
||||||
|
<< " never: " << co.carryover[(int)Qt::Wednesday].never << "\n"
|
||||||
|
<< " **** Thursday **** \n"
|
||||||
|
<< " day: " << co.carryover[(int)Qt::Thursday].day << "\n"
|
||||||
|
<< " static_start: " << co.carryover[(int)Qt::Thursday].static_start.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " static_end: " << co.carryover[(int)Qt::Thursday].static_end.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " anytime: " << co.carryover[(int)Qt::Thursday].seemless << "\n"
|
||||||
|
<< " never: " << co.carryover[(int)Qt::Thursday].never << "\n"
|
||||||
|
<< " **** Friday **** \n"
|
||||||
|
<< " day: " << co.carryover[(int)Qt::Friday].day << "\n"
|
||||||
|
<< " static_start: " << co.carryover[(int)Qt::Friday].static_start.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " static_end: " << co.carryover[(int)Qt::Friday].static_end.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " anytime: " << co.carryover[(int)Qt::Friday].seemless << "\n"
|
||||||
|
<< " never: " << co.carryover[(int)Qt::Friday].never << "\n"
|
||||||
|
<< " **** Saturday **** \n"
|
||||||
|
<< " day: " << co.carryover[(int)Qt::Saturday].day << "\n"
|
||||||
|
<< " static_start: " << co.carryover[(int)Qt::Saturday].static_start.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " static_end: " << co.carryover[(int)Qt::Saturday].static_end.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " anytime: " << co.carryover[(int)Qt::Saturday].seemless << "\n"
|
||||||
|
<< " never: " << co.carryover[(int)Qt::Saturday].never << "\n"
|
||||||
|
<< " **** Sunday **** \n"
|
||||||
|
<< " day: " << co.carryover[(int)Qt::Sunday].day << "\n"
|
||||||
|
<< " static_start: " << co.carryover[(int)Qt::Sunday].static_start.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " static_end: " << co.carryover[(int)Qt::Sunday].static_end.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " anytime: " << co.carryover[(int)Qt::Sunday].seemless << "\n"
|
||||||
|
<< " never: " << co.carryover[(int)Qt::Sunday].never << "\n";
|
||||||
|
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TARIFF_CARRYOVER_H_INCLUDED
|
89
library/include/mobilisis/tariff_interpolation.h
Normal file
89
library/include/mobilisis/tariff_interpolation.h
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
#ifndef TARIFF_INTERPOLATION_H_INCLUDED
|
||||||
|
#define TARIFF_INTERPOLATION_H_INCLUDED
|
||||||
|
|
||||||
|
#include <QTime>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
struct ATBInterpolation {
|
||||||
|
|
||||||
|
enum Type {
|
||||||
|
NO_INTERPOLATION = 1,
|
||||||
|
STATIC_WALLCLOCK_TIME_VALUES = 2,
|
||||||
|
STATIC_TIMEPOINT_AND_DURATION = 3,
|
||||||
|
DYNAMIC_TIMEPOINT_AND_STATIC_DURATION = 4,
|
||||||
|
DYNAMIC_ABSTRACT_TIMEPOINT_AND_STATIC_DURATION = 5,
|
||||||
|
DYNAMIC_ABSTRACT_TIMEPOINT_AND_PRICE = 6,
|
||||||
|
DYNAMIC_ABSTRACT_TIMEPOINT_AND_STATIC_END_TIME = 7
|
||||||
|
};
|
||||||
|
|
||||||
|
static QString name(int i) {
|
||||||
|
switch(i) {
|
||||||
|
case (int)(NO_INTERPOLATION):
|
||||||
|
return QString("%1: NO_INTERPOLATION").arg(i);
|
||||||
|
case (int)(STATIC_WALLCLOCK_TIME_VALUES):
|
||||||
|
return QString("%1: STATIC_WALLCLOCK_TIME_VALUES").arg(i);
|
||||||
|
case (int)(STATIC_TIMEPOINT_AND_DURATION):
|
||||||
|
return QString("%1: STATIC_TIMEPOINT_AND_DURATION").arg(i);
|
||||||
|
case (int)(DYNAMIC_TIMEPOINT_AND_STATIC_DURATION):
|
||||||
|
return QString("%1: DYNAMIC_TIMEPOINT_AND_STATIC_DURATION").arg(i);
|
||||||
|
case (int)(DYNAMIC_ABSTRACT_TIMEPOINT_AND_STATIC_DURATION):
|
||||||
|
return QString("%1: DYNAMIC_ABSTRACT_TIMEPOINT_AND_STATIC_DURATION").arg(i);
|
||||||
|
case (int)(DYNAMIC_ABSTRACT_TIMEPOINT_AND_PRICE):
|
||||||
|
return QString("%1: DYNAMIC_ABSTRACT_TIMEPOINT_AND_PRICE").arg(i);
|
||||||
|
case (int)(DYNAMIC_ABSTRACT_TIMEPOINT_AND_STATIC_END_TIME):
|
||||||
|
return QString("%1: DYNAMIC_ABSTRACT_TIMEPOINT_AND_STATIC_END_TIME").arg(i);
|
||||||
|
default:;
|
||||||
|
}
|
||||||
|
return "ERROR";
|
||||||
|
}
|
||||||
|
|
||||||
|
explicit ATBInterpolation()
|
||||||
|
: id(0)
|
||||||
|
, static_start(QTime())
|
||||||
|
, static_end(QTime())
|
||||||
|
, static_start_str(QString())
|
||||||
|
, static_end_str(QString())
|
||||||
|
, static_duration(0)
|
||||||
|
, dynamic_start(QTime())
|
||||||
|
, dynamic_end(QTime())
|
||||||
|
, dynamic_start_str(QString())
|
||||||
|
, dynamic_end_str(QString())
|
||||||
|
, dynamic_duration(0)
|
||||||
|
, dynamic_until_price(0) {
|
||||||
|
}
|
||||||
|
|
||||||
|
int id;
|
||||||
|
QTime static_start;
|
||||||
|
QTime static_end;
|
||||||
|
QString static_start_str;
|
||||||
|
QString static_end_str;
|
||||||
|
int static_duration;
|
||||||
|
QTime dynamic_start;
|
||||||
|
QTime dynamic_end;
|
||||||
|
QString dynamic_start_str;
|
||||||
|
QString dynamic_end_str;
|
||||||
|
int dynamic_duration;
|
||||||
|
int dynamic_until_price;
|
||||||
|
|
||||||
|
friend QDebug operator<<(QDebug debug, ATBInterpolation const &i) {
|
||||||
|
QDebugStateSaver saver(debug);
|
||||||
|
|
||||||
|
debug.nospace()
|
||||||
|
<< " id: " << name(i.id) << "\n"
|
||||||
|
<< " static_start: " << i.static_start.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " static_end: " << i.static_end.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " static_start_str: " << i.static_start_str << "\n"
|
||||||
|
<< " static_end_str: " << i.static_end_str << "\n"
|
||||||
|
<< " static_duration: " << i.static_duration << "\n"
|
||||||
|
<< " dynamic_start: " << i.dynamic_start.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " dynamic_end: " << i.dynamic_end.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " dynamic_start_str: " << i.dynamic_start_str << "\n"
|
||||||
|
<< " dynamic_end_str: " << i.dynamic_end_str << "\n"
|
||||||
|
<< " dynamic_duration: " << i.dynamic_duration << "\n"
|
||||||
|
<< "dynamic_until_price: " << i.dynamic_until_price << "\n";
|
||||||
|
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TARIFF_INTERPOLATION_H_INCLUDED
|
29
library/include/mobilisis/tariff_prepaid.h
Normal file
29
library/include/mobilisis/tariff_prepaid.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#ifndef TARIFF_PREPAID_H_INCLUDED
|
||||||
|
#define TARIFF_PREPAID_H_INCLUDED
|
||||||
|
|
||||||
|
#include <QTime>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
struct ATBPrepaid {
|
||||||
|
explicit ATBPrepaid() = default;
|
||||||
|
int id;
|
||||||
|
bool anytime;
|
||||||
|
bool never;
|
||||||
|
QTime static_start;
|
||||||
|
QTime static_end;
|
||||||
|
|
||||||
|
friend QDebug operator<<(QDebug debug, ATBPrepaid const &pp) {
|
||||||
|
QDebugStateSaver saver(debug);
|
||||||
|
|
||||||
|
debug.nospace()
|
||||||
|
<< " id: " << pp.id << "\n"
|
||||||
|
<< " static_start: " << pp.static_start.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " static_end: " << pp.static_end.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " anytime: " << pp.anytime << "\n"
|
||||||
|
<< " never: " << pp.never << "\n";
|
||||||
|
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TARIFF_PREPAID_H_INCLUDED
|
Loading…
Reference in New Issue
Block a user