75 if (!ns->localOnly()) {
79 if (ns->usesCentralServer()) {
84 if (!ns->serverAllocatesPortNumbers()) {
89 if (!ns->connectionHasNameOfEndpoints()) {
133 for (
size_t i = 0;
i < ns.
size();
i++) {
137 if (!
conf2.fromFile(
n.c_str())) {
141 std::string mode =
conf2.getMode();
144 if (mode ==
"yarp" || mode ==
"//") {
148 }
else if (mode ==
"ros") {
152 }
else if (mode ==
"local") {
171 return spaces[0]->getNameServerContact();
184 if (ns->getNameServerName() == name) {
187 return ns->getNameServerContact();
189 Contact result = ns->queryName(name);
217#define HELPER(x) (*((MultiNameSpaceHelper*)((x)->system_resource)))
228 if (system_resource !=
nullptr) {
230 system_resource =
nullptr;
242 return HELPER(
this)._localOnly;
248 return HELPER(
this)._usesCentralServer;
254 return HELPER(
this)._connectionHasNameOfEndpoints;
270 return HELPER(
this)._serverAllocatesPortNumbers;
285 return HELPER(
this).queryName(name);
359 for (
size_t i = 0;
i < lst.size();
i++) {
365 iresult = lst[
i]->registerName(name);
367 iresult = lst[
i]->registerContact(result);
369 if (
i == 0 || result.
getPort() <= 0) {
380 for (
size_t i = 0;
i < lst.size();
i++) {
394 for (
size_t i = 0;
i < lst.size();
i++) {
408 for (
size_t i = 0;
i < lst.size();
i++) {
448 if (name.find(
"/ros") != std::string::npos) {
452 HELPER(
this).activate(
true);
458 HELPER(
this).activate(
true);
std::vector< NameSpace * > SpaceList
bool setLocalMode(bool flag)
bool _serverAllocatesPortNumbers
Contact getNameServerContact()
Contact queryName(const std::string &name)
bool _connectionHasNameOfEndpoints
bool activate(bool force=false)
A simple collection of objects that can be described and transmitted in a portable way.
size_type size() const
Gets the number of elements in the bottle.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
A mini-server for performing network communication in the background.
Contact getNameServerContact() const override
Get an address for a name server that manages the name space, if available.
Contact registerName(const std::string &name) override
Record contact information to tie to a port name.
virtual ~MultiNameSpace()
virtual bool connectPortToTopic(const Contact &src, const Contact &dest, const ContactStyle &style) override
Publish a port to a topic.
virtual NameStore * getQueryBypass()
Get any alternative place to make name queries, if one was set by queryBypass()
virtual bool connectTopicToPort(const Contact &src, const Contact &dest, const ContactStyle &style) override
Subscribe a port to a topic.
virtual bool connectPortToPortPersistently(const Contact &src, const Contact &dest, const ContactStyle &style) override
Connect two ports with persistence.
Value * getProperty(const std::string &name, const std::string &key) override
Get the value of a named key from a named port.
virtual bool disconnectTopicFromPort(const Contact &src, const Contact &dest, const ContactStyle &style) override
Stop subscribing a port to a topic.
virtual bool disconnectPortToPortPersistently(const Contact &src, const Contact &dest, const ContactStyle &style) override
Disconnect two ports, removing any persistence.
virtual void queryBypass(NameStore *store)
Set an alternative place to make name queries.
bool connectionHasNameOfEndpoints() const override
When connections are made involving ports managed by this NameSpace do the ports involved end up know...
Contact queryName(const std::string &name) override
Map from port name to contact information.
bool localOnly() const override
Check if the NameSpace is only valid for the current process ("local").
bool serverAllocatesPortNumbers() const override
Check if a central server is responsible for allocating port numbers, or if this should be left up to...
bool usesCentralServer() const override
Check if a central server is involved in managing the NameSpace.
bool activate(bool force=false)
virtual bool disconnectPortFromTopic(const Contact &src, const Contact &dest, const ContactStyle &style) override
Stop publishing a port to a topic.
Contact unregisterName(const std::string &name) override
Disassociate contact information from a port name.
Contact registerContact(const Contact &contact) override
Record contact information (should include a port name).
Contact unregisterContact(const Contact &contact) override
Disassociate contact information (should include a port name).
virtual bool setProperty(const std::string &name, const std::string &key, const Value &value) override
Associate a key/value pair with a named port.
bool setLocalMode(bool flag)
virtual Contact detectNameServer(bool useDetectedServer, bool &scanNeeded, bool &serverUsed) override
Find a name server for this NameSpace, if applicable.
virtual bool writeToNameServer(PortWriter &cmd, PortReader &reply, const ContactStyle &style) override
Write a message to a name server for this NameSpace, if applicable.
An abstract name space for ports.
virtual bool disconnectTopicFromPort(const Contact &src, const Contact &dest, const ContactStyle &style)=0
Stop subscribing a port to a topic.
virtual bool disconnectPortFromTopic(const Contact &src, const Contact &dest, const ContactStyle &style)=0
Stop publishing a port to a topic.
virtual bool connectPortToPortPersistently(const Contact &src, const Contact &dest, const ContactStyle &style)=0
Connect two ports with persistence.
virtual bool connectTopicToPort(const Contact &src, const Contact &dest, const ContactStyle &style)=0
Subscribe a port to a topic.
virtual bool writeToNameServer(PortWriter &cmd, PortReader &reply, const ContactStyle &style)=0
Write a message to a name server for this NameSpace, if applicable.
virtual bool connectPortToTopic(const Contact &src, const Contact &dest, const ContactStyle &style)=0
Publish a port to a topic.
virtual bool setProperty(const std::string &name, const std::string &key, const Value &value)=0
Associate a key/value pair with a named port.
virtual Value * getProperty(const std::string &name, const std::string &key)=0
Get the value of a named key from a named port.
virtual bool disconnectPortToPortPersistently(const Contact &src, const Contact &dest, const ContactStyle &style)=0
Disconnect two ports, removing any persistence.
Abstract interface for a database of port names.
static std::string getNameServerName()
Get the name of the port associated with the nameserver (usually "/root", but this can be overwritten...
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
virtual Contact detectNameServer(bool useDetectedServer, bool &scanNeeded, bool &serverUsed) override
Find a name server for this NameSpace, if applicable.
static double nowSystem()
A single value (typically within a Bottle).
virtual std::string asString() const
Get string value.
virtual Contact detectNameServer(bool useDetectedServer, bool &scanNeeded, bool &serverUsed) override
Find a name server for this NameSpace, if applicable.
Small helper class to help deal with legacy YARP configuration files.
bool fromFile(const char *ns=nullptr)
yarp::os::Bottle getNamespaces(bool refresh=false)
#define yCError(component,...)
#define yCAssert(component, x)
#define yCWarning(component,...)
#define YARP_OS_LOG_COMPONENT(name, name_string)
The components from which ports and connections are built.
An interface to the operating system, including Port based communication.