CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
LogicTool.h
Go to the documentation of this file.
1 // $Id: LogicTool.h,v 1.3 2009/08/09 11:11:36 aosorio Exp $
2 #ifndef LOGICTOOL_H
3 #define LOGICTOOL_H 1
4 
5 // Include files
8 
9 #include <ostream>
10 #include <vector>
11 
21 template <class GenLogic>
22 class LogicTool {
23 public:
25  LogicTool( ) { };
26 
27  virtual ~LogicTool( ) {
28  m_logkeys.clear();
29  };
30 
32 
34 
35  GenLogic * (*createlogic) ();
36 
38 
39  bool initialise()
40  {
41  bool status(true);
42 
43  //...
44  std::string key = std::string("ChamberORLogic");
45  createlogic = (GenLogic * (*)()) &createChamberORLogic;
46  status = m_rbclogic.Register( key , createlogic );
47 
48  m_logkeys.push_back( key );
49 
50  key = std::string("TestLogic");
51  createlogic = (GenLogic * (*)()) &createTestLogic;
52  status = m_rbclogic.Register( key , createlogic );
53 
54  m_logkeys.push_back( key );
55 
56  key = std::string("PatternLogic");
57  createlogic = (GenLogic * (*)()) &createPatternLogic;
58  status = m_rbclogic.Register( key , createlogic );
59  //...
60 
61  m_logkeys.push_back( key );
62 
63  key = std::string("TrackingAlg");
64  createlogic = (GenLogic * (*)()) &createTrackingAlg;
65  status = m_rbclogic.Register( key , createlogic );
66 
67  m_logkeys.push_back( key );
68 
69  key = std::string("SectorORLogic");
70  createlogic = (GenLogic * (*)()) &createSectorORLogic;
71  status = m_rbclogic.Register( key , createlogic );
72 
73  m_logkeys.push_back( key );
74 
75  key = std::string("TwoORLogic");
76  createlogic = (GenLogic * (*)()) &createTwoORLogic;
77  status = m_rbclogic.Register( key , createlogic );
78 
79  m_logkeys.push_back( key );
80 
81  key = std::string("WedgeORLogic");
82  createlogic = (GenLogic * (*)()) &createWedgeORLogic;
83  status = m_rbclogic.Register( key , createlogic );
84 
85  m_logkeys.push_back( key );
86 
87  key = std::string("PointingLogic");
88  createlogic = (GenLogic * (*)()) &createPointingLogic;
89  status = m_rbclogic.Register( key , createlogic );
90 
91  m_logkeys.push_back( key );
92 
93  return status;
94 
95  };
96 
97 
98  GenLogic * retrieve( const std::string & _logic_name )
99  {
100  GenLogic * _obj;
101  _obj = m_rbclogic.CreateObject( _logic_name );
102  return _obj;
103  };
104 
105  bool endjob()
106  {
107  bool status(true);
108  typename std::vector<std::string>::iterator itr = m_logkeys.begin();
109  while ( itr != m_logkeys.end() )
110  {
111  status = status && ( m_rbclogic.Unregister( (*itr) ) );
112  ++itr;
113  }
114  return status;
115 
116  };
117 
118 
119 protected:
120 
121 private:
122 
123  typename std::vector<std::string> m_logkeys;
124 
125 };
126 #endif // LOGICTOOL_H
Ilogic * CreateObject(const Identifier &id)
Definition: LogicFactory.h:39
TTUWedgeORLogic * createWedgeORLogic()
Definition: LogicImp.cc:19
RBCChamberORLogic * createChamberORLogic()
Definition: LogicImp.cc:14
TTUSectorORLogic * createSectorORLogic()
Definition: LogicImp.cc:17
GenLogic * retrieve(const std::string &_logic_name)
Definition: LogicTool.h:98
LogicFactory< GenLogic, std::string > RBCLogicType
Destructor.
Definition: LogicTool.h:29
bool Register(const Identifier &id, LogicCreator creator)
Definition: LogicFactory.h:24
LogicTool()
Standard constructor.
Definition: LogicTool.h:25
GenLogic *(* createlogic)()
Definition: LogicTool.h:35
RBCTestLogic * createTestLogic()
Definition: LogicImp.cc:13
bool Unregister(const Identifier &id)
Definition: LogicFactory.h:29
TTUPointingLogic * createPointingLogic()
Definition: LogicImp.cc:20
bool initialise()
Definition: LogicTool.h:39
TTUTwoORLogic * createTwoORLogic()
Definition: LogicImp.cc:18
std::vector< std::string > m_logkeys
Definition: LogicTool.h:116
bool endjob()
Definition: LogicTool.h:105
list key
Definition: combine.py:13
virtual ~LogicTool()
Definition: LogicTool.h:27
TTUTrackingAlg * createTrackingAlg()
Definition: LogicImp.cc:16
RBCPatternLogic * createPatternLogic()
Definition: LogicImp.cc:15
tuple status
Definition: ntuplemaker.py:245
RBCLogicType m_rbclogic
Definition: LogicTool.h:37