00001 #ifndef BESIII_RAW_FILE_READER_H 00002 #define BESIII_RAW_FILE_READER_H 00003 00004 #include "RawFile/RawFileUtil.h" 00005 #include "IRawFile/IRawReader.h" 00006 #include <vector> 00007 #include <string> 00008 00009 //forward declaration 00010 class raw_ifstream; 00011 class EvtIdxHandler; 00012 class RawFileException; 00013 00014 typedef std::vector<std::string> VFileNames_t; 00015 00016 class RawFileReader : public IRawReader 00017 { 00018 public : 00019 00020 typedef const VFileNames_t ReaderArgType; 00021 00022 static std::vector<int> getEventNumber(const VFileNames_t& idxfnames); 00023 00024 // thread safe 00025 RawFileReader(const std::string& fname); 00026 RawFileReader(const VFileNames_t& fnames); 00027 RawFileReader(const std::string& fname, const std::string& idxfname); 00028 RawFileReader(const VFileNames_t& fnames, const VFileNames_t& idxfnames); 00029 virtual ~RawFileReader(); 00030 00031 // thread safe 00032 const uint32_t* nextEvent(); 00033 const uint32_t* currentEvent() const { return m_buffer; } 00034 00035 // following interface are not thread safe !!! 00036 const uint32_t* nextEvent(int nIgnore); 00037 const uint32_t* findEventById(uint32_t evtId); 00038 const uint32_t* roughlyNextEvent(int nIgnore, int evtByte = 0); 00039 00040 uint32_t runNo(); 00041 00042 std::string currentFile(); 00043 uint32_t tellg(); 00044 uint32_t stat(); 00045 00046 00047 private : 00048 00049 const uint32_t* notSafeNextEvent(); 00050 00051 void read_one_event(); 00052 RawFileReader& nextFile(RawFileException& e); 00053 00054 RawFileReader(); //stop default 00055 00056 00057 private : 00058 00059 uint32_t m_bufferSize; 00060 uint32_t* m_buffer; 00061 00062 raw_ifstream* m_rfs; 00063 EvtIdxHandler* m_idxHandler; 00064 00065 DataSeparatorRecord m_dataSeparatorRecord; 00066 }; 00067 00068 #endif