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