Go to the documentation of this file.00001 #ifndef CondTools_L1Trigger_Interval_h
00002 #define CondTools_L1Trigger_Interval_h
00003
00004 #include <map>
00005 #include <cassert>
00006
00007 namespace l1t
00008 {
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 template<typename TimeType, typename PayloadType>
00020 class Interval
00021 {
00022 public:
00023
00024
00025
00026 Interval (const TimeType& start, const TimeType& end)
00027 : m_start (start), m_end (end), isInvalid (false)
00028 { assert (m_start <= m_end); }
00029
00030
00031
00032 Interval (const TimeType& start, const TimeType& end, const PayloadType& payload)
00033 : m_start(start), m_end (end), _payload (payload), isInvalid (false) {}
00034
00035
00036 void setPayload (const PayloadType& payload) { this->_payload = payload; }
00037
00038 const PayloadType& payload () const { return this->_payload; }
00039
00040
00041 const TimeType & start () const { return this->m_start; }
00042
00043 const TimeType & end () const { return this->m_end; }
00044
00045
00046
00047
00048 static Interval & invalid ();
00049
00050
00051 bool operator== (const Interval<TimeType, PayloadType> & other) const
00052 { return (this->isInvalid == true && other.isInvalid == true ) ||
00053 (this->start () == other.start ()) && (this->end () == other.end () &&
00054 this->isInvalid == other.isInvalid); }
00055
00056 bool operator!= (const Interval<TimeType, PayloadType> & other) const
00057 { return ! (*this == other); }
00058
00059 protected:
00060
00061 TimeType m_start;
00062 TimeType m_end;
00063 PayloadType _payload;
00064
00065
00066 bool isInvalid;
00067 };
00068
00069
00070
00071
00072
00073
00074
00075 template<typename TimeType, typename PayloadType>
00076 class IntervalManager
00077 {
00078 public:
00079
00080
00081 void addInterval (const Interval<TimeType, PayloadType> & interval)
00082 { intervalMap.insert (std::make_pair (interval.start (), interval)); }
00083
00084
00085
00086 void clear () { intervalMap.clear (); }
00087
00088
00089
00090
00091 const Interval<TimeType, PayloadType> & find (const TimeType & time) const;
00092
00093 protected:
00094
00095 typedef std::map<TimeType, Interval<TimeType, PayloadType> > IntervalMap;
00096 IntervalMap intervalMap;
00097 };
00098
00099 }
00100
00101
00102 #include "CondTools/L1Trigger/src/Interval.icc"
00103
00104 #endif