00001 #ifndef _FUShmOutputModule_h 00002 #define _FUShmOutputModule_h 00003 00004 /* 00005 Description: 00006 Header file shared memory to be used with FUShmOutputModule. 00007 See CMS EvF Storage Manager wiki page for further notes. 00008 00009 $Id: FUShmOutputModule.h,v 1.9 2012/05/02 15:02:19 smorovic Exp $ 00010 */ 00011 00012 #include "FWCore/ParameterSet/interface/ParameterSet.h" 00013 00014 #include "IOPool/Streamer/interface/InitMsgBuilder.h" 00015 #include "IOPool/Streamer/interface/EventMsgBuilder.h" 00016 #include "FWCore/Framework/interface/LuminosityBlock.h" 00017 00018 #include "EventFilter/ShmBuffer/interface/FUShmBuffer.h" 00019 #include "EventFilter/Modules/interface/ShmOutputModuleRegistry.h" 00020 00021 #include <iostream> 00022 00023 // Data structure to be shared by all output modules for event serialization 00024 struct SM_SharedMemoryHandle 00025 { 00026 SM_SharedMemoryHandle(): 00027 shmBuffer_(0) 00028 { } 00029 00030 evf::FUShmBuffer* getShmBuffer() { 00031 if(!shmBuffer_) { 00032 shmBuffer_ = evf::FUShmBuffer::getShmBuffer(); 00033 return shmBuffer_; 00034 } else { 00035 return shmBuffer_; 00036 } 00037 } 00038 void detachShmBuffer() { 00039 if(!shmBuffer_) { 00040 // no shared memory was attached to! 00041 } else { 00042 shmdt(shmBuffer_); 00043 shmBuffer_ = 0; 00044 } 00045 } 00046 evf::FUShmBuffer* getBufferRef() { 00047 return shmBuffer_; 00048 } 00049 00050 evf::FUShmBuffer* shmBuffer_; 00051 }; 00052 00053 namespace edm 00054 { 00055 class ParameterSetDescription; 00056 class FUShmOutputModule : public evf::OutputModule 00057 { 00058 public: 00059 00060 FUShmOutputModule(edm::ParameterSet const& ps); 00061 ~FUShmOutputModule(); 00062 00063 void doOutputHeader(InitMsgBuilder const& initMessage); 00064 void doOutputEvent(EventMsgBuilder const& eventMessage); 00065 unsigned int getCounts(){ 00066 return count_; 00067 } 00068 void start(); 00069 void stop(); 00070 // No parameters. 00071 static void fillDescription(ParameterSetDescription&) {} 00072 private: 00073 00074 evf::FUShmBuffer* shmBuffer_; 00075 std::string name_; 00076 unsigned int count_; 00077 00078 static bool fuIdsInitialized_; 00079 static uint32 fuGuidValue_; 00080 bool postponeInitMsg_; 00081 bool sentInitMsg_; 00082 unsigned char * initBuf_; 00083 unsigned int initBufSize_; 00084 bool postponeStart_; 00085 unsigned int nExpectedEPs_; 00086 00087 public: 00088 //void writeLuminosityBlock(LuminosityBlockPrincipal const&); 00089 void setPostponeInitMsg(); 00090 void sendPostponedStart(); 00091 void sendPostponedInitMsg(); 00092 void setNExpectedEPs(unsigned int EPs); 00093 void unregisterFromShm(); 00094 00095 }; 00096 } 00097 00098 #endif