YARP
Yet Another Robot Platform
Contact.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_CONTACT_H
11 #define YARP_OS_CONTACT_H
12 
13 #include <yarp/conf/compiler.h>
14 #include <yarp/conf/system.h>
15 
16 #include <yarp/os/NestedContact.h>
17 
18 #include <string>
19 
20 namespace yarp {
21 namespace os {
22 class Searchable;
23 } // namespace os
24 } // namespace yarp
25 
26 
27 namespace yarp {
28 namespace os {
29 
39 {
40 public:
51  Contact(const std::string& name = std::string(),
52  const std::string& carrier = std::string(),
53  const std::string& hostname = std::string(),
54  int port = -1);
55 
62  Contact(const std::string& hostname,
63  int port);
64 
72  Contact(const std::string& carrier,
73  const std::string& hostname,
74  int port);
75 
81  Contact(const Contact& rhs);
82 
88  Contact(Contact&& rhs) noexcept;
89 
93  virtual ~Contact();
94 
101  Contact& operator=(const Contact& rhs);
102 
109  Contact& operator=(Contact&& rhs) noexcept;
110 
124  static Contact fromConfig(const Searchable& config);
125 
134  static Contact fromString(const std::string& txt);
135 
147  std::string getName() const;
148 
154  void setName(const std::string& name);
155 
164  std::string getRegName() const;
165 
176  std::string getHost() const;
177 
183  void setHost(const std::string& hostname);
184 
195  int getPort() const;
196 
197 
203  void setPort(int port);
204 
215  std::string getCarrier() const;
216 
222  void setCarrier(const std::string& carrier);
223 
233  const NestedContact& getNested() const;
234 
241  void setNestedContact(const yarp::os::NestedContact& nestedContact);
242 
251  bool hasTimeout() const;
252 
258  float getTimeout() const;
259 
265  void setTimeout(float timeout);
266 
279  void setSocket(const std::string& carrier,
280  const std::string& hostname,
281  int port);
282 
293  bool isValid() const;
294 
300  std::string toString() const;
301 
308  std::string toURI(bool includeCarrier = true) const;
309 
319  static std::string convertHostToIp(const char* name);
320 
323 #ifndef DOXYGEN_SHOULD_SKIP_THIS
324 private:
325  class Private;
326  Private* mPriv;
327 #endif // DOXYGEN_SHOULD_SKIP_THIS
328 };
329 
330 } // namespace os
331 } // namespace yarp
332 
333 #endif // YARP_OS_CONTACT_H
yarp::os::Searchable
A base class for nested structures that can be searched.
Definition: Searchable.h:69
yarp::os::NestedContact
A placeholder for rich contact information.
Definition: NestedContact.h:27
yarp::os::Time::isValid
bool isValid()
Check if time is valid (non-zero).
Definition: Time.cpp:317
YARP_os_API
#define YARP_os_API
Definition: api.h:19
NestedContact.h
compiler.h
system.h
toString
std::string toString(const T &value)
convert an arbitrary type to string.
Definition: fakeMotionControl.cpp:121
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::os::Contact
Represents how to reach a part of a YARP network.
Definition: Contact.h:39