00001 // $Id: LogicTool.h,v 1.3 2009/08/09 11:11:36 aosorio Exp $ 00002 #ifndef LOGICTOOL_H 00003 #define LOGICTOOL_H 1 00004 00005 // Include files 00006 #include "L1Trigger/RPCTechnicalTrigger/interface/LogicFactory.h" 00007 #include "L1Trigger/RPCTechnicalTrigger/interface/LogicImp.h" 00008 00009 #include <ostream> 00010 #include <vector> 00011 00021 template <class GenLogic> 00022 class LogicTool { 00023 public: 00025 LogicTool( ) { }; 00026 00027 virtual ~LogicTool( ) { 00028 m_logkeys.clear(); 00029 }; 00030 00032 00033 typedef LogicFactory< GenLogic, std::string> RBCLogicType; 00034 00035 GenLogic * (*createlogic) (); 00036 00037 RBCLogicType m_rbclogic; 00038 00039 bool initialise() 00040 { 00041 bool status(true); 00042 00043 //... 00044 std::string key = std::string("ChamberORLogic"); 00045 createlogic = (GenLogic * (*)()) &createChamberORLogic; 00046 status = m_rbclogic.Register( key , createlogic ); 00047 00048 m_logkeys.push_back( key ); 00049 00050 key = std::string("TestLogic"); 00051 createlogic = (GenLogic * (*)()) &createTestLogic; 00052 status = m_rbclogic.Register( key , createlogic ); 00053 00054 m_logkeys.push_back( key ); 00055 00056 key = std::string("PatternLogic"); 00057 createlogic = (GenLogic * (*)()) &createPatternLogic; 00058 status = m_rbclogic.Register( key , createlogic ); 00059 //... 00060 00061 m_logkeys.push_back( key ); 00062 00063 key = std::string("TrackingAlg"); 00064 createlogic = (GenLogic * (*)()) &createTrackingAlg; 00065 status = m_rbclogic.Register( key , createlogic ); 00066 00067 m_logkeys.push_back( key ); 00068 00069 key = std::string("SectorORLogic"); 00070 createlogic = (GenLogic * (*)()) &createSectorORLogic; 00071 status = m_rbclogic.Register( key , createlogic ); 00072 00073 m_logkeys.push_back( key ); 00074 00075 key = std::string("TwoORLogic"); 00076 createlogic = (GenLogic * (*)()) &createTwoORLogic; 00077 status = m_rbclogic.Register( key , createlogic ); 00078 00079 m_logkeys.push_back( key ); 00080 00081 key = std::string("WedgeORLogic"); 00082 createlogic = (GenLogic * (*)()) &createWedgeORLogic; 00083 status = m_rbclogic.Register( key , createlogic ); 00084 00085 m_logkeys.push_back( key ); 00086 00087 key = std::string("PointingLogic"); 00088 createlogic = (GenLogic * (*)()) &createPointingLogic; 00089 status = m_rbclogic.Register( key , createlogic ); 00090 00091 m_logkeys.push_back( key ); 00092 00093 return status; 00094 00095 }; 00096 00097 00098 GenLogic * retrieve( const std::string & _logic_name ) 00099 { 00100 GenLogic * _obj; 00101 _obj = m_rbclogic.CreateObject( _logic_name ); 00102 return _obj; 00103 }; 00104 00105 bool endjob() 00106 { 00107 bool status(true); 00108 typename std::vector<std::string>::iterator itr = m_logkeys.begin(); 00109 while ( itr != m_logkeys.end() ) 00110 { 00111 status = status && ( m_rbclogic.Unregister( (*itr) ) ); 00112 ++itr; 00113 } 00114 return status; 00115 00116 }; 00117 00118 00119 protected: 00120 00121 private: 00122 00123 typename std::vector<std::string> m_logkeys; 00124 00125 }; 00126 #endif // LOGICTOOL_H