10 #ifndef YARP_OS_ELECTION_H
11 #define YARP_OS_ELECTION_H
66 typedef void* voidPtr;
70 typedef typename std::map<std::string, PR> map_type;
74 PR* getRecordRaw(
const std::string& key,
bool create =
false)
76 typename map_type::iterator entry = nameMap.find(key);
77 if (entry == nameMap.end() && create) {
79 entry = nameMap.find(key);
81 if (entry == nameMap.end()) {
84 return &(entry->second);
91 PR*
add(
const std::string& key,
typename PR::peer_type* entity)
95 PR* rec = getRecordRaw(key,
true);
102 void remove(
const std::string& key,
typename PR::peer_type* entity)
106 PR* rec = getRecordRaw(key,
false);
112 typename PR::peer_type*
getElect(
const std::string& key)
115 PR* rec = getRecordRaw(key,
false);
118 return rec->getFirst();
126 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.