YARP
Yet Another Robot Platform
NameClient.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef YARP_OS_IMPL_NAMECLIENT_H
8 #define YARP_OS_IMPL_NAMECLIENT_H
9 
10 #include <yarp/os/Contact.h>
11 #include <yarp/os/ContactStyle.h>
12 #include <yarp/os/Nodes.h>
13 
14 namespace yarp {
15 namespace os {
16 
17 class Bottle;
18 class NameStore;
19 
20 namespace impl {
21 
22 class NameServer;
23 
32 {
33 private:
34  NameClient();
35  NameClient(const NameClient& nic);
36 
37 public:
41  virtual ~NameClient();
42 
50  static NameClient& getNameClient();
51 
52  static NameClient* create();
53 
58  Contact getAddress();
59 
65  Contact queryName(const std::string& name);
66 
72  Contact registerName(const std::string& name);
73 
80  Contact registerName(const std::string& name, const Contact& suggest);
81 
87  Contact unregisterName(const std::string& name);
88 
98  Contact probe(const std::string& cmd);
99 
107  static Contact extractAddress(const std::string& txt);
108 
109  static Contact extractAddress(const Bottle& bot);
110 
119  std::string send(const std::string& cmd, bool multi = true, const ContactStyle& style = ContactStyle());
120 
130  bool send(yarp::os::Bottle& cmd, yarp::os::Bottle& reply);
131 
138  void setFakeMode(bool fake = true);
139 
145  bool isFakeMode() const;
146 
153  void setScan(bool allow = true);
154 
161  void setSave(bool allow = true);
162 
169  bool didScan();
170 
177  bool didSave();
178 
185  bool updateAddress();
186 
187  bool setContact(const yarp::os::Contact& contact);
188 
189  void queryBypass(NameStore* store);
190 
191  NameStore* getQueryBypass();
192 
193  std::string getMode();
194 
195  yarp::os::Nodes& getNodes();
196 
197 private:
198  Contact address;
199  YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(std::string) host;
200  YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(std::string) mode;
201  bool fake;
202  NameServer* fakeServer;
203  bool allowScan;
204  bool allowSaveScan;
205  bool reportScan;
206  bool reportSaveScan;
207  bool isSetup;
208  NameStore* altStore;
209  yarp::os::Nodes nodes;
210 
211  NameServer& getServer();
212  void setup();
213 };
214 
215 } // namespace impl
216 } // namespace os
217 } // namespace yarp
218 
219 #endif // YARP_OS_IMPL_NAMECLIENT_H
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:74
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
Abstract interface for a database of port names.
Definition: NameStore.h:20
The Nodes class.
Definition: Nodes.h:32
Client for YARP name server.
Definition: NameClient.h:32
Implementation of a YARP2-conforming name server.
Definition: NameServer.h:45
The main, catch-all namespace for YARP.
Definition: dirs.h:16
#define YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(x)
Suppress MSVC C4251 warning for the declaration.
Definition: system.h:336
#define YARP_os_impl_API
Definition: api.h:46