Go to the documentation of this file.00001 #ifndef PhysicsTools_MVAComputer_ProcessRegistry_h
00002 #define PhysicsTools_MVAComputer_ProcessRegistry_h
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <string>
00016 #include <map>
00017
00018 namespace PhysicsTools {
00019
00031 template<class Base_t, class CalibBase_t, class Parent_t>
00032 class ProcessRegistry {
00033 public:
00043 template<class Instance_t, class Calibration_t>
00044 class Registry : public ProcessRegistry<Base_t, CalibBase_t, Parent_t> {
00045 public:
00046 Registry(const char *name) :
00047 ProcessRegistry<Base_t, CalibBase_t, Parent_t>(name) {}
00048
00049 protected:
00050 Base_t *instance(const char *name, const CalibBase_t *calib,
00051 Parent_t *parent) const
00052 {
00053 return new Instance_t(name,
00054 dynamic_cast<const Calibration_t*>(calib),
00055 parent);
00056 }
00057 };
00058
00068 class Factory {
00069 public:
00070 static Base_t *create(const char *name,
00071 const CalibBase_t *calib,
00072 Parent_t *parent = 0);
00073 };
00074
00075 protected:
00076 friend class Factory;
00077
00079 ProcessRegistry(const char *name) : name(name)
00080 { registerProcess(name, this); }
00081 virtual ~ProcessRegistry() { unregisterProcess(name); }
00082
00084 static Base_t *create(const char *name, const CalibBase_t *calib,
00085 Parent_t *parent);
00086
00088 virtual Base_t *instance(const char *name, const CalibBase_t *calib,
00089 Parent_t *parent) const = 0;
00090
00091 private:
00092 static void registerProcess(const char *name,
00093 const ProcessRegistry *process);
00094 static void unregisterProcess(const char *name);
00095
00096 typedef std::map<std::string, const ProcessRegistry*> RegistryMap;
00097
00099 static RegistryMap *getRegistry();
00100
00101 const char *name;
00102 };
00103
00104 }
00105
00106 #include "PhysicsTools/MVAComputer/interface/ProcessRegistry.icc"
00107
00108 #endif // PhysicsTools_MVAComputer_ProcessRegistry_h