CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/IOPool/Streamer/interface/StreamerInputModule.h

Go to the documentation of this file.
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     virtual EventPrincipal* read();
00031 
00032   private:
00033     //ProductRegistry const* prod_reg_;
00034     std::auto_ptr<Producer> pr_; 
00035   }; //end-of-class-def
00036 
00037   template <typename Producer>
00038   StreamerInputModule<Producer>::~StreamerInputModule() {}
00039 
00040   template <typename Producer>
00041   StreamerInputModule<Producer>::StreamerInputModule(
00042                     ParameterSet const& pset,
00043                     InputSourceDescription const& desc):
00044         StreamerInputSource(pset, desc),
00045         //prod_reg_(&productRegistry()), 
00046         pr_(new Producer(pset)) {
00047     //Get header/init from Producer
00048     InitMsgView const* header = pr_->getHeader();
00049     deserializeAndMergeWithRegistry(*header); 
00050   }
00051 
00052   template <typename Producer>
00053   EventPrincipal* StreamerInputModule<Producer>::read() {
00054 
00055     EventMsgView const* eview = pr_->getNextEvent();
00056 
00057     if (pr_->newHeader()) {   
00058         FDEBUG(6) << "A new file has been opened and we must compare Headers here !!" << std::endl;
00059         // A new file has been opened and we must compare Headers here !!
00060         //Get header/init from Producer
00061         InitMsgView const* header = pr_->getHeader();
00062         deserializeAndMergeWithRegistry(*header, true);
00063     } 
00064     if (eview == 0) {
00065         return  0;
00066     }
00067     return(deserializeEvent(*eview));
00068   }
00069 
00070 } // end of namespace-edm
00071   
00072 #endif