YARP
Yet Another Robot Platform
Contact.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_CONTACT_H
8 #define YARP_OS_CONTACT_H
9 
10 #include <yarp/conf/compiler.h>
11 #include <yarp/conf/system.h>
12 
13 #include <yarp/os/NestedContact.h>
14 
15 #include <string>
16 
17 namespace yarp {
18 namespace os {
19 class Searchable;
20 } // namespace os
21 } // namespace yarp
22 
23 
24 namespace yarp {
25 namespace os {
26 
36 {
37 public:
48  Contact(const std::string& name = std::string(),
49  const std::string& carrier = std::string(),
50  const std::string& hostname = std::string(),
51  int port = -1);
52 
59  Contact(const std::string& hostname,
60  int port);
61 
69  Contact(const std::string& carrier,
70  const std::string& hostname,
71  int port);
72 
78  Contact(const Contact& rhs);
79 
85  Contact(Contact&& rhs) noexcept;
86 
90  virtual ~Contact();
91 
98  Contact& operator=(const Contact& rhs);
99 
106  Contact& operator=(Contact&& rhs) noexcept;
107 
121  static Contact fromConfig(const Searchable& config);
122 
131  static Contact fromString(const std::string& txt);
132 
144  std::string getName() const;
145 
151  void setName(const std::string& name);
152 
161  std::string getRegName() const;
162 
173  std::string getHost() const;
174 
180  void setHost(const std::string& hostname);
181 
192  int getPort() const;
193 
194 
200  void setPort(int port);
201 
212  std::string getCarrier() const;
213 
219  void setCarrier(const std::string& carrier);
220 
230  const NestedContact& getNested() const;
231 
238  void setNestedContact(const yarp::os::NestedContact& nestedContact);
239 
248  bool hasTimeout() const;
249 
255  float getTimeout() const;
256 
262  void setTimeout(float timeout);
263 
276  void setSocket(const std::string& carrier,
277  const std::string& hostname,
278  int port);
279 
290  bool isValid() const;
291 
297  std::string toString() const;
298 
305  std::string toURI(bool includeCarrier = true) const;
306 
316  static std::string convertHostToIp(const char* name);
317 
320 #ifndef DOXYGEN_SHOULD_SKIP_THIS
321 private:
322  class Private;
323  Private* mPriv;
324 #endif // DOXYGEN_SHOULD_SKIP_THIS
325 };
326 
327 } // namespace os
328 } // namespace yarp
329 
330 #endif // YARP_OS_CONTACT_H
Represents how to reach a part of a YARP network.
Definition: Contact.h:36
A placeholder for rich contact information.
Definition: NestedContact.h:24
A base class for nested structures that can be searched.
Definition: Searchable.h:66
std::string toString(const T &value)
convert an arbitrary type to string.
bool isValid()
Check if time is valid (non-zero).
Definition: Time.cpp:314
The main, catch-all namespace for YARP.
Definition: dirs.h:16
#define YARP_os_API
Definition: api.h:18