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