CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Friends
ThePEG::ProxyBase Class Reference

#include <Proxy.h>

Inheritance diagram for ThePEG::ProxyBase:
ThePEG::Proxy< Proxy > ThePEG::Proxy< T > ThePEG::RandomEngineGlue::Proxy

Public Types

typedef unsigned long ProxyID
 

Public Member Functions

ProxyID getID () const
 
ProxyBaseoperator= (const ProxyBase &orig)=delete
 
 ProxyBase (const ProxyBase &orig)=delete
 
virtual ~ProxyBase ()
 

Private Types

typedef ProxyBase *(* ctor_t) (ProxyID id)
 

Private Member Functions

 ProxyBase (ProxyID id)
 

Static Private Member Functions

static std::shared_ptr< ProxyBasecreate (ctor_t ctor)
 
static std::shared_ptr< ProxyBasefind (ProxyID id)
 

Private Attributes

const ProxyID id
 

Friends

template<class T >
class Proxy
 

Detailed Description

Definition at line 14 of file Proxy.h.

Member Typedef Documentation

◆ ctor_t

typedef ProxyBase*(* ThePEG::ProxyBase::ctor_t) (ProxyID id)
private

Definition at line 27 of file Proxy.h.

◆ ProxyID

typedef unsigned long ThePEG::ProxyBase::ProxyID

Definition at line 16 of file Proxy.h.

Constructor & Destructor Documentation

◆ ProxyBase() [1/2]

ThePEG::ProxyBase::ProxyBase ( const ProxyBase orig)
delete

◆ ~ProxyBase()

ProxyBase::~ProxyBase ( )
virtual

Definition at line 28 of file Proxy.cc.

References getProxyMapInstance(), genParticles_cff::map, and mutex.

28  {
29  std::scoped_lock scoped_lock(mutex);
30 
32  if (map)
33  map->erase(id);
34 }
std::map< ProxyBase::ProxyID, std::weak_ptr< ProxyBase > > ProxyMap
Definition: Proxy.cc:10
static std::mutex mutex
Definition: Proxy.cc:8
static ProxyMap * getProxyMapInstance()
Definition: Proxy.cc:12

◆ ProxyBase() [2/2]

ProxyBase::ProxyBase ( ProxyID  id)
private

Definition at line 26 of file Proxy.cc.

26 : id(id) {}
const ProxyID id
Definition: Proxy.h:37

Member Function Documentation

◆ create()

std::shared_ptr< ProxyBase > ProxyBase::create ( ctor_t  ctor)
staticprivate

Definition at line 36 of file Proxy.cc.

References getProxyMapInstance(), genParticles_cff::map, and mutex.

Referenced by ThePEG::Proxy< Proxy >::create().

36  {
37  static ProxyBase::ProxyID nextProxyID = 0;
38 
39  std::scoped_lock scoped_lock(mutex);
40 
41  std::shared_ptr<ProxyBase> proxy(ctor(++nextProxyID));
42 
44  if (map)
45  map->insert(ProxyMap::value_type(proxy->getID(), proxy));
46 
47  return proxy;
48 }
std::map< ProxyBase::ProxyID, std::weak_ptr< ProxyBase > > ProxyMap
Definition: Proxy.cc:10
static std::mutex mutex
Definition: Proxy.cc:8
static ProxyMap * getProxyMapInstance()
Definition: Proxy.cc:12
unsigned long ProxyID
Definition: Proxy.h:16

◆ find()

std::shared_ptr< ProxyBase > ProxyBase::find ( ProxyID  id)
staticprivate

Definition at line 50 of file Proxy.cc.

References getProxyMapInstance(), genParticles_cff::map, and mutex.

Referenced by ThePEG::Proxy< Proxy >::find().

50  {
51  std::scoped_lock scoped_lock(mutex);
52 
54  if (!map)
55  return std::shared_ptr<ProxyBase>();
56 
57  ProxyMap::const_iterator pos = map->find(id);
58  if (pos == map->end())
59  return std::shared_ptr<ProxyBase>();
60 
61  return std::shared_ptr<ProxyBase>(pos->second);
62 }
std::map< ProxyBase::ProxyID, std::weak_ptr< ProxyBase > > ProxyMap
Definition: Proxy.cc:10
static std::mutex mutex
Definition: Proxy.cc:8
static ProxyMap * getProxyMapInstance()
Definition: Proxy.cc:12

◆ getID()

ProxyID ThePEG::ProxyBase::getID ( ) const
inline

Definition at line 24 of file Proxy.h.

References id.

24 { return id; }
const ProxyID id
Definition: Proxy.h:37

◆ operator=()

ProxyBase& ThePEG::ProxyBase::operator= ( const ProxyBase orig)
delete

Friends And Related Function Documentation

◆ Proxy

template<class T >
friend class Proxy
friend

Definition at line 30 of file Proxy.h.

Member Data Documentation

◆ id

const ProxyID ThePEG::ProxyBase::id
private

Definition at line 37 of file Proxy.h.

Referenced by getID().