ATLAS Offline Software
Loading...
Searching...
No Matches
IOVTime.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef ATHENAKERNEL_IOVTIME_H
6#define ATHENAKERNEL_IOVTIME_H
7
19
20#include <iosfwd>
21#include <string>
22#include <stdint.h>
23#include <limits>
24
25class MsgStream;
26class EventIDBase;
27
33class IOVTime {
34
35private:
42
43public:
44 static constexpr uint32_t MINRUN = std::numeric_limits<uint32_t>::min();
45
46 // We remove the top bit from MAXRUN to allow use of this to set
47 // CondDBKey which has a sign bit
48 static constexpr uint32_t MAXRUN = (std::numeric_limits<uint32_t>::max() >> 1);
49
50 static constexpr uint32_t MINEVENT = std::numeric_limits<uint32_t>::min();
51 static constexpr uint32_t MAXEVENT = (std::numeric_limits<uint32_t>::max());
52
53 static constexpr uint64_t MAXRETIME =( ((uint64_t) IOVTime::MAXRUN << 32) + IOVTime::MAXEVENT );
54 static constexpr uint64_t UNDEFRETIME = std::numeric_limits<uint64_t>::max();
55
56 static constexpr uint64_t MINTIMESTAMP = std::numeric_limits<uint64_t>::min();
57 // Set MAXTIMESTAMP to 63 bit max
58 static constexpr uint64_t MAXTIMESTAMP = (std::numeric_limits<uint64_t>::max() >> 1);
59 static constexpr uint64_t UNDEFTIMESTAMP = std::numeric_limits<uint64_t>::max();
60
61public:
67 public:
68 bool operator() ( const IOVTime& t1, const IOVTime& t2 ) const noexcept {
69 return t1.timestamp() > t2.timestamp();
70 }
71 bool operator() ( const IOVTime* t1, const IOVTime* t2 ) const noexcept {
72 return t1->timestamp() > t2->timestamp();
73 }
74 };
75
81 public:
82 bool operator() ( const IOVTime& t1, const IOVTime& t2 ) const noexcept {
83 return t1.re_time() > t2.re_time();
84 }
85 bool operator() ( const IOVTime* t1, const IOVTime* t2 ) const noexcept {
86 return t1->re_time() > t2->re_time();
87 }
88 };
89
90public:
95 explicit IOVTime( uint32_t run, uint32_t event );
96 explicit IOVTime( uint32_t run, uint32_t event,
97 uint64_t timestamp );
98 IOVTime( const EventIDBase& eid);
99
100 void setTimestamp( uint64_t timestamp ) noexcept;
101 void setRETime( uint64_t time ) noexcept;
102 void setRunEvent( uint32_t run, uint32_t event ) noexcept;
103 void reset() noexcept;
104
105 inline uint32_t run() const noexcept { return static_cast<uint32_t> (m_time>>32); }
106 inline uint32_t event() const noexcept { return static_cast<uint32_t> (m_time & 0xFFFFFFFF); }
107 inline uint64_t re_time() const noexcept { return m_time; }
108 inline uint64_t timestamp() const noexcept { return m_timestamp; }
109
110 bool isValid() const noexcept;
111 inline bool isTimestamp() const noexcept { return (m_status == IOVTime::TIMESTAMP ||
112 m_status== IOVTime::BOTH) ? 1 : 0; }
113 inline bool isRunEvent() const noexcept { return (m_status == IOVTime::RUN_EVT ||
114 m_status == IOVTime::BOTH) ? 1 : 0; }
115 inline bool isBoth() const noexcept { return (m_status == IOVTime::BOTH) ? 1 : 0; }
116
117 operator std::string() const;
118 operator EventIDBase() const;
119
120 friend bool operator<(const IOVTime& lhs, const IOVTime& rhs) noexcept;
121 friend bool operator>(const IOVTime& lhs, const IOVTime& rhs) noexcept;
122 friend bool operator==(const IOVTime& lhs, const IOVTime& rhs) noexcept;
123 friend bool operator!=(const IOVTime& lhs, const IOVTime& rhs) noexcept;
124 friend bool operator>=(const IOVTime& lhs, const IOVTime& rhs) noexcept;
125 friend bool operator<=(const IOVTime& lhs, const IOVTime& rhs) noexcept;
126
127 friend std::ostream& operator<<(std::ostream& os, const IOVTime& rhs);
128 friend MsgStream& operator<<(MsgStream& os, const IOVTime& rhs);
129
130private:
131
133 uint64_t m_time;
134 uint64_t m_timestamp;
135};
136
137inline bool operator<(const IOVTime& lhs, const IOVTime& rhs) noexcept {
138 if (lhs.isTimestamp() && rhs.isTimestamp()) {
139 return lhs.m_timestamp < rhs.m_timestamp;
140 } else {
141 return lhs.m_time < rhs.m_time;
142 }
143}
144inline bool operator>(const IOVTime& lhs, const IOVTime& rhs) noexcept {
145 if (lhs.isTimestamp() && rhs.isTimestamp()) {
146 return lhs.m_timestamp > rhs.m_timestamp;
147 } else {
148 return lhs.m_time > rhs.m_time;
149 }
150}
151inline bool operator==(const IOVTime& lhs, const IOVTime& rhs) noexcept {
152 if (lhs.isTimestamp() && rhs.isTimestamp()) {
153 return lhs.m_timestamp == rhs.m_timestamp;
154 } else {
155 return lhs.m_time == rhs.m_time;
156 }
157}
158inline bool operator!=(const IOVTime& lhs, const IOVTime& rhs) noexcept {
159 return !(lhs == rhs) ;
160}
161inline bool operator>=(const IOVTime& lhs, const IOVTime& rhs) noexcept {
162 return !( lhs < rhs );
163}
164inline bool operator<=(const IOVTime& lhs, const IOVTime& rhs) noexcept {
165 return !( lhs > rhs );
166}
167
168// template < class STR >
169// inline STR& operator << (STR& os, const IOVTime& rhs) {
170// os << rhs.m_time << ": [" << (rhs.m_time>>32) << ","
171// << ( rhs.m_time & 0xFFFFFFFF ) << "]";
172// return os;
173// }
174
175#endif
176
bool operator>=(const IOVTime &lhs, const IOVTime &rhs) noexcept
Definition IOVTime.h:161
bool operator!=(const IOVTime &lhs, const IOVTime &rhs) noexcept
Definition IOVTime.h:158
bool operator==(const IOVTime &lhs, const IOVTime &rhs) noexcept
Definition IOVTime.h:151
bool operator<(const IOVTime &lhs, const IOVTime &rhs) noexcept
Definition IOVTime.h:137
bool operator<=(const IOVTime &lhs, const IOVTime &rhs) noexcept
Definition IOVTime.h:164
bool operator>(const IOVTime &lhs, const IOVTime &rhs) noexcept
Definition IOVTime.h:144
bool operator()(const IOVTime &t1, const IOVTime &t2) const noexcept
Definition IOVTime.h:82
bool operator()(const IOVTime &t1, const IOVTime &t2) const noexcept
Definition IOVTime.h:68
Basic time unit for IOVSvc.
Definition IOVTime.h:33
static constexpr uint64_t MAXTIMESTAMP
Definition IOVTime.h:58
static constexpr uint32_t MAXRUN
Definition IOVTime.h:48
void reset() noexcept
Definition IOVTime.cxx:108
friend bool operator>=(const IOVTime &lhs, const IOVTime &rhs) noexcept
Definition IOVTime.h:161
bool isBoth() const noexcept
Definition IOVTime.h:115
IOVTime(uint64_t timestamp)
Definition IOVTime.h:93
void setRETime(uint64_t time) noexcept
Definition IOVTime.cxx:84
void setRunEvent(uint32_t run, uint32_t event) noexcept
Definition IOVTime.cxx:96
uint32_t event() const noexcept
Definition IOVTime.h:106
friend bool operator!=(const IOVTime &lhs, const IOVTime &rhs) noexcept
Definition IOVTime.h:158
friend bool operator==(const IOVTime &lhs, const IOVTime &rhs) noexcept
Definition IOVTime.h:151
uint64_t timestamp() const noexcept
Definition IOVTime.h:108
IOVTime_type
Definition IOVTime.h:36
@ UNDEF
Definition IOVTime.h:37
@ TIMESTAMP
Definition IOVTime.h:38
@ BOTH
Definition IOVTime.h:40
@ RUN_EVT
Definition IOVTime.h:39
bool isValid() const noexcept
Definition IOVTime.cxx:117
static constexpr uint32_t MINEVENT
Definition IOVTime.h:50
friend bool operator<(const IOVTime &lhs, const IOVTime &rhs) noexcept
Definition IOVTime.h:137
friend bool operator<=(const IOVTime &lhs, const IOVTime &rhs) noexcept
Definition IOVTime.h:164
static constexpr uint64_t MINTIMESTAMP
Definition IOVTime.h:56
static constexpr uint64_t UNDEFTIMESTAMP
Definition IOVTime.h:59
void setTimestamp(uint64_t timestamp) noexcept
Definition IOVTime.cxx:72
static constexpr uint64_t UNDEFRETIME
Definition IOVTime.h:54
static constexpr uint32_t MAXEVENT
Definition IOVTime.h:51
IOVTime_type m_status
Definition IOVTime.h:132
uint64_t re_time() const noexcept
Definition IOVTime.h:107
uint64_t m_time
Definition IOVTime.h:133
static constexpr uint32_t MINRUN
Definition IOVTime.h:44
bool isTimestamp() const noexcept
Definition IOVTime.h:111
friend std::ostream & operator<<(std::ostream &os, const IOVTime &rhs)
Definition IOVTime.cxx:192
IOVTime()
Definition IOVTime.h:91
uint64_t m_timestamp
Definition IOVTime.h:134
friend bool operator>(const IOVTime &lhs, const IOVTime &rhs) noexcept
Definition IOVTime.h:144
bool isRunEvent() const noexcept
Definition IOVTime.h:113
static constexpr uint64_t MAXRETIME
Definition IOVTime.h:53
Definition run.py:1