YARP
Yet Another Robot Platform
NameSpace.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
9 #ifndef YARP_OS_NAMESPACE_H
10 #define YARP_OS_NAMESPACE_H
11 
12 #include <yarp/os/Contact.h>
13 #include <yarp/os/NameStore.h>
14 #include <yarp/os/Network.h>
15 #include <yarp/os/Value.h>
16 
17 namespace yarp {
18 namespace os {
19 
26 {
27 public:
31  virtual ~NameSpace();
32 
37  virtual bool checkNetwork();
38 
47  virtual bool checkNetwork(double timeout);
48 
53  virtual Contact getNameServerContact() const = 0;
54 
59  virtual std::string getNameServerName() const;
60 
64  virtual Contact queryName(const std::string& name) = 0;
65 
69  virtual Contact registerName(const std::string& name) = 0;
70 
74  virtual Contact registerContact(const Contact& contact) = 0;
75 
79  virtual Contact unregisterName(const std::string& name) = 0;
80 
84  virtual Contact unregisterContact(const Contact& contact) = 0;
85 
96  virtual Contact registerAdvanced(const Contact& contact,
97  NameStore* store)
98  {
99  YARP_UNUSED(store);
100  return registerContact(contact);
101  }
102 
107  virtual Contact unregisterAdvanced(const std::string& name,
108  NameStore* store)
109  {
110  YARP_UNUSED(store);
111  return unregisterName(name);
112  }
113 
117  virtual bool setProperty(const std::string& name,
118  const std::string& key,
119  const Value& value) = 0;
120 
126  virtual Value *getProperty(const std::string& name,
127  const std::string& key) = 0;
128 
132  virtual bool connectPortToTopic(const Contact& src,
133  const Contact& dest,
134  const ContactStyle& style) = 0;
135 
139  virtual bool connectTopicToPort(const Contact& src,
140  const Contact& dest,
141  const ContactStyle& style) = 0;
142 
146  virtual bool disconnectPortFromTopic(const Contact& src,
147  const Contact& dest,
148  const ContactStyle& style) = 0;
149 
153  virtual bool disconnectTopicFromPort(const Contact& src,
154  const Contact& dest,
155  const ContactStyle& style) = 0;
156 
160  virtual bool connectPortToPortPersistently(const Contact& src,
161  const Contact& dest,
162  const ContactStyle& style) = 0;
163 
167  virtual bool disconnectPortToPortPersistently(const Contact& src,
168  const Contact& dest,
169  const ContactStyle& style) = 0;
170 
175  virtual bool localOnly() const = 0;
176 
180  virtual bool usesCentralServer() const = 0;
181 
186  virtual bool serverAllocatesPortNumbers() const = 0;
187 
193  virtual bool connectionHasNameOfEndpoints() const = 0;
194 
204  virtual Contact detectNameServer(bool useDetectedServer,
205  bool& scanNeeded,
206  bool& serverUsed) = 0;
207 
212  virtual bool writeToNameServer(PortWriter& cmd,
213  PortReader& reply,
214  const ContactStyle& style) = 0;
215 
216 };
217 
218 } // namespace os
219 } // namespace yarp
220 
221 #endif // YARP_OS_NAMESPACE_H
yarp::os::NameSpace::~NameSpace
virtual ~NameSpace()
Destructor.
Network.h
yarp::os::ContactStyle
Preferences for how to communicate with a contact.
Definition: ContactStyle.h:27
yarp::os::NameStore
Abstract interface for a database of port names.
Definition: NameStore.h:23
yarp::os::NameSpace::connectionHasNameOfEndpoints
virtual bool connectionHasNameOfEndpoints() const =0
When connections are made involving ports managed by this NameSpace do the ports involved end up know...
yarp::os::NameSpace::writeToNameServer
virtual bool writeToNameServer(PortWriter &cmd, PortReader &reply, const ContactStyle &style)=0
Write a message to a name server for this NameSpace, if applicable.
yarp::os::NameSpace::queryName
virtual Contact queryName(const std::string &name)=0
Map from port name to contact information.
YARP_os_API
#define YARP_os_API
Definition: api.h:19
YARP_UNUSED
#define YARP_UNUSED(var)
Definition: api.h:159
yarp::os::PortWriter
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
Definition: PortWriter.h:27
yarp::os::NameSpace::registerContact
virtual Contact registerContact(const Contact &contact)=0
Record contact information (should include a port name).
yarp::os::NameSpace::setProperty
virtual bool setProperty(const std::string &name, const std::string &key, const Value &value)=0
Associate a key/value pair with a named port.
yarp::os::NameSpace::unregisterAdvanced
virtual Contact unregisterAdvanced(const std::string &name, NameStore *store)
Remove contact information, with access to the contact information of other ports for cross-referenci...
Definition: NameSpace.h:107
yarp::os::NameSpace::getNameServerContact
virtual Contact getNameServerContact() const =0
Get an address for a name server that manages the name space, if available.
yarp::os::NameSpace::disconnectPortToPortPersistently
virtual bool disconnectPortToPortPersistently(const Contact &src, const Contact &dest, const ContactStyle &style)=0
Disconnect two ports, removing any persistence.
yarp::os::NameSpace::detectNameServer
virtual Contact detectNameServer(bool useDetectedServer, bool &scanNeeded, bool &serverUsed)=0
Find a name server for this NameSpace, if applicable.
yarp::os::NameSpace::disconnectPortFromTopic
virtual bool disconnectPortFromTopic(const Contact &src, const Contact &dest, const ContactStyle &style)=0
Stop publishing a port to a topic.
yarp::os::PortReader
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition: PortReader.h:28
yarp::os::NameSpace::serverAllocatesPortNumbers
virtual bool serverAllocatesPortNumbers() const =0
Check if a central server is responsible for allocating port numbers, or if this should be left up to...
yarp::os::NameSpace::disconnectTopicFromPort
virtual bool disconnectTopicFromPort(const Contact &src, const Contact &dest, const ContactStyle &style)=0
Stop subscribing a port to a topic.
yarp::os::NameSpace::unregisterContact
virtual Contact unregisterContact(const Contact &contact)=0
Disassociate contact information (should include a port name).
yarp::os::NameSpace::getProperty
virtual Value * getProperty(const std::string &name, const std::string &key)=0
Get the value of a named key from a named port.
yarp::os::NameSpace::localOnly
virtual bool localOnly() const =0
Check if the NameSpace is only valid for the current process ("local").
yarp::os::NameSpace::connectPortToTopic
virtual bool connectPortToTopic(const Contact &src, const Contact &dest, const ContactStyle &style)=0
Publish a port to a topic.
yarp::os::NameSpace
An abstract name space for ports.
Definition: NameSpace.h:26
yarp::os::NameSpace::registerAdvanced
virtual Contact registerAdvanced(const Contact &contact, NameStore *store)
Record contact information, with access to the contact information of other ports for cross-referenci...
Definition: NameSpace.h:96
yarp::os::NameSpace::unregisterName
virtual Contact unregisterName(const std::string &name)=0
Disassociate contact information from a port name.
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::os::NameSpace::connectPortToPortPersistently
virtual bool connectPortToPortPersistently(const Contact &src, const Contact &dest, const ContactStyle &style)=0
Connect two ports with persistence.
yarp::os::Contact
Represents how to reach a part of a YARP network.
Definition: Contact.h:39
yarp::os::Value
A single value (typically within a Bottle).
Definition: Value.h:47
Contact.h
NameStore.h
yarp::os::NameSpace::registerName
virtual Contact registerName(const std::string &name)=0
Record contact information to tie to a port name.
yarp::os::NameSpace::usesCentralServer
virtual bool usesCentralServer() const =0
Check if a central server is involved in managing the NameSpace.
Value.h
yarp::os::NameSpace::connectTopicToPort
virtual bool connectTopicToPort(const Contact &src, const Contact &dest, const ContactStyle &style)=0
Subscribe a port to a topic.