00001 #ifndef IOPool_Streamer_StreamerInputModule_h 00002 #define IOPool_Streamer_StreamerInputModule_h 00003 00004 #include "IOPool/Streamer/interface/StreamerInputSource.h" 00005 00006 #include "FWCore/Utilities/interface/DebugMacros.h" 00007 00008 #include <memory> 00009 #include <string> 00010 #include <fstream> 00011 #include <vector> 00012 #include <utility> 00013 #include <iostream> 00014 #include <algorithm> 00015 #include <iterator> 00016 00017 namespace edm 00018 { 00019 template <typename Producer> 00020 class StreamerInputModule : public StreamerInputSource { 00026 public: 00027 explicit StreamerInputModule(ParameterSet const& pset, 00028 InputSourceDescription const& desc); 00029 virtual ~StreamerInputModule(); 00030 private: 00031 virtual void closeFile_() { 00032 if(pr_.get() != nullptr) pr_->closeFile(); 00033 } 00034 00035 virtual bool checkNextEvent(); 00036 00037 //ProductRegistry const* prod_reg_; 00038 std::auto_ptr<Producer> pr_; 00039 }; //end-of-class-def 00040 00041 template <typename Producer> 00042 StreamerInputModule<Producer>::~StreamerInputModule() {} 00043 00044 template <typename Producer> 00045 StreamerInputModule<Producer>::StreamerInputModule( 00046 ParameterSet const& pset, 00047 InputSourceDescription const& desc): 00048 StreamerInputSource(pset, desc), 00049 //prod_reg_(&productRegistry()), 00050 pr_(new Producer(pset)) { 00051 //Get header/init from Producer 00052 InitMsgView const* header = pr_->getHeader(); 00053 deserializeAndMergeWithRegistry(*header); 00054 } 00055 00056 template <typename Producer> 00057 bool StreamerInputModule<Producer>::checkNextEvent() { 00058 00059 EventMsgView const* eview = pr_->getNextEvent(); 00060 00061 if (pr_->newHeader()) { 00062 FDEBUG(6) << "A new file has been opened and we must compare Headers here !!" << std::endl; 00063 // A new file has been opened and we must compare Headers here !! 00064 //Get header/init from Producer 00065 InitMsgView const* header = pr_->getHeader(); 00066 deserializeAndMergeWithRegistry(*header, true); 00067 } 00068 if (eview == 0) { 00069 return false; 00070 } 00071 deserializeEvent(*eview); 00072 return true; 00073 } 00074 00075 } // end of namespace-edm 00076 00077 #endif