24 Node*
getNode(
const std::string& name,
bool create);
27 void prepare(
const std::string& name);
29 Contact query(
const std::string& name,
const std::string& category);
43 std::map<std::string, std::pair<Node*, bool>>
nodes_map;
64 for (
auto&
n : nodes_map) {
65 if (
n.second.first !=
nullptr) {
66 if (!
n.second.second) {
67 delete n.second.first;
68 n.second.first =
nullptr;
77 if (dummy !=
nullptr) {
91 if (
it != nodes_map.end()) {
92 node =
it->second.first;
97 if (
it == nodes_map.end()) {
98 nodes_map[nc.
getNodeName()] = std::make_pair(node,
false);
104 node =
it->second.first;
121 if (node !=
nullptr) {
122 node->
add(contactable);
136 if (node !=
nullptr) {
137 node->
update(contactable);
158 Node* node = getNode(contactable.
getName(),
false);
159 if (node !=
nullptr) {
160 node->
remove(contactable);
171 for (
const auto&
n : nodes_map) {
172 result =
n.second.first->query(name, category);
186 for (
const auto&
n : nodes_map) {
206 if (
it != nodes_map.end()) {
207 result =
it->second.first->
where();
218 if (
it != nodes_map.end()) {
227 nodes_map[name].second =
true;
238 if (active_name.empty()) {
239 dummy =
new Node(
"...");
247 yAssert(nodes_map.find(name) == nodes_map.end());
248 nodes_map[name] = std::make_pair(&node,
true);
255 nodes_map.erase(name);
272 mPriv->add(contactable);
277 mPriv->remove(contactable);
282 return mPriv->query(name, category);
292 return mPriv->enable(
flag);
302 return mPriv->getParent(name);
307 return mPriv->getURI(name);
317 mPriv->update(contactable);
322 mPriv->setActiveName(name);
327 return mPriv->getActiveName();
332 return mPriv->requireActiveName();
337 mPriv->addExternalNode(name, node);
342 mPriv->removeExternalNode(name);
A mini-server for performing network communication in the background.
Contact where() const override
Returns information about how this port can be reached.
void interrupt() override
Interrupt any current reads or writes attached to the port.
T & prepare()
Access the object which will be transmitted by the next call to yarp::os::BufferedPort::write.
void prepare(const std::string &name)
prepare if it is not already been done, opens the port of the Node.
void update(Contactable &contactable)
update should update the contactable with new information.
void remove(Contactable &contactable) override
remove specified contactable from the list of contactables associated with this Node.
void add(Contactable &contactable) override
add a contactable to this node.
std::map< std::string, std::pair< Node *, bool > > nodes_map
void addExternalNode(const std::string &name, Node &node)
void add(Contactable &contactable)
void prepare(const std::string &name)
Contact query(const std::string &name, const std::string &category)
std::string getActiveName()
Contact getParent(const std::string &name)
Node * getNode(const std::string &name, bool create)
void removeExternalNode(const std::string &name)
Contact getURI(const std::string &name)
void remove(Contactable &contactable)
void setActiveName(const std::string &name)
void update(Contactable &contactable)
void removeExternalNode(const std::string &name)
removeExternalNode erase the node from the container.
void remove(Contactable &contactable) override
remove a Contactable from the Node specified in the contactable's name.
virtual Contact query(const std::string &name, const std::string &category="") override
query the list of Node to find a Contact with the specified name.
void addExternalNode(const std::string &name, Node &node)
addExternalNode adds a Node to this container.
Contact getURI(const std::string &name)
getURI queries the Node specified in the name parameter to get Contact information about the specifie...
std::string getActiveName()
getActiveName getter for the currently active node's name
bool enable(bool flag)
enable setter for the activity state of the container.
bool requireActiveName()
requireActiveName if there is no active node, creates a temporary one.
void clear()
clear empties the container
void add(Contactable &contactable) override
add a Contactable to the Node specified in the contactable name (see NestedContact....
void setActiveName(const std::string &name)
setActiveName setter for the currently active node
void prepare(const std::string &name)
prepare checks for the existence of the node specified in the name parameter.
void interrupt()
interrupt delegates interrupt call to all of the Node in this container.
virtual void update(Contactable &contactable)
update a Node information in this container.
Contact getParent(const std::string &name)
getParent get info about node associated with the specified port.
An interface to the operating system, including Port based communication.
The main, catch-all namespace for YARP.