YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
NameConfig.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_NAMECONFIG_H
8#define YARP_OS_IMPL_NAMECONFIG_H
9
10#include <yarp/os/Bottle.h>
11#include <yarp/os/Contact.h>
12
13namespace yarp::os::impl {
14
15#define YARP_CONFIG_FILENAME "yarp.conf"
16#define YARP_CONFIG_NAMESPACE_FILENAME "yarp_namespace.conf"
17
23{
24public:
25 static std::string expandFilename(const char* fname);
26
27 std::string getSafeString(const std::string& txt);
28
29 std::string getConfigFileName(const char* stem = nullptr,
30 const char* ns = nullptr);
31
32 std::string readConfig(const std::string& fileName);
33
34 bool writeConfig(const std::string& fileName, const std::string& text);
35
36 bool fromFile(const char* ns = nullptr);
37
38 bool toFile(bool clean = false);
39
40 void setAddress(const Contact& address);
41
42 static std::string getHostName(bool prefer_loopback = false,
43 const std::string& seed = "");
44
45 static std::string getIps();
46
47 static yarp::os::Bottle getIpsAsBottle();
48
49 static bool isLocalName(const std::string& name);
50
51 Contact getAddress();
52
53 std::string getMode()
54 {
55 return mode;
56 }
57
58 void setMode(const std::string& mode)
59 {
60 this->mode = mode;
61 }
62
63 std::string getNamespace(bool refresh = false);
64
65 yarp::os::Bottle getNamespaces(bool refresh = false);
66
67 void setNamespace(const std::string& ns);
68
69private:
70 Contact address;
72 yarp::os::Bottle spaces;
74
75 bool fromString(const std::string& txt);
76};
77
78} // namespace yarp::os::impl
79
80#endif // YARP_OS_IMPL_NAMECONFIG_H
A simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:64
A mini-server for performing network communication in the background.
Represents how to reach a part of a YARP network.
Definition Contact.h:33
Small helper class to help deal with legacy YARP configuration files.
Definition NameConfig.h:23
void setMode(const std::string &mode)
Definition NameConfig.h:58
The components from which ports and connections are built.
#define YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(x)
Suppress MSVC C4251 warning for the declaration.
Definition system.h:338
#define YARP_os_impl_API
Definition api.h:46