YARP
Yet Another Robot Platform
Searchable.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_SEARCHABLE_H
8#define YARP_OS_SEARCHABLE_H
9
10#include <yarp/os/api.h>
11
12#include <cstddef>
13#include <string>
14
15namespace yarp::os {
16class Value;
17class Bottle;
18} // namespace yarp::os
19
20namespace yarp::os {
21
22#ifndef DOXYGEN_SHOULD_SKIP_THIS
23
24class YARP_os_API SearchReport
25{
26public:
29 bool isFound;
30 bool isGroup;
31 bool isComment;
32 bool isDefault;
33
34 explicit SearchReport();
35};
36
37class YARP_os_API SearchMonitor
38{
39public:
40 virtual ~SearchMonitor();
41 virtual void report(const SearchReport& report, const char* context) = 0;
42};
43
44#endif /* DOXYGEN_SHOULD_SKIP_THIS */
45
46
56{
57private:
58 SearchMonitor* monitor;
59 YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(std::string) monitorContext;
60
61public:
65 explicit Searchable();
66
70 Searchable(const Searchable& rhs) = default;
71
75 Searchable(Searchable&& rhs) noexcept = default;
76
80 virtual ~Searchable();
81
85 Searchable& operator=(const Searchable& rhs) = default;
86
90 Searchable& operator=(Searchable&& rhs) noexcept = default;
91
98 virtual bool check(const std::string& key) const = 0;
99
100
108 virtual bool check(const std::string& key,
109 const std::string& comment) const;
110
119 virtual Value& find(const std::string& key) const = 0;
120
131 virtual Bottle& findGroup(const std::string& key) const = 0;
132
144 Bottle& findGroup(const std::string& key, const std::string& comment) const;
145
171 virtual bool check(const std::string& key,
172 Value*& result,
173 const std::string& comment = "") const;
174
175
185 virtual Value check(const std::string& key,
186 const Value& fallback,
187 const std::string& comment = "") const;
188
193 virtual bool isNull() const;
194
202 virtual std::string toString() const = 0;
203
204#ifndef DOXYGEN_SHOULD_SKIP_THIS
205 virtual void setMonitor(SearchMonitor* monitor, const char* context = "");
206 virtual SearchMonitor* getMonitor() const;
207 virtual std::string getMonitorContext() const;
208 virtual void reportToMonitor(const SearchReport& report) const;
209#endif /* DOXYGEN_SHOULD_SKIP_THIS */
210};
211
212} // namespace yarp::os
213
214#endif // YARP_OS_SEARCHABLE_H
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:64
A base class for nested structures that can be searched.
Definition: Searchable.h:56
Searchable(const Searchable &rhs)=default
Copy constructor.
Searchable(Searchable &&rhs) noexcept=default
Move constructor.
Searchable & operator=(Searchable &&rhs) noexcept=default
Move assignment operator.
virtual ~Searchable()
Destructor.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
virtual std::string toString() const =0
Return a standard text representation of the content of the object.
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
Searchable & operator=(const Searchable &rhs)=default
Copy assignment operator.
virtual Bottle & findGroup(const std::string &key) const =0
Gets a list corresponding to a given keyword.
A single value (typically within a Bottle).
Definition: Value.h:43
An interface to the operating system, including Port based communication.
std::string findGroup(const robotinterface::ParamList &list, const std::string &name)
Definition: Types.cpp:47
#define YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(x)
Suppress MSVC C4251 warning for the declaration.
Definition: system.h:338
#define YARP_os_API
Definition: api.h:18