CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ProcessRegistry.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_MVAComputer_ProcessRegistry_h
2 #define PhysicsTools_MVAComputer_ProcessRegistry_h
3 // -*- C++ -*-
4 //
5 // Package: MVAComputer
6 // Class : ProcessRegistry
7 //
8 
9 //
10 // Author: Christophe Saout <christophe.saout@cern.ch>
11 // Created: Sat Apr 24 15:18 CEST 2007
12 // $Id: ProcessRegistry.h,v 1.9 2011/04/15 17:07:13 wmtan Exp $
13 //
14 
15 #include <string>
16 #include <map>
17 
18 namespace PhysicsTools {
19 
31 template<class Base_t, class CalibBase_t, class Parent_t>
33  public:
43  template<class Instance_t, class Calibration_t>
44  class Registry : public ProcessRegistry<Base_t, CalibBase_t, Parent_t> {
45  public:
46  Registry(const char *name) :
47  ProcessRegistry<Base_t, CalibBase_t, Parent_t>(name) {}
48 
49  protected:
50  Base_t *instance(const char *name, const CalibBase_t *calib,
51  Parent_t *parent) const
52  {
53  return new Instance_t(name,
54  dynamic_cast<const Calibration_t*>(calib),
55  parent);
56  }
57  };
58 
68  class Factory {
69  public:
70  static Base_t *create(const char *name,
71  const CalibBase_t *calib,
72  Parent_t *parent = 0);
73  };
74 
75  protected:
76  friend class Factory;
77 
79  ProcessRegistry(const char *name) : name(name)
80  { registerProcess(name, this); }
82 
84  static Base_t *create(const char *name, const CalibBase_t *calib,
85  Parent_t *parent);
86 
88  virtual Base_t *instance(const char *name, const CalibBase_t *calib,
89  Parent_t *parent) const = 0;
90 
91  private:
92  static void registerProcess(const char *name,
93  const ProcessRegistry *process);
94  static void unregisterProcess(const char *name);
95 
96  typedef std::map<std::string, const ProcessRegistry*> RegistryMap;
97 
99  static RegistryMap *getRegistry();
100 
101  const char *name;
102 };
103 
104 } // namespace PhysicsTools
105 
106 #endif // PhysicsTools_MVAComputer_ProcessRegistry_h
list parent
Definition: dbtoconf.py:74
Base_t * instance(const char *name, const CalibBase_t *calib, Parent_t *parent) const
virtual method to implement by respective processor instance classes
static Base_t * create(const char *name, const CalibBase_t *calib, Parent_t *parent)
create an instance of name, given a calibration calib and parent parent
static void unregisterProcess(const char *name)
static void registerProcess(const char *name, const ProcessRegistry *process)
MVATrainerComputer * calib
Definition: MVATrainer.cc:64
ProcessRegistry(const char *name)
instantiate registry and registers itself with name
virtual Base_t * instance(const char *name, const CalibBase_t *calib, Parent_t *parent) const =0
virtual method to implement by respective processor instance classes
static Base_t * create(const char *name, const CalibBase_t *calib, Parent_t *parent=0)
std::map< std::string, const ProcessRegistry * > RegistryMap
static RegistryMap * getRegistry()
return map of all registered processes, allocate if necessary
Factory helper class to instantiate a processor.
template to generate a registry singleton for a type.
Generic registry template for polymorphic processor implementations.
tuple process
Definition: LaserDQM_cfg.py:3