brainstorming ...
This commit is contained in:
parent
5cfca87f3e
commit
41a09d882d
20
library/include/mobilisis/tariff_comp_state.h
Normal file
20
library/include/mobilisis/tariff_comp_state.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#ifndef TARIFF_COMP_STATE_H_INCLUDED
|
||||||
|
#define TARIFF_COMP_STATE_H_INCLUDED
|
||||||
|
|
||||||
|
#include <QDateTime>
|
||||||
|
|
||||||
|
struct TariffCompState {
|
||||||
|
QDateTime const m_start;
|
||||||
|
int m_nettoParkingTimeTotal = 0;
|
||||||
|
int m_bruttoParkingTimeTotal = 0;
|
||||||
|
int m_priceTotal = 0;
|
||||||
|
|
||||||
|
explicit TariffCompState(QDateTime start)
|
||||||
|
: m_start(std::move(start))
|
||||||
|
, m_nettoParkingTimeTotal(0)
|
||||||
|
, m_bruttoParkingTimeTotal(0)
|
||||||
|
, m_priceTotal(0) {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TARIFF_COMP_STATE_H_INCLUDED
|
29
library/include/mobilisis/tariff_comp_step.h
Normal file
29
library/include/mobilisis/tariff_comp_step.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#ifndef TARIFF_COMP_STEP_H_INCLUDED
|
||||||
|
#define TARIFF_COMP_STEP_H_INCLUDED
|
||||||
|
|
||||||
|
#include <QDateTime>
|
||||||
|
#include "tariff_comp_state.h"
|
||||||
|
|
||||||
|
class TariffCompStep {
|
||||||
|
int m_duration;
|
||||||
|
QDateTime const m_start;
|
||||||
|
QDateTime const m_end;
|
||||||
|
uint64_t const m_handle;
|
||||||
|
TariffCompState m_compState;
|
||||||
|
|
||||||
|
uint64_t hash();
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit TariffCompStep(int duration, QDateTime start, QDateTime end, TariffCompState &compState)
|
||||||
|
: m_duration(duration)
|
||||||
|
, m_start(std::move(start))
|
||||||
|
, m_end(std::move(end))
|
||||||
|
, m_handle(hash())
|
||||||
|
, m_compState(compState) {
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t handle() { return m_handle; }
|
||||||
|
uint64_t handle() const { return m_handle; }
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TARIFF_COMP_STEP_H_INCLUDED
|
17
library/src/tariff_comp_step.cpp
Normal file
17
library/src/tariff_comp_step.cpp
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#include "tariff_comp_step.h"
|
||||||
|
|
||||||
|
#include <QByteArray>
|
||||||
|
#include <QCryptographicHash>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
uint64_t TariffCompStep::hash() {
|
||||||
|
QString const str(QString("%1%2%3").arg(m_duration).arg(m_start.toString(Qt::ISODate)).arg(m_end.toString(Qt::ISODate)));
|
||||||
|
QByteArray const hash = QCryptographicHash::hash(
|
||||||
|
QByteArray::fromRawData(reinterpret_cast<char const*>(str.utf16()), str.length()*2),
|
||||||
|
QCryptographicHash::Md5
|
||||||
|
);
|
||||||
|
|
||||||
|
uint64_t const &i = hash.left(8).toULongLong(nullptr, 16);
|
||||||
|
uint64_t const &j = hash.right(8).toULongLong(nullptr, 16);
|
||||||
|
return i ^ j;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user