YARP
Yet Another Robot Platform
NameSpace.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
6 #ifndef YARP_OS_NAMESPACE_H
7 #define YARP_OS_NAMESPACE_H
8 
9 #include <yarp/os/Contact.h>
10 #include <yarp/os/NameStore.h>
11 #include <yarp/os/Network.h>
12 #include <yarp/os/Value.h>
13 
14 namespace yarp {
15 namespace os {
16 
23 {
24 public:
28  virtual ~NameSpace();
29 
34  virtual bool checkNetwork();
35 
44  virtual bool checkNetwork(double timeout);
45 
50  virtual Contact getNameServerContact() const = 0;
51 
56  virtual std::string getNameServerName() const;
57 
61  virtual Contact queryName(const std::string& name) = 0;
62 
66  virtual Contact registerName(const std::string& name) = 0;
67 
71  virtual Contact registerContact(const Contact& contact) = 0;
72 
76  virtual Contact unregisterName(const std::string& name) = 0;
77 
81  virtual Contact unregisterContact(const Contact& contact) = 0;
82 
93  virtual Contact registerAdvanced(const Contact& contact,
94  NameStore* store)
95  {
96  YARP_UNUSED(store);
97  return registerContact(contact);
98  }
99 
104  virtual Contact unregisterAdvanced(const std::string& name,
105  NameStore* store)
106  {
107  YARP_UNUSED(store);
108  return unregisterName(name);
109  }
110 
114  virtual bool setProperty(const std::string& name,
115  const std::string& key,
116  const Value& value) = 0;
117 
123  virtual Value *getProperty(const std::string& name,
124  const std::string& key) = 0;
125 
129  virtual bool connectPortToTopic(const Contact& src,
130  const Contact& dest,
131  const ContactStyle& style) = 0;
132 
136  virtual bool connectTopicToPort(const Contact& src,
137  const Contact& dest,
138  const ContactStyle& style) = 0;
139 
143  virtual bool disconnectPortFromTopic(const Contact& src,
144  const Contact& dest,
145  const ContactStyle& style) = 0;
146 
150  virtual bool disconnectTopicFromPort(const Contact& src,
151  const Contact& dest,
152  const ContactStyle& style) = 0;
153 
157  virtual bool connectPortToPortPersistently(const Contact& src,
158  const Contact& dest,
159  const ContactStyle& style) = 0;
160 
164  virtual bool disconnectPortToPortPersistently(const Contact& src,
165  const Contact& dest,
166  const ContactStyle& style) = 0;
167 
172  virtual bool localOnly() const = 0;
173 
177  virtual bool usesCentralServer() const = 0;
178 
183  virtual bool serverAllocatesPortNumbers() const = 0;
184 
190  virtual bool connectionHasNameOfEndpoints() const = 0;
191 
201  virtual Contact detectNameServer(bool useDetectedServer,
202  bool& scanNeeded,
203  bool& serverUsed) = 0;
204 
209  virtual bool writeToNameServer(PortWriter& cmd,
210  PortReader& reply,
211  const ContactStyle& style) = 0;
212 
213 };
214 
215 } // namespace os
216 } // namespace yarp
217 
218 #endif // YARP_OS_NAMESPACE_H
Preferences for how to communicate with a contact.
Definition: ContactStyle.h:24
Represents how to reach a part of a YARP network.
Definition: Contact.h:36
An abstract name space for ports.
Definition: NameSpace.h:23
virtual bool usesCentralServer() const =0
Check if a central server is involved in managing the NameSpace.
virtual Contact registerName(const std::string &name)=0
Record contact information to tie to a port name.
virtual Contact detectNameServer(bool useDetectedServer, bool &scanNeeded, bool &serverUsed)=0
Find a name server for this NameSpace, if applicable.
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:104
virtual Contact queryName(const std::string &name)=0
Map from port name to contact information.
virtual Contact getNameServerContact() const =0
Get an address for a name server that manages the name space, if available.
virtual bool serverAllocatesPortNumbers() const =0
Check if a central server is responsible for allocating port numbers, or if this should be left up to...
virtual bool disconnectTopicFromPort(const Contact &src, const Contact &dest, const ContactStyle &style)=0
Stop subscribing a port to a topic.
virtual bool localOnly() const =0
Check if the NameSpace is only valid for the current process ("local").
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 ~NameSpace()
Destructor.
virtual bool connectionHasNameOfEndpoints() const =0
When connections are made involving ports managed by this NameSpace do the ports involved end up know...
virtual Contact unregisterContact(const Contact &contact)=0
Disassociate contact information (should include a port name).
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:93
virtual bool connectTopicToPort(const Contact &src, const Contact &dest, const ContactStyle &style)=0
Subscribe a port to a topic.
virtual Contact unregisterName(const std::string &name)=0
Disassociate contact information from a port name.
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 Contact registerContact(const Contact &contact)=0
Record contact information (should include a port name).
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.
Definition: NameStore.h:20
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition: PortReader.h:25
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
Definition: PortWriter.h:24
A single value (typically within a Bottle).
Definition: Value.h:45
The main, catch-all namespace for YARP.
Definition: dirs.h:16
#define YARP_UNUSED(var)
Definition: api.h:162
#define YARP_os_API
Definition: api.h:18