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 (ProxyID id)
 
 ProxyBase (const ProxyBase &orig)=delete
 

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

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

Definition at line 23 of file Proxy.h.

typedef unsigned long ThePEG::ProxyBase::ProxyID

Definition at line 16 of file Proxy.h.

Constructor & Destructor Documentation

ProxyBase::~ProxyBase ( )
virtual

Definition at line 29 of file Proxy.cc.

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

29  {
30  boost::mutex::scoped_lock scoped_lock(mutex);
31 
33  if (map)
34  map->erase(id);
35 }
static boost::mutex mutex
Definition: Proxy.cc:9
std::map< ProxyBase::ProxyID, std::weak_ptr< ProxyBase > > ProxyMap
Definition: Proxy.cc:11
static ProxyMap * getProxyMapInstance()
Definition: Proxy.cc:13
ProxyBase::ProxyBase ( ProxyID  id)
private

Definition at line 27 of file Proxy.cc.

27 : id(id) {}
const ProxyID id
Definition: Proxy.h:37
ThePEG::ProxyBase::ProxyBase ( const ProxyBase orig)
privatedelete

Member Function Documentation

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

Definition at line 37 of file Proxy.cc.

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

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

37  {
38  static ProxyBase::ProxyID nextProxyID = 0;
39 
40  boost::mutex::scoped_lock scoped_lock(mutex);
41 
42  std::shared_ptr<ProxyBase> proxy(ctor(++nextProxyID));
43 
45  if (map)
46  map->insert(ProxyMap::value_type(proxy->getID(), proxy));
47 
48  return proxy;
49 }
static boost::mutex mutex
Definition: Proxy.cc:9
std::map< ProxyBase::ProxyID, std::weak_ptr< ProxyBase > > ProxyMap
Definition: Proxy.cc:11
static ProxyMap * getProxyMapInstance()
Definition: Proxy.cc:13
unsigned long ProxyID
Definition: Proxy.h:16
std::shared_ptr< ProxyBase > ProxyBase::find ( ProxyID  id)
staticprivate

Definition at line 51 of file Proxy.cc.

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

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

51  {
52  boost::mutex::scoped_lock scoped_lock(mutex);
53 
55  if (!map)
56  return std::shared_ptr<ProxyBase>();
57 
58  ProxyMap::const_iterator pos = map->find(id);
59  if (pos == map->end())
60  return std::shared_ptr<ProxyBase>();
61 
62  return std::shared_ptr<ProxyBase>(pos->second);
63 }
static boost::mutex mutex
Definition: Proxy.cc:9
std::map< ProxyBase::ProxyID, std::weak_ptr< ProxyBase > > ProxyMap
Definition: Proxy.cc:11
static ProxyMap * getProxyMapInstance()
Definition: Proxy.cc:13
ProxyID ThePEG::ProxyBase::getID ( ) const
inline

Definition at line 20 of file Proxy.h.

References id.

20 { return id; }
const ProxyID id
Definition: Proxy.h:37
ProxyBase& ThePEG::ProxyBase::operator= ( const ProxyBase orig)
privatedelete

Friends And Related Function Documentation

template<class T >
friend class Proxy
friend

Definition at line 26 of file Proxy.h.

Member Data Documentation

const ProxyID ThePEG::ProxyBase::id
private

Definition at line 37 of file Proxy.h.

Referenced by getID().