|
YARP
Yet Another Robot Platform
|
|
Go to the documentation of this file.
53 for (
auto ns : spaces) {
61 _usesCentralServer =
false;
62 _serverAllocatesPortNumbers =
false;
63 _connectionHasNameOfEndpoints =
true;
70 _usesCentralServer =
false;
71 _serverAllocatesPortNumbers =
true;
73 for (
auto ns : spaces) {
78 if (!ns->localOnly()) {
82 if (ns->usesCentralServer()) {
83 _usesCentralServer =
true;
87 if (!ns->serverAllocatesPortNumbers()) {
88 _serverAllocatesPortNumbers =
false;
92 if (!ns->connectionHasNameOfEndpoints()) {
93 _connectionHasNameOfEndpoints =
false;
105 spaces.push_back(ns);
119 if (!spaces.empty()) {
126 static double last_shown =
now - 10;
127 if (
now - last_shown > 3) {
129 yCWarning(MULTINAMESPACE,
"YARP name server(s) not configured, ports will be anonymous\n");
130 yCWarning(MULTINAMESPACE,
"check your namespace and settings with 'yarp detect'\n");
136 for (
size_t i = 0; i < ns.
size(); i++) {
141 yCWarning(MULTINAMESPACE,
"Could not find namespace %s\n", n.c_str());
144 std::string mode = conf2.
getMode();
147 if (mode ==
"yarp" || mode ==
"//") {
150 spaces.push_back(ns);
151 }
else if (mode ==
"ros") {
154 spaces.push_back(ns);
155 }
else if (mode ==
"local") {
157 spaces.push_back(ns);
160 yCError(MULTINAMESPACE,
"cannot deal with namespace of type %s", mode.c_str());
172 if (!spaces.empty()) {
174 return spaces[0]->getNameServerContact();
183 for (
auto ns : spaces) {
187 if (ns->getNameServerName() == name) {
190 return ns->getNameServerContact();
192 Contact result = ns->queryName(name);
206 if (spaces.empty()) {
220 #define HELPER(x) (*((MultiNameSpaceHelper*)((x)->system_resource)))
226 yCAssert(MULTINAMESPACE, system_resource !=
nullptr);
231 if (system_resource !=
nullptr) {
233 system_resource =
nullptr;
239 return HELPER(
this).setLocalMode(flag);
245 return HELPER(
this)._localOnly;
251 return HELPER(
this)._usesCentralServer;
257 return HELPER(
this)._connectionHasNameOfEndpoints;
273 return HELPER(
this)._serverAllocatesPortNumbers;
278 return HELPER(
this).activate(force);
288 return HELPER(
this).queryName(name);
362 for (
size_t i = 0; i < lst.size(); i++) {
368 iresult = lst[i]->registerName(name);
370 iresult = lst[i]->registerContact(result);
372 if (i == 0 || result.
getPort() <= 0) {
383 for (
size_t i = 0; i < lst.size(); i++) {
385 Contact iresult = lst[i]->registerContact(contact);
397 for (
size_t i = 0; i < lst.size(); i++) {
399 Contact iresult = lst[i]->unregisterName(name);
411 for (
size_t i = 0; i < lst.size(); i++) {
413 Contact iresult = lst[i]->unregisterContact(contact);
451 if (name.find(
"/ros") != std::string::npos) {
454 if (r.
isValid() && useDetectedServer && scanNeeded) {
455 HELPER(
this).activate(
true);
460 if (r.
isValid() && useDetectedServer && scanNeeded) {
461 HELPER(
this).activate(
true);
bool _connectionHasNameOfEndpoints
bool localOnly() const override
Check if the NameSpace is only valid for the current process ("local").
A simple collection of objects that can be described and transmitted in a portable way.
virtual bool writeToNameServer(PortWriter &cmd, PortReader &reply, const ContactStyle &style) override
Write a message to a name server for this NameSpace, if applicable.
size_type size() const
Gets the number of elements in the bottle.
virtual void queryBypass(NameStore *store)
Set an alternative place to make name queries.
bool usesCentralServer() const override
Check if a central server is involved in managing the NameSpace.
Abstract interface for a database of port names.
virtual bool disconnectPortToPortPersistently(const Contact &src, const Contact &dest, const ContactStyle &style) override
Disconnect two ports, removing any persistence.
#define yCWarning(component,...)
virtual bool disconnectTopicFromPort(const Contact &src, const Contact &dest, const ContactStyle &style) override
Stop subscribing a port to a topic.
Contact queryName(const std::string &name) override
Map from port name to contact information.
virtual bool writeToNameServer(PortWriter &cmd, PortReader &reply, const ContactStyle &style)=0
Write a message to a name server for this NameSpace, if applicable.
Contact registerContact(const Contact &contact) override
Record contact information (should include a port name).
virtual NameStore * getQueryBypass()
Get any alternative place to make name queries, if one was set by queryBypass()
virtual bool connectPortToTopic(const Contact &src, const Contact &dest, const ContactStyle &style) override
Publish a port to a topic.
virtual bool connectPortToPortPersistently(const Contact &src, const Contact &dest, const ContactStyle &style) override
Connect two ports with persistence.
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
virtual bool setProperty(const std::string &name, const std::string &key, const Value &value)=0
Associate a key/value pair with a named port.
bool _serverAllocatesPortNumbers
virtual Contact detectNameServer(bool useDetectedServer, bool &scanNeeded, bool &serverUsed) override
Find a name server for this NameSpace, if applicable.
double now()
Return the current time in seconds, relative to an arbitrary starting point.
static double nowSystem()
Contact unregisterName(const std::string &name) override
Disassociate contact information from a port name.
Contact registerName(const std::string &name) override
Record contact information to tie to a port name.
virtual Contact detectNameServer(bool useDetectedServer, bool &scanNeeded, bool &serverUsed) override
Find a name server for this NameSpace, if applicable.
virtual bool disconnectPortToPortPersistently(const Contact &src, const Contact &dest, const ContactStyle &style)=0
Disconnect two ports, removing any persistence.
bool setLocalMode(bool flag)
Value * getProperty(const std::string &name, const std::string &key) override
Get the value of a named key from a named port.
virtual bool disconnectPortFromTopic(const Contact &src, const Contact &dest, const ContactStyle &style)=0
Stop publishing a port to a topic.
bool setLocalMode(bool flag)
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
virtual bool setProperty(const std::string &name, const std::string &key, const Value &value) override
Associate a key/value pair with a named port.
virtual bool disconnectTopicFromPort(const Contact &src, const Contact &dest, const ContactStyle &style)=0
Stop subscribing a port to a topic.
virtual std::string asString() const
Get string value.
virtual Value * getProperty(const std::string &name, const std::string &key)=0
Get the value of a named key from a named port.
bool activate(bool force=false)
virtual bool connectPortToTopic(const Contact &src, const Contact &dest, const ContactStyle &style)=0
Publish a port to a topic.
std::vector< NameSpace * > SpaceList
An abstract name space for ports.
#define yCAssert(component, x)
Contact unregisterContact(const Contact &contact) override
Disassociate contact information (should include a port name).
#define yCError(component,...)
yarp::os::Bottle getNamespaces(bool refresh=false)
bool connectionHasNameOfEndpoints() const override
When connections are made involving ports managed by this NameSpace do the ports involved end up know...
bool serverAllocatesPortNumbers() const override
Check if a central server is responsible for allocating port numbers, or if this should be left up to...
An interface to the operating system, including Port based communication.
virtual bool disconnectPortFromTopic(const Contact &src, const Contact &dest, const ContactStyle &style) override
Stop publishing a port to a topic.
bool activate(bool force=false)
virtual bool connectPortToPortPersistently(const Contact &src, const Contact &dest, const ContactStyle &style)=0
Connect two ports with persistence.
Contact queryName(const std::string &name)
static std::string getNameServerName()
Get the name of the port associated with the nameserver (usually "/root", but this can be overwritten...
bool fromFile(const char *ns=nullptr)
virtual Contact detectNameServer(bool useDetectedServer, bool &scanNeeded, bool &serverUsed) override
Find a name server for this NameSpace, if applicable.
A single value (typically within a Bottle).
Small helper class to help deal with legacy YARP configuration files.
#define YARP_OS_LOG_COMPONENT(name, name_string)
The components from which ports and connections are built.
virtual ~MultiNameSpace()
virtual bool connectTopicToPort(const Contact &src, const Contact &dest, const ContactStyle &style)=0
Subscribe a port to a topic.
Contact getNameServerContact()
virtual bool connectTopicToPort(const Contact &src, const Contact &dest, const ContactStyle &style) override
Subscribe a port to a topic.
Contact getNameServerContact() const override
Get an address for a name server that manages the name space, if available.