00001 #ifndef ProcessorMgr_h
00002 #define ProcessorMgr_h 1
00003
00004 #include "lcio.h"
00005 #include "Processor.h"
00006 #include "LCIOOutputProcessor.h"
00007
00008 #include "IO/LCRunListener.h"
00009 #include "IO/LCEventListener.h"
00010
00011 #include "EVENT/LCEvent.h"
00012 #include "EVENT/LCRunHeader.h"
00013 #include "LogicalExpressions.h"
00014
00015 #include <map>
00016 #include <set>
00017 #include <list>
00018
00019 using namespace lcio ;
00020
00021 namespace marlin{
00022
00023
00024 typedef std::map< const std::string , Processor* > ProcessorMap ;
00025 typedef std::list< Processor* > ProcessorList ;
00026 typedef std::map< const std::string , int > SkippedEventMap ;
00027
00028
00034 class ProcessorMgr : public LCRunListener, public LCEventListener {
00035
00036 friend class Processor ;
00037 friend class CMProcessor ;
00038 friend class MarlinSteerCheck ;
00039
00040 public:
00041
00044 static ProcessorMgr* instance() ;
00045
00049
00050
00051
00055 bool addActiveProcessor( const std::string& processorType , const std::string& processorName ,
00056 StringParameters* parameters , const std::string condition="true" ) ;
00057
00060 void removeActiveProcessor( const std::string& name ) ;
00061
00062
00066 Processor* getActiveProcessor( const std::string& name ) ;
00067
00071 Processor* getProcessor( const std::string& type ) ;
00072
00075 void dumpRegisteredProcessors() ;
00076
00079 void dumpRegisteredProcessorsXML() ;
00080
00081 virtual void init() ;
00082 virtual void processRunHeader( LCRunHeader* ) ;
00083 virtual void processEvent( LCEvent* ) ;
00084 virtual void end() ;
00085
00086
00087 virtual void modifyRunHeader( LCRunHeader*) { ; }
00088 virtual void modifyEvent( LCEvent *) ;
00089
00092 virtual void readDataSource( int numEvents ) ;
00093
00094
00096 virtual void setProcessorReturnValue( Processor* proc, bool val ) ;
00097
00099 virtual void setProcessorReturnValue( Processor* proc, bool val , const std::string& name) ;
00100
00101 protected:
00104 void registerProcessor( Processor* processor ) ;
00105
00107 std::set< std::string > getAvailableProcessorTypes() ;
00108
00109
00110 ProcessorMgr() {}
00111
00112 private:
00113 static ProcessorMgr* _me ;
00114 ProcessorMap _map ;
00115 ProcessorMap _activeMap ;
00116 ProcessorList _list ;
00117 SkippedEventMap _skipMap ;
00118
00119 LogicalExpressions _conditions ;
00120
00121
00122 };
00123
00124 }
00125 #endif