// EventIdRange.h #ifndef EventIdRange_H #define EventIdRange_H // David Adams // June 2002 // // Range of event ID's with the same run number and a contiguous // set of event numbers. // // XML format: // // EventIdRange // run = 123 // first = 24001 // last = 24199 // #include "dataset_id/EventId.h" #include class XmlElement; class EventIdRange { public: // Typedefs typedef unsigned long size_type; public: // static functions // XML name. static const char* xml_name() { return "EventIdRange"; } // XML DTD. static const Text& dtd(); private: // data EventId _id; size_type _size; public: // Default constructor. EventIdRange(); // Full constructor from event ID. explicit EventIdRange(EventId id, size_type size =1); // Full constructor from run and event numbers. EventIdRange(EventId::RunNumber run, EventId::EventNumber evt1, EventId::EventNumber evt2); // XML constructor. explicit EventIdRange(const XmlElement& ele); public: // const functions // Return the run number. EventId::RunNumber run() const { return _id.run(); } // Return the first event number. EventId::EventNumber first_event() const { return _id.event(); } // Return the last event number. EventId::EventNumber last_event() const { return _id.event() + _size - 1; } // Return the number of event ID's. size_type size() const { return _size; } // Return if this is a valid range. bool is_valid() const { return _size>0 && _id.is_valid(); } // Contains another range? bool contains(const EventIdRange& rng) const; // Write to XML. const XmlElement* xml() const; public: // mutating functions // Remove the first event. void pop_front(); // Remove the last event. void pop_back(); }; // Ordering operator. // Ranges may not overlap or be adjacent. bool operator<(const EventIdRange& lhs, const EventIdRange& rhs); // Equality. // Ranges must be identical. bool operator==(const EventIdRange& lhs, const EventIdRange& rhs); // Inequality. bool operator!=(const EventIdRange& lhs, const EventIdRange& rhs); // Output stream. std::ostream& operator<<(std::ostream& lhs, const EventIdRange& rhs); #endif