Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

EvtIdxHandler.h

Go to the documentation of this file.
00001 #ifndef BESIII_EVTIDX_HANDLER_H
00002 #define BESIII_EVTIDX_HANDLER_H
00003 
00004 #include <vector>
00005 #include <string>
00006 #include <fstream>
00007 
00008 class EvtIdxHandler
00009 {
00010    public :
00011 
00012       static uint32_t IdxFileStartMarker() { return 0xFFFFAAAA; }
00013       static uint32_t IdxIdBlockMarker()   { return 0xFFFFBBBB; }
00014       static uint32_t IdxPosBlockMarker()  { return 0xFFFFCCCC; }
00015 
00016       static EvtIdxHandler* instance(const std::vector<std::string>& fnames);
00017       static void release();
00018 
00019       EvtIdxHandler();  // writing
00020       virtual ~EvtIdxHandler();
00021 
00022       // for reading
00023       void next_file();
00024 
00025       uint32_t  nextPos(int nIgnore);
00026       uint32_t  findPosById(uint32_t evtId);
00027 
00028       int nEvtLeft(int nIgnore) const {
00029          return ( m_totEvt - (m_idxPos+nIgnore) );
00030       }
00031 
00032       // for constructing and writing
00033       void addPos(uint32_t evtId, uint32_t pos);
00034       void write(std::string fname);
00035 
00036 
00037    private :
00038 
00039       EvtIdxHandler(const std::vector<std::string>& idxfnames);  // reading
00040 
00041       void init_idx();  //only for reading
00042       void enlarge_block(int min_size);
00043 
00044 
00045    private :
00046 
00047       int        m_totEvt;
00048       int        m_idxPos;  //only for reading, no less than 0
00049 
00050       int        m_blockSize;
00051       uint32_t*  m_EIdBlock;
00052       uint32_t*  m_PosBlock;
00053 
00054       std::vector<std::string>            m_fnames;  //only for reading
00055       std::vector<std::string>::iterator  m_curFile;  //only for reading
00056       std::fstream                        m_fs;
00057 
00058       static int             _nHandler;
00059       static EvtIdxHandler*  _instance;
00060 };
00061 
00062 #endif

Generated on Wed Feb 2 15:41:37 2011 for BOSS6.5.5 by  doxygen 1.3.9.1