YARP
Yet Another Robot Platform
NameClient.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
10 #ifndef YARP_OS_IMPL_NAMECLIENT_H
11 #define YARP_OS_IMPL_NAMECLIENT_H
12 
13 #include <yarp/os/Contact.h>
14 #include <yarp/os/ContactStyle.h>
15 #include <yarp/os/Nodes.h>
16 
17 namespace yarp {
18 namespace os {
19 
20 class Bottle;
21 class NameStore;
22 
23 namespace impl {
24 
25 class NameServer;
26 
35 {
36 private:
37  NameClient();
38  NameClient(const NameClient& nic);
39 
40 public:
44  virtual ~NameClient();
45 
53  static NameClient& getNameClient();
54 
55  static NameClient* create();
56 
61  Contact getAddress();
62 
68  Contact queryName(const std::string& name);
69 
75  Contact registerName(const std::string& name);
76 
83  Contact registerName(const std::string& name, const Contact& suggest);
84 
90  Contact unregisterName(const std::string& name);
91 
101  Contact probe(const std::string& cmd);
102 
110  static Contact extractAddress(const std::string& txt);
111 
112  static Contact extractAddress(const Bottle& bot);
113 
122  std::string send(const std::string& cmd, bool multi = true, const ContactStyle& style = ContactStyle());
123 
133  bool send(yarp::os::Bottle& cmd, yarp::os::Bottle& reply);
134 
141  void setFakeMode(bool fake = true);
142 
148  bool isFakeMode() const;
149 
156  void setScan(bool allow = true);
157 
164  void setSave(bool allow = true);
165 
172  bool didScan();
173 
180  bool didSave();
181 
188  bool updateAddress();
189 
190  bool setContact(const yarp::os::Contact& contact);
191 
192  void queryBypass(NameStore* store);
193 
194  NameStore* getQueryBypass();
195 
196  std::string getMode();
197 
198  yarp::os::Nodes& getNodes();
199 
200 private:
201  Contact address;
202  YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(std::string) host;
203  YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(std::string) mode;
204  bool fake;
205  NameServer* fakeServer;
206  bool allowScan;
207  bool allowSaveScan;
208  bool reportScan;
209  bool reportSaveScan;
210  bool isSetup;
211  NameStore* altStore;
212  yarp::os::Nodes nodes;
213 
214  NameServer& getServer();
215  void setup();
216 };
217 
218 } // namespace impl
219 } // namespace os
220 } // namespace yarp
221 
222 #endif // YARP_OS_IMPL_NAMECLIENT_H
yarp::os::Bottle
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:73
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
ContactStyle.h
YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG
#define YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(x)
Suppress MSVC C4251 warning for the declaration.
Definition: system.h:339
yarp::os::impl::NameServer
Implementation of a YARP2-conforming name server.
Definition: NameServer.h:46
yarp::os::Nodes
The Nodes class.
Definition: Nodes.h:35
Nodes.h
yarp::os::impl::NameClient
Client for YARP name server.
Definition: NameClient.h:35
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
YARP_os_impl_API
#define YARP_os_impl_API
Definition: api.h:45
yarp::os::Contact
Represents how to reach a part of a YARP network.
Definition: Contact.h:39
Contact.h