YARP  2.3.68+225-20170329.5+gitb0d3289
Yet Another Robot Platform
yarp::os::ElectionOf< PR > Class Template Reference

Pick one of a set of peers to be "active". More...

#include <yarp/os/Election.h>

Public Member Functions

 ElectionOf ()
 
virtual ~ElectionOf ()
 
PR * add (const yarp::os::ConstString &key, typename PR::peer_type *entity)
 
void remove (const yarp::os::ConstString &key, typename PR::peer_type *entity)
 
PR::peer_type * getElect (const yarp::os::ConstString &key)
 
PR * getRecord (const yarp::os::ConstString &key)
 
long getEventCount ()
 
void lock ()
 
void unlock ()
 

Private Types

typedef void * voidPtr
 
typedef std::map< yarp::os::ConstString, PR > map_type
 

Private Member Functions

PR * getRecordRaw (const yarp::os::ConstString &key, bool create=false)
 

Private Attributes

yarp::os::Semaphore mutex
 
map_type nameMap
 
long ct
 

Detailed Description

template<class PR>
class yarp::os::ElectionOf< PR >

Pick one of a set of peers to be "active".

Used for situations where a manager is required for some resource used by several peers, but it doesn't matter which peer plays that role.

PR should be a subclass of PeerRecord.

Definition at line 19 of file Election.h.

Member Typedef Documentation

◆ map_type

template<class PR>
typedef std::map<yarp::os::ConstString,PR> yarp::os::ElectionOf< PR >::map_type
private

Definition at line 69 of file Election.h.

◆ voidPtr

template<class PR>
typedef void* yarp::os::ElectionOf< PR >::voidPtr
private

Definition at line 65 of file Election.h.

Constructor & Destructor Documentation

◆ ElectionOf()

template<class PR>
yarp::os::ElectionOf< PR >::ElectionOf ( )
inline

Definition at line 85 of file Election.h.

◆ ~ElectionOf()

template<class PR>
virtual yarp::os::ElectionOf< PR >::~ElectionOf ( )
inlinevirtual

Definition at line 88 of file Election.h.

Member Function Documentation

◆ add()

template<class PR>
PR* yarp::os::ElectionOf< PR >::add ( const yarp::os::ConstString key,
typename PR::peer_type *  entity 
)
inline

Definition at line 90 of file Election.h.

◆ getElect()

template<class PR>
PR::peer_type* yarp::os::ElectionOf< PR >::getElect ( const yarp::os::ConstString key)
inline

Definition at line 108 of file Election.h.

◆ getEventCount()

template<class PR>
long yarp::os::ElectionOf< PR >::getEventCount ( )
inline

Definition at line 125 of file Election.h.

◆ getRecord()

template<class PR>
PR* yarp::os::ElectionOf< PR >::getRecord ( const yarp::os::ConstString key)
inline

Definition at line 118 of file Election.h.

◆ getRecordRaw()

template<class PR>
PR* yarp::os::ElectionOf< PR >::getRecordRaw ( const yarp::os::ConstString key,
bool  create = false 
)
inlineprivate

Definition at line 73 of file Election.h.

◆ lock()

template<class PR>
void yarp::os::ElectionOf< PR >::lock ( )
inline

Definition at line 129 of file Election.h.

◆ remove()

template<class PR>
void yarp::os::ElectionOf< PR >::remove ( const yarp::os::ConstString key,
typename PR::peer_type *  entity 
)
inline

Definition at line 99 of file Election.h.

◆ unlock()

template<class PR>
void yarp::os::ElectionOf< PR >::unlock ( )
inline

Definition at line 130 of file Election.h.

Member Data Documentation

◆ ct

template<class PR>
long yarp::os::ElectionOf< PR >::ct
private

Definition at line 71 of file Election.h.

◆ mutex

template<class PR>
yarp::os::Semaphore yarp::os::ElectionOf< PR >::mutex
private

Definition at line 67 of file Election.h.

◆ nameMap

template<class PR>
map_type yarp::os::ElectionOf< PR >::nameMap
private

Definition at line 70 of file Election.h.


The documentation for this class was generated from the following file: