##// END OF EJS Templates
Add qdebug operator for SqpDateTime to enable its display in a log
perrinel -
r296:c63ffe9f765e
parent child
Show More
@@ -1,28 +1,42
1 #ifndef SCIQLOP_SQPDATETIME_H
1 #ifndef SCIQLOP_SQPDATETIME_H
2 #define SCIQLOP_SQPDATETIME_H
2 #define SCIQLOP_SQPDATETIME_H
3
3
4 #include <QObject>
4 #include <QObject>
5
6 #include <QDateTime>
7 #include <QDebug>
8
5 /**
9 /**
6 * @brief The SqpDateTime struct holds the information of time parameters
10 * @brief The SqpDateTime struct holds the information of time parameters
7 */
11 */
8 struct SqpDateTime {
12 struct SqpDateTime {
9 /// Start time
13 /// Start time
10 double m_TStart;
14 double m_TStart;
11 /// End time
15 /// End time
12 double m_TEnd;
16 double m_TEnd;
13
17
14 bool contains(const SqpDateTime &dateTime)
18 bool contains(const SqpDateTime &dateTime)
15 {
19 {
16 return (m_TStart <= dateTime.m_TStart && m_TEnd >= dateTime.m_TEnd);
20 return (m_TStart <= dateTime.m_TStart && m_TEnd >= dateTime.m_TEnd);
17 }
21 }
18
22
19 bool intersect(const SqpDateTime &dateTime)
23 bool intersect(const SqpDateTime &dateTime)
20 {
24 {
21 return (m_TEnd >= dateTime.m_TStart && m_TStart <= dateTime.m_TEnd);
25 return (m_TEnd >= dateTime.m_TStart && m_TStart <= dateTime.m_TEnd);
22 }
26 }
23 };
27 };
24
28
29 inline QDebug operator<<(QDebug d, SqpDateTime obj)
30 {
31 auto tendDateTimeStart = QDateTime::fromMSecsSinceEpoch(obj.m_TStart * 1000);
32 auto tendDateTimeEnd = QDateTime::fromMSecsSinceEpoch(obj.m_TEnd * 1000);
33
34 // QDebug << "ts: " << tendDateTimeStart << " te: " << tendDateTimeEnd;
35 d << "ts: " << tendDateTimeStart << " te: " << tendDateTimeEnd;
36 return d;
37 }
38
25 // Required for using shared_ptr in signals/slots
39 // Required for using shared_ptr in signals/slots
26 Q_DECLARE_METATYPE(SqpDateTime)
40 Q_DECLARE_METATYPE(SqpDateTime)
27
41
28 #endif // SCIQLOP_SQPDATETIME_H
42 #endif // SCIQLOP_SQPDATETIME_H
General Comments 0
You need to be logged in to leave comments. Login now