93 return (
cat.empty() ||
cat ==
"-");
99 return (
cat.empty() ||
cat ==
"+");
105 return (
cat.empty() ||
cat ==
"+" ||
cat ==
"-");
111 return (
cat.empty() ||
cat ==
"-1");
117 return (
cat.empty() ||
cat ==
"+1");
123 return (
cat.empty() ||
cat ==
"+1" ||
cat ==
"-1");
174 msg =
alt.get(1).asString();
207 if (!
mutex.try_lock()) {
234 std::vector<Contact>
query(
const std::string&
name,
const std::string& category = std::string());
261 if (!(
item.isSubscriber() ||
item.isPublisher())) {
291 if (connections->
size() == 0) {
307 na.reply =
Value(std::string(
"hmm"));
323 if (!
item.isSubscriber()) {
343 if (!
item.isPublisher()) {
358 na.reply =
Value(std::string(
"hmm"));
366 na.fail(
"Cannot find topic");
383 na.fromExternal(reply);
389 std::string topic =
na.args.get(0).asString();
393 na.fail(
"Cannot find topic");
409 na.fail(
"Cannot find topic");
419 if (prop !=
nullptr) {
420 prop->
put(
"node_like", 1);
434 name =
item.nc.getNodeName();
436 if (name !=
item.nc.getNodeName()) {
437 yCError(
NODE,
"Node name mismatch, expected [%s] but got [%s]\n", name.c_str(),
item.nc.getNodeName().c_str());
441 item.contactable = &contactable;
444 name_cache[&contactable] =
item;
445 by_part_name.insert(std::pair<std::string, NodeItem>(
item.nc.getNestedName(),
item));
446 by_category.insert(std::pair<std::string, NodeItem>(
item.nc.getCategory(),
item));
461 name_cache.erase(&contactable);
462 std::string nestedName =
item.nc.getNestedName();
463 for (
auto it = by_part_name.begin();
it != by_part_name.end(); ++
it) {
464 if (
it->first == nestedName &&
it->second.contactable->
where().
toString() == contactable.
where().toString()) {
465 by_part_name.erase(
it);
469 std::string category =
item.nc.getCategory();
470 for (
auto it = by_category.begin();
it != by_category.end(); ++
it) {
471 if (
it->first == category &&
it->second.contactable->
where().
toString() == contactable.
where().toString()) {
472 by_category.erase(
it);
483 for (std::multimap<std::string, NodeItem>::const_iterator
it = by_part_name.begin();
it != by_part_name.end(); ++
it) {
484 if (
it->first == name && (category.empty() || category ==
it->second.nc.getCategory())) {
500 yCDebug(
NODE,
"NODE API for %s received %s\n", name.c_str(),
na.request.toString().c_str());
501 std::string key =
na.request.get(0).asString();
502 na.args =
na.request.tail().tail();
503 if (key ==
"getBusStats") {
505 }
else if (key ==
"getBusInfo") {
507 }
else if (key ==
"getMasterUri") {
509 }
else if (key ==
"shutdown") {
511 }
else if (key ==
"getPid") {
513 }
else if (key ==
"getSubscriptions") {
514 getSubscriptions(
na);
515 }
else if (key ==
"getPublications") {
517 }
else if (key ==
"paramUpdate") {
519 }
else if (key ==
"publisherUpdate") {
521 }
else if (key ==
"requestTopic") {
524 na.error(
"I have no idea what you are talking about");
526 if (
na.should_drop) {
534 yCDebug(
NODE,
"NODE %s <<< %s\n", name.c_str(),
full.toString().c_str());
575 mPriv->
add(contactable);
580 mPriv->
update(contactable);
585 mPriv->
remove(contactable);
590 std::vector<Contact>
contacts = mPriv->
query(name, category);
void cat(Vector &a, const Vector &b)
static std::string fromRosName(const std::string &str)
static std::string toRosName(const std::string &str)
void fail(const char *txt)
void error(const char *txt)
void fromExternal(const Bottle &alt)
Contactable * contactable
std::multimap< std::string, std::string > outgoingURIs
std::multimap< std::string, std::string > incomingURIs
void report(const PortInfo &info) override
Callback for port event/state information.
A simple collection of objects that can be described and transmitted in a portable way.
Bottle & addList()
Places an empty nested list in the bottle, at the end of the list.
size_type size() const
Gets the number of elements in the bottle.
void addInt32(std::int32_t x)
Places a 32-bit integer in the bottle, at the end of the list.
void addString(const char *str)
Places a string in the bottle, at the end of the list.
A mini-server for performing network communication in the background.
Contact where() const override
Returns information about how this port can be reached.
std::string getName() const override
Get name of port.
void close() override
Stop port activity.
void interrupt() override
Interrupt any current reads or writes attached to the port.
void getReport(PortReport &reporter) override
Get information on the state of the port - connections etc.
T * read(bool shouldWait=true) override
Read an available object from the port.
void write(bool forceStrict=false)
Write the current object being returned by BufferedPort::prepare.
An interface for reading from a network connection.
virtual void requestDrop()=0
Tag the connection to be dropped after the current message.
virtual ConnectionWriter * getWriter()=0
Gets a way to reply to the message, if possible.
virtual bool isValid() const =0
static bool write(const Contact &contact, PortWriter &cmd, PortReader &reply, bool admin=false, bool quiet=false, double timeout=-1)
Send a single command to a port and await a single response.
void update(Contactable &contactable)
std::vector< Contact > query(const std::string &name, const std::string &category=std::string())
void getPid(NodeArgs &na)
std::multimap< std::string, NodeItem > by_part_name
void shutdown(NodeArgs &na)
void prepare(const std::string &name)
void publisherUpdate(NodeArgs &na)
void getBusInfo(NodeArgs &na)
std::map< Contactable *, NodeItem > name_cache
void paramUpdate(NodeArgs &na)
void getSubscriptions(NodeArgs &na)
void add(Contactable &contactable)
std::multimap< std::string, NodeItem > by_category
bool read(ConnectionReader &reader) override
Read this object from a network connection.
void requestTopic(NodeArgs &na)
void getBusStats(NodeArgs &na)
void remove(Contactable &contactable)
void getPublications(NodeArgs &na)
void getMasterUri(NodeArgs &na)
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.
virtual Contact query(const std::string &name, const std::string &category="") override
query the Node to obtain Contact information about a nested port associated with this Node.
void add(Contactable &contactable) override
add a contactable to this node.
Contact where()
where getter fot information about the port of the Node.
void interrupt()
interrupt delegates the call to the Node port interrupt.
void removeExternalNode(const std::string &name)
removeExternalNode erase the node from the container.
void addExternalNode(const std::string &name, Node &node)
addExternalNode adds a Node to this container.
std::string getActiveName()
getActiveName getter for the currently active node's name
void setActiveName(const std::string &name)
setActiveName setter for the currently active node
Information about a port connection or event.
@ PORTINFO_CONNECTION
Information about an incoming or outgoing connection.
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
A base class for objects that want information about port status changes.
A mini-server for network communication.
void setReader(PortReader &reader) override
Set an external reader for port data.
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.
void includeNodeInName(bool flag) override
Choose whether to prepend a node name (if one is available) to the port's name.
void releaseProperties(Property *prop) override
End access unstructured port properties.
void close() override
Stop port activity.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
Property * acquireProperties(bool readOnly) override
Access unstructured port properties.
A class for storing options and configuration information.
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
static Contact rosify(const Contact &contact)
static std::string fromRosName(const std::string &name)
static std::string toRosName(const std::string &name)
Possible ROS names are a subset of YARP names.
A single value (typically within a Bottle).
virtual Bottle * asList() const
Get list value.
Client for YARP name server.
static NameClient & getNameClient()
Get an instance of the name client.
#define yCError(component,...)
#define yCAssert(component, x)
#define yCDebug(component,...)
#define YARP_OS_LOG_COMPONENT(name, name_string)
std::string get_string(const std::string &key, bool *found=nullptr)
Read a string from an environment variable.
The components from which ports and connections are built.
An interface to the operating system, including Port based communication.
int getpid()
Portable wrapper for the getppid() function.