EventIDRange.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_EVENTIDRANGE_H
2 #define GAUDIKERNEL_EVENTIDRANGE_H 1
3 
14 #include <iostream>
15 #include <string>
16 #include <sstream>
17 
23 class EventIDRange {
24 public:
26  EventIDRange( const EventIDBase& start, const EventIDBase& stop );
29 
30  EventIDBase start() const { return m_start; }
31  EventIDBase stop() const { return m_stop; }
32 
33  bool isInRange(const EventIDBase& t) const {
34  return ( t>=m_start && t<m_stop );
35  }
36 
37  static EventIDRange intersect(const EventIDRange& it) { return it; }
38  template <typename ... T>
39  static EventIDRange intersect(const EventIDRange& first, const T& ... rest) {
40  EventIDRange r = intersect(rest...);
41 
42  EventIDBase i1 = std::max(first.start(), r.start());
43  EventIDBase i2 = std::min(first.stop(), r.stop());
44 
45  return EventIDRange(i1,i2);
46  }
47 
48  friend bool operator==(const EventIDRange& lhs, const EventIDRange& rhs);
49  friend bool operator!=(const EventIDRange& lhs, const EventIDRange& rhs);
50 
51  friend std::ostream& operator<<(std::ostream& os, const EventIDRange& rhs);
52 
53  operator std::string() const;
54 
55 private:
56 
59 
60 };
61 
62 inline bool operator==(const EventIDRange& lhs, const EventIDRange& rhs) {
63  return lhs.m_start==rhs.m_start &&
64  lhs.m_stop==rhs.m_stop ;
65 }
66 
67 inline bool operator!=(const EventIDRange& lhs, const EventIDRange& rhs) {
68  return ! (lhs == rhs);
69 }
70 
71 inline EventIDRange::operator std::string () const {
73  os << "{" << m_start << " - " << m_stop << "}";
74  return os.str();
75 }
76 
77 #endif
static EventIDRange intersect(const EventIDRange &first, const T &...rest)
Definition: EventIDRange.h:39
friend std::ostream & operator<<(std::ostream &os, const EventIDRange &rhs)
friend bool operator==(const EventIDRange &lhs, const EventIDRange &rhs)
Definition: EventIDRange.h:62
EventIDRange(const EventIDRange &r)
Definition: EventIDRange.h:27
EventIDBase m_stop
Definition: EventIDRange.h:58
STL class.
T min(T...args)
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Event ID Range object.
Definition: EventIDRange.h:23
EventIDRange & operator=(const EventIDRange &r)
friend bool operator!=(const EventIDRange &lhs, const EventIDRange &rhs)
Definition: EventIDRange.h:67
T max(T...args)
static EventIDRange intersect(const EventIDRange &it)
Definition: EventIDRange.h:37
EventIDBase stop() const
Definition: EventIDRange.h:31
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Definition: EventIDBase.h:29
EventIDBase m_start
Definition: EventIDRange.h:57
EventIDBase start() const
Definition: EventIDRange.h:30
bool isInRange(const EventIDBase &t) const
Definition: EventIDRange.h:33
STL class.