CMS 3D CMS Logo

Proxy.h
Go to the documentation of this file.
1 #ifndef GeneratorInterface_Herwig7Interface_Proxy_h
2 #define GeneratorInterface_Herwig7Interface_Proxy_h
3 #include <memory>
4 
5 namespace ThePEG {
6 
7  // forward declarations
8  class LHEEvent;
9  class LHERunInfo;
10 
11  template <class T>
12  class Proxy;
13 
14  class ProxyBase {
15  public:
16  typedef unsigned long ProxyID;
17 
18  virtual ~ProxyBase();
19 
20  ProxyID getID() const { return id; }
21 
22  private:
23  typedef ProxyBase *(*ctor_t)(ProxyID id);
24 
25  template <class T>
26  friend class Proxy;
27 
28  ProxyBase(ProxyID id);
29 
30  static std::shared_ptr<ProxyBase> create(ctor_t ctor);
31  static std::shared_ptr<ProxyBase> find(ProxyID id);
32 
33  // not allowed and not implemented
34  ProxyBase(const ProxyBase &orig) = delete;
35  ProxyBase &operator=(const ProxyBase &orig) = delete;
36 
37  const ProxyID id;
38  };
39 
40  template <class T>
41  class Proxy : public ProxyBase {
42  public:
43  typedef Proxy Base;
44 
45  static inline std::shared_ptr<T> create() { return std::static_pointer_cast<T>(ProxyBase::create(&Proxy::ctor)); }
46  static inline std::shared_ptr<T> find(ProxyID id) { return std::dynamic_pointer_cast<T>(ProxyBase::find(id)); }
47 
48  protected:
49  inline Proxy(ProxyID id) : ProxyBase(id) {}
50 
51  private:
52  static ProxyBase *ctor(ProxyID id) { return new T(id); }
53  };
54 
55 } // namespace ThePEG
56 
57 #endif // GeneratorProxy_Herwig7Interface_Proxy_h
ThePEG::ProxyBase::ctor_t
ProxyBase *(* ctor_t)(ProxyID id)
Definition: Proxy.h:23
ThePEG::Proxy::find
static std::shared_ptr< T > find(ProxyID id)
Definition: Proxy.h:46
particlelevel_cff.LHERunInfo
LHERunInfo
Definition: particlelevel_cff.py:56
ThePEG::Proxy::create
static std::shared_ptr< T > create()
Definition: Proxy.h:45
ThePEG::ProxyBase::ProxyBase
ProxyBase(ProxyID id)
Definition: Proxy.cc:26
ThePEG::ProxyBase::operator=
ProxyBase & operator=(const ProxyBase &orig)=delete
ThePEG::Proxy::ctor
static ProxyBase * ctor(ProxyID id)
Definition: Proxy.h:52
ThePEG::ProxyBase
Definition: Proxy.h:14
ThePEG::Proxy
Definition: Proxy.h:12
ThePEG
Definition: Herwig7Interface.h:24
ThePEG::ProxyBase::getID
ProxyID getID() const
Definition: Proxy.h:20
ThePEG::ProxyBase::id
const ProxyID id
Definition: Proxy.h:37
ThePEG::ProxyBase::find
static std::shared_ptr< ProxyBase > find(ProxyID id)
Definition: Proxy.cc:50
ThePEG::ProxyBase::ProxyID
unsigned long ProxyID
Definition: Proxy.h:16
ThePEG::ProxyBase::~ProxyBase
virtual ~ProxyBase()
Definition: Proxy.cc:28
ThePEG::Proxy::Base
Proxy Base
Definition: Proxy.h:43
ThePEG::Proxy::Proxy
Proxy(ProxyID id)
Definition: Proxy.h:49
T
long double T
Definition: Basic3DVectorLD.h:48
ThePEG::ProxyBase::create
static std::shared_ptr< ProxyBase > create(ctor_t ctor)
Definition: Proxy.cc:36