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
 
virtual ~ProxyBase ()
 

Private Types

typedef ProxyBase *(* ctor_t) (ProxyID id)
 

Private Member Functions

ProxyBaseoperator= (const ProxyBase &orig)=delete
 
 ProxyBase (const ProxyBase &orig)=delete
 
 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 23 of file Proxy.h.

◆ ProxyID

typedef unsigned long ThePEG::ProxyBase::ProxyID

Definition at line 16 of file Proxy.h.

Constructor & Destructor Documentation

◆ ~ProxyBase()

ProxyBase::~ProxyBase ( )
virtual

Definition at line 28 of file Proxy.cc.

28  {
29  std::scoped_lock scoped_lock(mutex);
30 
32  if (map)
33  map->erase(id);
34 }

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

◆ ProxyBase() [1/2]

ProxyBase::ProxyBase ( ProxyID  id)
private

Definition at line 26 of file Proxy.cc.

26 : id(id) {}

◆ ProxyBase() [2/2]

ThePEG::ProxyBase::ProxyBase ( const ProxyBase orig)
privatedelete

Member Function Documentation

◆ create()

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

Definition at line 36 of file Proxy.cc.

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 }

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

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

◆ find()

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

Definition at line 50 of file Proxy.cc.

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 }

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

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

◆ getID()

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

Definition at line 20 of file Proxy.h.

20 { return id; }

References id.

◆ operator=()

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

Friends And Related Function Documentation

◆ Proxy

template<class T >
friend class Proxy
friend

Definition at line 26 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().

pos
Definition: PixelAliasList.h:18
ThePEG::ProxyBase::id
const ProxyID id
Definition: Proxy.h:37
ThePEG::ProxyBase::ProxyID
unsigned long ProxyID
Definition: Proxy.h:16
mutex
static std::mutex mutex
Definition: Proxy.cc:8
getProxyMapInstance
static ProxyMap * getProxyMapInstance()
Definition: Proxy.cc:12
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition: JetExtendedAssociation.h:30
ProxyMap
std::map< ProxyBase::ProxyID, std::weak_ptr< ProxyBase > > ProxyMap
Definition: Proxy.cc:10
genParticles_cff.map
map
Definition: genParticles_cff.py:11