7 #ifndef YARP_OS_ELECTION_H
8 #define YARP_OS_ELECTION_H
63 typedef void* voidPtr;
67 typedef typename std::map<std::string, PR> map_type;
71 PR* getRecordRaw(
const std::string& key,
bool create =
false)
73 typename map_type::iterator entry = nameMap.find(key);
74 if (entry == nameMap.end() && create) {
76 entry = nameMap.find(key);
78 if (entry == nameMap.end()) {
81 return &(entry->second);
88 PR*
add(
const std::string& key,
typename PR::peer_type* entity)
92 PR* rec = getRecordRaw(key,
true);
99 void remove(
const std::string& key,
typename PR::peer_type* entity)
103 PR* rec = getRecordRaw(key,
false);
109 typename PR::peer_type*
getElect(
const std::string& key)
112 PR* rec = getRecordRaw(key,
false);
115 return rec->getFirst();
123 PR* rec = getRecordRaw(key,
false);
Pick one of a set of peers to be "active".
PR::peer_type * getElect(const std::string &key)
virtual ~ElectionOf()=default
PR * add(const std::string &key, typename PR::peer_type *entity)
PR * getRecord(const std::string &key)
void remove(const std::string &key, typename PR::peer_type *entity)
PeerRecord(const PeerRecord &alt)=default
map_type::iterator iterator
map_type::const_iterator const_iterator
std::map< T *, bool > map_type
The main, catch-all namespace for YARP.