CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_4/src/IOPool/Streamer/interface/StreamerInputFile.h

Go to the documentation of this file.
00001 #ifndef IOPool_Streamer_StreamerInputFile_h
00002 #define IOPool_Streamer_StreamerInputFile_h
00003 
00004 #include "IOPool/Streamer/interface/InitMessage.h"
00005 #include "IOPool/Streamer/interface/EventMessage.h"
00006 #include "IOPool/Streamer/interface/MsgTools.h"
00007 #include "Utilities/StorageFactory/interface/IOTypes.h"
00008 #include "Utilities/StorageFactory/interface/Storage.h"
00009 
00010 #include <boost/shared_ptr.hpp>
00011 
00012 #include<string>
00013 #include<vector>
00014 
00015 namespace edm {
00016   class EventSkipperByID;
00017   class StreamerInputFile {
00018   public:
00019 
00021     explicit StreamerInputFile(std::string const& name,
00022       int* numberOfEventsToSkip = 0,
00023       boost::shared_ptr<EventSkipperByID> eventSkipperByID = boost::shared_ptr<EventSkipperByID>());
00024 
00026     explicit StreamerInputFile(std::vector<std::string> const& names,
00027       int* numberOfEventsToSkip = 0,
00028       boost::shared_ptr<EventSkipperByID> eventSkipperByID = boost::shared_ptr<EventSkipperByID>());
00029 
00030     ~StreamerInputFile();
00031 
00032     bool next(); 
00034     InitMsgView const* startMessage() const { return startMsg_.get(); }
00037     EventMsgView const* currentRecord() const { return currentEvMsg_.get(); }
00040     bool newHeader() { bool tmp = newHeader_; newHeader_ = false; return tmp;}  
00043   private:
00044 
00045     void openStreamerFile(std::string const& name);
00046     IOSize readBytes(char* buf, IOSize nBytes);
00047     IOOffset skipBytes(IOSize nBytes);
00048 
00049     void readStartMessage();
00050     int readEventMessage();
00051 
00052     bool openNextFile();
00055     bool compareHeader();
00056 
00057     void logFileAction(char const* msg);
00058 
00059     boost::shared_ptr<InitMsgView> startMsg_;
00060     boost::shared_ptr<EventMsgView> currentEvMsg_;
00061 
00062     std::vector<char> headerBuf_; 
00063     std::vector<char> eventBuf_;  
00065     unsigned int currentFile_; 
00066     std::vector<std::string> streamerNames_; 
00067     bool multiStreams_;  
00068     std::string currentFileName_;
00069     bool currentFileOpen_;
00070 
00071     boost::shared_ptr<EventSkipperByID> eventSkipperByID_;
00072 
00073     int* numberOfEventsToSkip_;
00074 
00075     uint32 currRun_;
00076     uint32 currProto_;
00077 
00078     bool newHeader_;
00079 
00080     boost::shared_ptr<Storage> storage_;
00081 
00082     bool endOfFile_;
00083   };
00084 }
00085 
00086 #endif