##// END OF EJS Templates
Fixes Linux compilation
Alexandre Leroux -
r660:e4c0228e8d67
parent child
Show More
@@ -1,56 +1,58
1 1 #ifndef SCIQLOP_SQPRANGE_H
2 2 #define SCIQLOP_SQPRANGE_H
3 3
4 4 #include <QObject>
5 5
6 6 #include <QDebug>
7 7
8 8 #include <Common/DateUtils.h>
9 9 #include <Common/MetaTypes.h>
10 10
11 #include <cmath>
12
11 13 /**
12 14 * @brief The SqpRange struct holds the information of time parameters
13 15 */
14 16 struct SqpRange {
15 17 /// Start time (UTC)
16 18 double m_TStart;
17 19 /// End time (UTC)
18 20 double m_TEnd;
19 21
20 22 bool contains(const SqpRange &dateTime) const noexcept
21 23 {
22 24 return (m_TStart <= dateTime.m_TStart && m_TEnd >= dateTime.m_TEnd);
23 25 }
24 26
25 27 bool intersect(const SqpRange &dateTime) const noexcept
26 28 {
27 29 return (m_TEnd >= dateTime.m_TStart && m_TStart <= dateTime.m_TEnd);
28 30 }
29 31
30 32 bool operator==(const SqpRange &other) const
31 33 {
32 34 auto equals = [](const auto &v1, const auto &v2) {
33 35 return (std::isnan(v1) && std::isnan(v2)) || v1 == v2;
34 36 };
35 37
36 38 return equals(m_TStart, other.m_TStart) && equals(m_TEnd, other.m_TEnd);
37 39 }
38 40 bool operator!=(const SqpRange &other) const { return !(*this == other); }
39 41 };
40 42
41 43 const auto INVALID_RANGE
42 44 = SqpRange{std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN()};
43 45
44 46 inline QDebug operator<<(QDebug d, SqpRange obj)
45 47 {
46 48 auto tendDateTimeStart = DateUtils::dateTime(obj.m_TStart);
47 49 auto tendDateTimeEnd = DateUtils::dateTime(obj.m_TEnd);
48 50
49 51 d << "ts: " << tendDateTimeStart << " te: " << tendDateTimeEnd;
50 52 return d;
51 53 }
52 54
53 55 // Required for using shared_ptr in signals/slots
54 56 SCIQLOP_REGISTER_META_TYPE(SQPRANGE_REGISTRY, SqpRange)
55 57
56 58 #endif // SCIQLOP_SQPRANGE_H
General Comments 0
You need to be logged in to leave comments. Login now