YARP
Yet Another Robot Platform
RosLookup.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
9 #include <yarp/os/Contact.h>
10 
11 #include <cstdio>
12 #include <string>
13 
14 class RosLookup
15 {
16 public:
17  bool valid;
18  std::string hostname;
19  int portnum;
20  std::string protocol;
21 
23  valid(false),
24  portnum(-1)
25  {}
26 
27  bool lookupCore(const std::string& name);
28 
29  bool lookupTopic(const std::string& name);
30 
31  std::string toString() const {
32  char buf[1000];
33  sprintf(buf,"/%s:%d/", hostname.c_str(), portnum);
34  return buf;
35  }
36 
37  yarp::os::Contact toContact(const char *carrier) {
38  return yarp::os::Contact(carrier,hostname.c_str(), portnum);
39  }
40 
43 };
RosLookup::lookupTopic
bool lookupTopic(const std::string &name)
Definition: RosLookup.cpp:76
RosLookup::RosLookup
RosLookup()
Definition: RosLookup.h:22
RosLookup
Definition: RosLookup.h:15
RosLookup::getRosCoreAddressFromEnv
static yarp::os::Contact getRosCoreAddressFromEnv()
Definition: RosLookup.cpp:121
RosLookup::portnum
int portnum
Definition: RosLookup.h:19
RosLookup::toString
std::string toString() const
Definition: RosLookup.h:31
RosLookup::getRosCoreAddress
static yarp::os::Contact getRosCoreAddress()
Definition: RosLookup.cpp:130
RosLookup::valid
bool valid
Definition: RosLookup.h:17
RosLookup::hostname
std::string hostname
Definition: RosLookup.h:18
RosLookup::lookupCore
bool lookupCore(const std::string &name)
Definition: RosLookup.cpp:39
RosLookup::protocol
std::string protocol
Definition: RosLookup.h:20
yarp::os::Contact
Represents how to reach a part of a YARP network.
Definition: Contact.h:39
RosLookup::toContact
yarp::os::Contact toContact(const char *carrier)
Definition: RosLookup.h:37
Contact.h