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