00001 #ifndef IOPool_Streamer_StreamerInputSource_h 00002 #define IOPool_Streamer_StreamerInputSource_h 00003 00012 #include "TBufferFile.h" 00013 00014 #include "FWCore/Framework/interface/Frameworkfwd.h" 00015 #include "FWCore/Framework/interface/InputSource.h" 00016 00017 #include "DataFormats/Streamer/interface/StreamedProducts.h" 00018 #include "DataFormats/Common/interface/EDProductGetter.h" 00019 00020 #include "boost/shared_ptr.hpp" 00021 00022 #include <vector> 00023 00024 class InitMsgView; 00025 class EventMsgView; 00026 00027 namespace edm { 00028 class ParameterSetDescription; 00029 class StreamerInputSource : public InputSource { 00030 public: 00031 explicit StreamerInputSource(ParameterSet const& pset, 00032 InputSourceDescription const& desc); 00033 virtual ~StreamerInputSource(); 00034 static void fillDescription(ParameterSetDescription& description); 00035 00036 static 00037 std::auto_ptr<SendJobHeader> deserializeRegistry(InitMsgView const& initView); 00038 00039 void deserializeAndMergeWithRegistry(InitMsgView const& initView, bool subsequent = false); 00040 00041 EventPrincipal* deserializeEvent(EventMsgView const& eventView); 00042 00043 static 00044 void mergeIntoRegistry(SendJobHeader const& header, ProductRegistry&, bool subsequent); 00045 00054 static unsigned int uncompressBuffer(unsigned char *inputBuffer, 00055 unsigned int inputSize, 00056 std::vector<unsigned char> &outputBuffer, 00057 unsigned int expectedFullSize); 00058 protected: 00059 static void declareStreamers(SendDescs const& descs); 00060 static void buildClassCache(SendDescs const& descs); 00061 void setEndRun() {runEndingFlag_ = true;} 00062 void resetAfterEndRun(); 00063 00064 bool inputFileTransitionsEachEvent_; 00065 00066 private: 00067 00068 class ProductGetter : public EDProductGetter { 00069 public: 00070 ProductGetter(); 00071 virtual ~ProductGetter(); 00072 00073 virtual EDProduct const* getIt(edm::ProductID const& id) const; 00074 00075 void setEventPrincipal(EventPrincipal *ep); 00076 00077 private: 00078 // We don't own the principal. The lifetime must be managed externally. 00079 EventPrincipal const* eventPrincipal_; 00080 }; 00081 00082 virtual EventPrincipal* read() = 0; 00083 00084 virtual boost::shared_ptr<RunAuxiliary> readRunAuxiliary_(); 00085 00086 virtual boost::shared_ptr<LuminosityBlockAuxiliary> readLuminosityBlockAuxiliary_(); 00087 00088 virtual EventPrincipal* 00089 readEvent_(); 00090 00091 virtual ItemType getNextItemType(); 00092 00093 virtual void setRun(RunNumber_t r); 00094 00095 virtual boost::shared_ptr<FileBlock> readFile_(); 00096 00097 bool newRun_; 00098 bool newLumi_; 00099 bool eventCached_; 00100 00101 TClass* tc_; 00102 std::vector<unsigned char> dest_; 00103 TBufferFile xbuf_; 00104 bool runEndingFlag_; 00105 ProductGetter productGetter_; 00106 00107 //Do not like these to be static, but no choice as deserializeRegistry() that sets it is a static memeber 00108 static std::string processName_; 00109 static unsigned int protocolVersion_; 00110 }; //end-of-class-def 00111 } // end of namespace-edm 00112 00113 #endif