SqpDateTime.h
43 lines
| 1.0 KiB
| text/x-c
|
CLexer
r191 | #ifndef SCIQLOP_SQPDATETIME_H | |||
#define SCIQLOP_SQPDATETIME_H | ||||
r234 | #include <QObject> | |||
r296 | ||||
#include <QDebug> | ||||
Alexandre Leroux
|
r488 | #include <Common/DateUtils.h> | ||
Alexandre Leroux
|
r308 | #include <Common/MetaTypes.h> | ||
r191 | /** | |||
* @brief The SqpDateTime struct holds the information of time parameters | ||||
*/ | ||||
struct SqpDateTime { | ||||
Alexandre Leroux
|
r491 | /// Start time (UTC) | ||
r191 | double m_TStart; | |||
Alexandre Leroux
|
r491 | /// End time (UTC) | ||
r191 | double m_TEnd; | |||
r228 | ||||
r318 | bool contains(const SqpDateTime &dateTime) const noexcept | |||
r228 | { | |||
return (m_TStart <= dateTime.m_TStart && m_TEnd >= dateTime.m_TEnd); | ||||
} | ||||
r258 | ||||
r318 | bool intersect(const SqpDateTime &dateTime) const noexcept | |||
r258 | { | |||
return (m_TEnd >= dateTime.m_TStart && m_TStart <= dateTime.m_TEnd); | ||||
} | ||||
r191 | }; | |||
r296 | inline QDebug operator<<(QDebug d, SqpDateTime obj) | |||
{ | ||||
Alexandre Leroux
|
r488 | auto tendDateTimeStart = DateUtils::dateTime(obj.m_TStart); | ||
auto tendDateTimeEnd = DateUtils::dateTime(obj.m_TEnd); | ||||
r296 | ||||
d << "ts: " << tendDateTimeStart << " te: " << tendDateTimeEnd; | ||||
return d; | ||||
} | ||||
r234 | // Required for using shared_ptr in signals/slots | |||
Alexandre Leroux
|
r308 | SCIQLOP_REGISTER_META_TYPE(SQPDATETIME_REGISTRY, SqpDateTime) | ||
r234 | ||||
r191 | #endif // SCIQLOP_SQPDATETIME_H | |||