LCIO  "2.7.4"
 All Classes Namespaces Functions Variables Typedefs Friends Pages
RunEventMap.h
1 #ifndef SIO_RunEventMap_H
2 #define SIO_RunEventMap_H 1
3 
4 #include <map>
5 
6 #include "LCIORandomAccess.h"
7 
8 namespace SIO {
9 
10  class RunEventMap ;
11 
12  std::ostream & operator<<(std::ostream& os, const RunEventMap& rm ) ;
13 
14 
20  class RunEventMap {
21 
22 
23  friend std::ostream & operator<<(std::ostream& os, const RunEventMap& rm ) ;
24 
25  public:
26 
27  typedef std::map< RunEvent, long64> MapType ;
28  typedef MapType::iterator Map_IT ;
29  typedef MapType::const_iterator Map_cIT ;
30 
31  static const int NPos = -1 ;
32 
33  RunEventMap() ;
34  ~RunEventMap() ;
35 
38  void add(const RunEvent& re, long64 pos ) ;
39 
43  long64 getPosition(const RunEvent& re ) {
44  return getPosition( long64( re ) ) ;
45  }
46 
49  long64 getPosition( long64 re ) ;
50 
51 
52  /* Return the minimal run event object - (-1,-1) if empty.
53  */
54  RunEvent minRunEvent() ;
55 
56  /* Return the maximum run event object - (-1,-1) if empty.
57  */
58  RunEvent maxRunEvent() ;
59 
60 
61  int getNumberOfEventRecords() const { return _nEvt ; }
62 
63  int getNumberOfRunRecords() const { return _nRun ; }
64 
65  // map funcitons
66  size_t size() { return _map.size() ; }
67 
68  Map_IT begin() { return _map.begin() ; }
69  Map_IT end() { return _map.end() ; }
70  Map_cIT begin() const { return _map.begin() ; }
71  Map_cIT end() const { return _map.end() ; }
72  bool empty() const { return _map.empty() ; }
73 
74  template <class InputIterator>
75  void insert(InputIterator b, InputIterator e) { _map.insert( b , e ) ; }
76 
77  void clear() { _map.clear() ; _nRun=0 ; _nEvt =0 ; }
78 
79  protected:
80 
81  MapType _map ;
82 
83  int _nRun ;
84  int _nEvt ;
85 
86  }; // class
87  } // namespace
88 
89 #endif /* ifndef SIO_RunEventMap_H */
Helper struct that stores run and event positions in the file.
Definition: LCIORandomAccess.h:17
Map that holds positions of Run and Event records.
Definition: RunEventMap.h:20
long64 getPosition(const RunEvent &re)
Return the position of the specified Event record or Run record respectively (if EventNum == -1 )...
Definition: RunEventMap.h:43
void add(const RunEvent &re, long64 pos)
Add a new entry to the event map - if the RunEvent already exists the new position will be stored...
Definition: RunEventMap.cc:20