YARP
Yet Another Robot Platform
Searchable.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
10 #ifndef YARP_OS_SEARCHABLE_H
11 #define YARP_OS_SEARCHABLE_H
12 
13 #include <yarp/os/api.h>
14 
15 #include <cstddef>
16 #include <string>
17 
18 #ifndef YARP_NO_DEPRECATED // Since YARP 3.0.0
19 #define YARP_INCLUDING_DEPRECATED_HEADER_ON_PURPOSE
20 # include <yarp/os/ConstString.h>
21 #undef YARP_INCLUDING_DEPRECATED_HEADER_ON_PURPOSE
22 #endif // YARP_NO_DEPRECATED
23 
24 
25 namespace yarp {
26 namespace os {
27 class Value;
28 class Bottle;
29 } // namespace os
30 } // namespace yarp
31 
32 namespace yarp {
33 namespace os {
34 
35 #ifndef DOXYGEN_SHOULD_SKIP_THIS
36 
37 class YARP_os_API SearchReport
38 {
39 public:
41  YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(std::string) value;
42  bool isFound;
43  bool isGroup;
44  bool isComment;
45  bool isDefault;
46 
47  explicit SearchReport();
48 };
49 
50 class YARP_os_API SearchMonitor
51 {
52 public:
53  virtual ~SearchMonitor();
54  virtual void report(const SearchReport& report, const char* context) = 0;
55 };
56 
57 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
58 
59 
69 {
70 private:
71  SearchMonitor* monitor;
72  YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(std::string) monitorContext;
73 
74 public:
78  explicit Searchable();
79 
83  Searchable(const Searchable& rhs) = default;
84 
88  Searchable(Searchable&& rhs) noexcept = default;
89 
93  virtual ~Searchable();
94 
98  Searchable& operator=(const Searchable& rhs) = default;
99 
103  Searchable& operator=(Searchable&& rhs) noexcept = default;
104 
111  virtual bool check(const std::string& key) const = 0;
112 
113 
121  virtual bool check(const std::string& key,
122  const std::string& comment) const;
123 
132  virtual Value& find(const std::string& key) const = 0;
133 
144  virtual Bottle& findGroup(const std::string& key) const = 0;
145 
157  Bottle& findGroup(const std::string& key, const std::string& comment) const;
158 
184  virtual bool check(const std::string& key,
185  Value*& result,
186  const std::string& comment = "") const;
187 
188 
198  virtual Value check(const std::string& key,
199  const Value& fallback,
200  const std::string& comment = "") const;
201 
206  virtual bool isNull() const;
207 
215  virtual std::string toString() const = 0;
216 
217 #ifndef DOXYGEN_SHOULD_SKIP_THIS
218  virtual void setMonitor(SearchMonitor* monitor, const char* context = "");
219  virtual SearchMonitor* getMonitor() const;
220  virtual std::string getMonitorContext() const;
221  virtual void reportToMonitor(const SearchReport& report) const;
222 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
223 };
224 
225 } // namespace os
226 } // namespace yarp
227 
228 #endif // YARP_OS_SEARCHABLE_H
yarp::os::Bottle
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:72
yarp::os::Searchable
A base class for nested structures that can be searched.
Definition: Searchable.h:68
YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG
#define YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(x)
Definition: system.h:339
toString
std::string toString(const T &value)
convert an arbitrary type to string.
Definition: fakeMotionControl.cpp:113
yarp
Definition: numeric.h:47
YARP_os_API
#define YARP_os_API
Definition: api.h:19
ConstString.h
yarp::os::Value
A single value (typically within a Bottle).
Definition: Value.h:46
api.h