7#ifndef YARP_OS_ELECTION_H
8#define YARP_OS_ELECTION_H
66 typedef typename std::map<std::string, PR> map_type;
70 PR* getRecordRaw(
const std::string& key,
bool create =
false)
72 typename map_type::iterator
entry = nameMap.find(key);
73 if (
entry == nameMap.end() && create) {
75 entry = nameMap.find(key);
77 if (
entry == nameMap.end()) {
80 return &(
entry->second);
87 PR*
add(
const std::string& key,
typename PR::peer_type*
entity)
91 PR*
rec = getRecordRaw(key,
true);
98 void remove(
const std::string& key,
typename PR::peer_type*
entity)
102 PR*
rec = getRecordRaw(key,
false);
108 typename PR::peer_type*
getElect(
const std::string& key)
111 PR*
rec = getRecordRaw(key,
false);
114 return rec->getFirst();
122 PR*
rec = getRecordRaw(key,
false);
A mini-server for performing network communication in the background.
Pick one of a set of peers to be "active".
virtual ~ElectionOf()=default
PR * add(const std::string &key, typename PR::peer_type *entity)
PR::peer_type * getElect(const std::string &key)
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
An interface to the operating system, including Port based communication.