LCIO  "2.7.4"
 All Classes Namespaces Functions Variables Typedefs Friends Pages
LCIORandomAccessMgr.h
1 #ifndef SIO_LCIORandomAccessMgr_H
2 #define SIO_LCIORandomAccessMgr_H 1
3 
4 #include "LCIORandomAccess.h"
5 #include "RunEventMap.h"
6 
7 #include <iostream>
8 #include <map>
9 #include <list>
10 
11 class SIO_stream ;
12 
13 namespace SIO {
14 
15  class LCIORandomAccessMgr ;
16  class SIOIndexHandler ;
17  class SIORandomAccessHandler ;
18 
19  std::ostream & operator<<(std::ostream& os, const LCIORandomAccessMgr& ra ) ;
20 
39 
40  friend class SIOIndexHandler ;
41  friend class SIORandomAccessHandler ;
42  friend std::ostream & operator<<(std::ostream& os, const LCIORandomAccessMgr& ra ) ;
43 
44  public:
45 
47 
48  virtual ~LCIORandomAccessMgr() ;
49 
53  long64 getPosition(const RunEvent& re ) {
54  return _runEvtMap.getPosition( re ) ;
55  }
56 
59  void add(const RunEvent& re, long64 pos ) {
60  _runEvtMap.add( re , pos ) ;
61  }
62 
66  bool createEventMap(SIO_stream* s) ;
67 
70  const RunEventMap& getEventMap() { return _runEvtMap ; }
71 
75  bool initAppend( SIO_stream* s) ;
76 
77 
80  void writeRandomAccessRecords(SIO_stream* stream) ;
81 
83  void clear() ;
84 
85  protected:
86 
89 
92 
94  bool readLCIORandomAccessAt( SIO_stream* stream , long64 pos) ;
95 
97  bool readLCIOIndexAt( SIO_stream* stream , long64 pos) ;
98 
100  bool recreateEventMap(SIO_stream*) ;
101 
103  bool readLCIORandomAccess( SIO_stream* stream ) ;
104 
106  bool readLCIOIndex( SIO_stream* stream ) ;
107 
108 
110  void createFileRecord() ;
111 
114  return (_list.empty() ? 0 : _list.back() ) ;
115  }
116 
117  // ----- map with RunHeader and EventHeader record positions
118  RunEventMap _runEvtMap ;
119 
120  // ----- list of LCIORandomAccess objects
121  std::list< LCIORandomAccess* > _list ;
122 
123  LCIORandomAccess* _fileRecord ;
124 
125  }; // class
126 
127 
128 } // namespace
129 #endif
Manager class for LCIO direct access.
Definition: LCIORandomAccessMgr.h:38
LCIORandomAccess * createFromEventMap()
Prepare an LCIORandomAccess object from the current contents of RunEventMap (all file locations set t...
Definition: LCIORandomAccessMgr.cc:57
bool initAppend(SIO_stream *s)
Initialize random access for append mode: read last LCIORandomAccess record if it exists - recreate t...
Definition: LCIORandomAccessMgr.cc:211
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
bool readLCIOIndexAt(SIO_stream *stream, long64 pos)
Read the LCIOIndex record at the specified position.
Definition: LCIORandomAccessMgr.cc:172
const LCIORandomAccess * lastLCIORandomAccess()
Pointer to the last LCIORandomAccess in the list.
Definition: LCIORandomAccessMgr.h:113
long64 getPosition(const RunEvent &re)
Return the position of the specified Event record or Run record respectively (if EventNum == -1 )...
Definition: RunEventMap.h:43
Implementation class for LCIORandomAccess records.
Definition: LCIORandomAccess.h:47
bool createEventMap(SIO_stream *s)
Get the run and event header map from the stream - either by reading the random access records or by ...
Definition: LCIORandomAccessMgr.cc:232
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: LCIORandomAccessMgr.h:59
Handler for LCIOrandomAccess and LCIOIndex objects/blocks.
Definition: SIORandomAccessHandler.h:16
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
bool readLCIORandomAccess(SIO_stream *stream)
Helper for reading the next LCIORandomAccess record (need preceeding call to LCSIO::seek() ) ...
Definition: LCIORandomAccessMgr.cc:139
const RunEventMap & getEventMap()
Return the event map - it will be empty, if not yet created.
Definition: LCIORandomAccessMgr.h:70
void writeRandomAccessRecords(SIO_stream *stream)
Write the current random access records LCIOIndex and LCIORandomAccess to the stream.
Definition: LCIORandomAccessMgr.cc:367
void createFileRecord()
Create file record from all LCIORandomAccess records.
Definition: LCIORandomAccessMgr.cc:77
bool readLCIOIndex(SIO_stream *stream)
Helper for reading the next LCIOIndex record (need preceeding call to LCSIO::seek() ) ...
Definition: LCIORandomAccessMgr.cc:179
bool readLCIORandomAccessAt(SIO_stream *stream, long64 pos)
Read the LCIORandomAccess record at the specified position.
Definition: LCIORandomAccessMgr.cc:131
void addLCIORandomAccess(LCIORandomAccess *ra)
Add a new LCIORandomAccess object to the list.
Definition: LCIORandomAccessMgr.cc:119
void clear()
Clear all lists and maps before closing a file.
Definition: LCIORandomAccessMgr.cc:41
long64 getPosition(const RunEvent &re)
Return the position of the specified Event record or Run record respectively (if EventNum == -1 )...
Definition: LCIORandomAccessMgr.h:53
bool recreateEventMap(SIO_stream *)
Fill the RunEventMap from the event and run header records in the file.
Definition: LCIORandomAccessMgr.cc:290
Handler for LCIOrandomAccess and LCIOIndex objects/blocks.
Definition: SIOIndexHandler.h:16