CGEM BOSS 6.6.5.h
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#include <stdint.h>
8
10{
11 public :
12
13 static uint32_t IdxFileStartMarker() { return 0xFFFFAAAA; }
14 static uint32_t IdxIdBlockMarker() { return 0xFFFFBBBB; }
15 static uint32_t IdxPosBlockMarker() { return 0xFFFFCCCC; }
16
17 static EvtIdxHandler* instance(const std::vector<std::string>& fnames);
18 static void release();
19
20 EvtIdxHandler(); // writing
21 virtual ~EvtIdxHandler();
22
23 // for reading
24 void next_file();
25
26 uint32_t nextPos(int nIgnore);
27 uint32_t findPosById(uint32_t evtId);
28
29 int nEvtLeft(int nIgnore) const {
30 return ( m_totEvt - (m_idxPos+nIgnore) );
31 }
32
33 // for constructing and writing
34 void addPos(uint32_t evtId, uint32_t pos);
35 void write(std::string fname);
36
37
38 private :
39
40 EvtIdxHandler(const std::vector<std::string>& idxfnames); // reading
41
42 void init_idx(); //only for reading
43 void enlarge_block(int min_size);
44
45
46 private :
47
48 int m_totEvt;
49 int m_idxPos; //only for reading, no less than 0
50
51 int m_blockSize;
52 uint32_t* m_EIdBlock;
53 uint32_t* m_PosBlock;
54
55 std::vector<std::string> m_fnames; //only for reading
56 std::vector<std::string>::iterator m_curFile; //only for reading
57 std::fstream m_fs;
58
59 static int _nHandler;
60 static EvtIdxHandler* _instance;
61};
62
63#endif
#define private
static uint32_t IdxPosBlockMarker()
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()
static void release()
void addPos(uint32_t evtId, uint32_t pos)
int nEvtLeft(int nIgnore) const
uint32_t nextPos(int nIgnore)
static uint32_t IdxIdBlockMarker()