BOSS 6.6.4.p01
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtIdxHandler.h
Go to the documentation of this file.
1#ifndef BESIII_EVTIDX_HANDLER_H
2#define BESIII_EVTIDX_HANDLER_H
3
4#include <vector>
5#include <string>
6#include <fstream>
7
9{
10 public :
11
12 static uint32_t IdxFileStartMarker() { return 0xFFFFAAAA; }
13 static uint32_t IdxIdBlockMarker() { return 0xFFFFBBBB; }
14 static uint32_t IdxPosBlockMarker() { return 0xFFFFCCCC; }
15
16 static EvtIdxHandler* instance(const std::vector<std::string>& fnames);
17 static void release();
18
19 EvtIdxHandler(); // writing
20 virtual ~EvtIdxHandler();
21
22 // for reading
23 void next_file();
24
25 uint32_t nextPos(int nIgnore);
26 uint32_t findPosById(uint32_t evtId);
27
28 int nEvtLeft(int nIgnore) const {
29 return ( m_totEvt - (m_idxPos+nIgnore) );
30 }
31
32 // for constructing and writing
33 void addPos(uint32_t evtId, uint32_t pos);
34 void write(std::string fname);
35
36
37 private :
38
39 EvtIdxHandler(const std::vector<std::string>& idxfnames); // reading
40
41 void init_idx(); //only for reading
42 void enlarge_block(int min_size);
43
44
45 private :
46
47 int m_totEvt;
48 int m_idxPos; //only for reading, no less than 0
49
50 int m_blockSize;
51 uint32_t* m_EIdBlock;
52 uint32_t* m_PosBlock;
53
54 std::vector<std::string> m_fnames; //only for reading
55 std::vector<std::string>::iterator m_curFile; //only for reading
56 std::fstream m_fs;
57
58 static int _nHandler;
59 static EvtIdxHandler* _instance;
60};
61
62#endif
#define private
static uint32_t IdxPosBlockMarker()
Definition: EvtIdxHandler.h:14
static EvtIdxHandler * instance(const std::vector< std::string > &fnames)
uint32_t findPosById(uint32_t evtId)
void write(std::string fname)
virtual ~EvtIdxHandler()
static uint32_t IdxFileStartMarker()
Definition: EvtIdxHandler.h:12
static void release()
void addPos(uint32_t evtId, uint32_t pos)
int nEvtLeft(int nIgnore) const
Definition: EvtIdxHandler.h:28
uint32_t nextPos(int nIgnore)
static uint32_t IdxIdBlockMarker()
Definition: EvtIdxHandler.h:13