00001 #ifndef IOPool_Streamer_StreamerInputModule_h 00002 #define IOPool_Streamer_StreamerInputModule_h 00003 00004 #include "IOPool/Streamer/interface/StreamerInputSource.h" 00005 00006 #include "DataFormats/Common/interface/Wrapper.h" 00007 #include "FWCore/Utilities/interface/Exception.h" 00008 #include "IOPool/Streamer/interface/ClassFiller.h" 00009 #include "FWCore/Framework/interface/EventPrincipal.h" 00010 00011 #include "DataFormats/Streamer/interface/StreamedProducts.h" 00012 #include "FWCore/Utilities/interface/DebugMacros.h" 00013 #include "IOPool/Streamer/interface/StreamerFileIO.h" 00014 00015 #include "FWCore/ParameterSet/interface/ParameterSet.h" 00016 00017 #include "IOPool/Streamer/interface/InitMessage.h" 00018 #include "IOPool/Streamer/interface/EventMessage.h" 00019 #include "IOPool/Streamer/interface/Utilities.h" 00020 00021 #include <memory> 00022 #include <string> 00023 #include <fstream> 00024 #include <vector> 00025 #include <utility> 00026 #include <iostream> 00027 #include <algorithm> 00028 #include <iterator> 00029 00030 namespace edm 00031 { 00032 template <typename Producer> 00033 class StreamerInputModule : public StreamerInputSource { 00039 public: 00040 explicit StreamerInputModule(ParameterSet const& pset, 00041 InputSourceDescription const& desc); 00042 virtual ~StreamerInputModule(); 00043 virtual std::auto_ptr<EventPrincipal> read(); 00044 00045 private: 00046 //ProductRegistry const* prod_reg_; 00047 std::auto_ptr<Producer> pr_; 00048 }; //end-of-class-def 00049 00050 template <typename Producer> 00051 StreamerInputModule<Producer>::~StreamerInputModule() {} 00052 00053 template <typename Producer> 00054 StreamerInputModule<Producer>::StreamerInputModule( 00055 ParameterSet const& pset, 00056 InputSourceDescription const& desc): 00057 StreamerInputSource(pset, desc), 00058 //prod_reg_(&productRegistry()), 00059 pr_(new Producer(pset)) { 00060 //Get header/init from Producer 00061 InitMsgView const* header = pr_->getHeader(); 00062 deserializeAndMergeWithRegistry(*header); 00063 saveTriggerNames(header); 00064 } 00065 00066 template <typename Producer> 00067 std::auto_ptr<EventPrincipal> StreamerInputModule<Producer>::read() { 00068 00069 EventMsgView const* eview = pr_->getNextEvent(); 00070 00071 if (pr_->newHeader()) { 00072 FDEBUG(6) << "A new file has been opened and we must compare Headers here !!" << std::endl; 00073 // A new file has been opened and we must compare Heraders here !! 00074 //Get header/init from Producer 00075 InitMsgView const* header = pr_->getHeader(); 00076 deserializeAndMergeWithRegistry(*header, true); 00077 saveTriggerNames(header); 00078 } 00079 if (eview == 0) { 00080 return std::auto_ptr<EventPrincipal>(); 00081 } 00082 std::auto_ptr<EventPrincipal> pEvent(deserializeEvent(*eview)); 00083 return pEvent; 00084 } 00085 00086 } // end of namespace-edm 00087 00088 #endif