YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
ResourceFinder.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_RESOURCEFINDER_H
8#define YARP_OS_RESOURCEFINDER_H
9
10#include <yarp/os/Bottle.h>
11#include <yarp/os/Property.h>
13#include <yarp/os/Searchable.h>
14#include <yarp/os/Value.h>
15
16#include <string>
17
18namespace yarp::os {
19
29{
30public:
32
34
35 virtual ~ResourceFinder();
36
37 const ResourceFinder& operator=(const ResourceFinder& alt);
38
50 bool configure(int argc, char* argv[], bool skipFirstArgument = true);
51
60 bool setDefaultContext(const std::string& contextName)
61 {
62 clearContext();
63 return addContext(contextName);
64 }
65
72 bool setDefault(const std::string& key, const std::string& val);
73
80 bool setDefault(const std::string& key, std::int32_t val);
81
88 bool setDefault(const std::string& key, yarp::conf::float64_t val);
89
95 bool setDefault(const std::string& key, const yarp::os::Value& val);
96
103 bool setDefaultConfigFile(const std::string& fname)
104 {
105 return setDefault("from", fname);
106 }
107
124 std::string findFile(const std::string& name);
125
133 std::string findFileByName(const std::string& name);
134
150 std::string findPath(const std::string& name);
151
166 yarp::os::Bottle findPaths(const std::string& name);
167
173 std::string findPath();
174
175
183 std::string getContext();
184
191 yarp::os::Bottle getContexts();
192
193 // Searchable interface
194 bool check(const std::string& key) const override;
195 Value& find(const std::string& key) const override;
196 Bottle& findGroup(const std::string& key) const override;
197 bool isNull() const override;
198 std::string toString() const override;
199
200
209 virtual ResourceFinder findNestedResourceFinder(const std::string& key);
210
211
212 bool isConfigured() const
213 {
214 return m_isConfiguredFlag;
215 }
216
225 static ResourceFinder& getResourceFinderSingleton();
226
227 using Searchable::check;
228 using Searchable::findGroup;
229
233 std::string getHomeContextPath();
234
238 std::string getHomeRobotPath();
239
240 yarp::os::Bottle findPaths(const std::string& name,
241 const ResourceFinderOptions& options);
242
243 std::string findPath(const std::string& name,
244 const ResourceFinderOptions& options);
245
246 std::string findFile(const std::string& name,
247 const ResourceFinderOptions& options);
248
249 std::string findFileByName(const std::string& name,
250 const ResourceFinderOptions& options);
251
252 bool readConfig(Property& config,
253 const std::string& key,
254 const ResourceFinderOptions& options);
255
256#ifndef YARP_NO_DEPRECATED // Since YARP 3.4
268 bool setVerbose(bool verbose = true);
269
280 bool setQuiet(bool quiet = true);
281#endif // YARP_NO_DEPRECATED
282
283private:
284 // this might be useful, but is not in spec
285 bool addContext(const std::string& appName);
286
287 // this might be useful, but is not in spec
288 bool clearContext();
289
290 bool m_owned;
291 bool m_nullConfig;
292 bool m_isConfiguredFlag;
293 yarp::os::Property m_configprop;
294
295#ifndef DOXYGEN_SHOULD_SKIP_THIS
296private:
297 class Private;
298 Private* mPriv;
299 ResourceFinder(Searchable& data, Private* altPriv);
300#endif // DOXYGEN_SHOULD_SKIP_THIS
301};
302
303} // namespace yarp::os
304
305#endif // YARP_OS_RESOURCEFINDER_H
std::string toString(const T &value)
convert an arbitrary type to string.
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.
A class for storing options and configuration information.
Definition Property.h:33
These options are loosely based on http://wiki.icub.org/wiki/YARP_ResourceFinder.
Helper class for finding config files and other external resources.
bool setDefaultContext(const std::string &contextName)
Sets the context for the current ResourceFinder object.
bool setDefaultConfigFile(const std::string &fname)
Provide a default value for the configuration file (can be overridden from command line with the –fro...
A base class for nested structures that can be searched.
Definition Searchable.h:31
A single value (typically within a Bottle).
Definition Value.h:43
double float64_t
Definition numeric.h:77
An interface to the operating system, including Port based communication.
#define YARP_os_API
Definition api.h:18