YARP
Yet Another Robot Platform
Searchable.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2019 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  virtual ~Searchable();
84 
91  virtual bool check(const std::string& key) const = 0;
92 
93 
101  virtual bool check(const std::string& key,
102  const std::string& comment) const;
103 
112  virtual Value& find(const std::string& key) const = 0;
113 
124  virtual Bottle& findGroup(const std::string& key) const = 0;
125 
137  Bottle& findGroup(const std::string& key, const std::string& comment) const;
138 
164  virtual bool check(const std::string& key,
165  Value*& result,
166  const std::string& comment = "") const;
167 
168 
178  virtual Value check(const std::string& key,
179  const Value& fallback,
180  const std::string& comment = "") const;
181 
186  virtual bool isNull() const;
187 
195  virtual std::string toString() const = 0;
196 
197 #ifndef DOXYGEN_SHOULD_SKIP_THIS
198  virtual void setMonitor(SearchMonitor* monitor, const char* context = "");
199  virtual SearchMonitor* getMonitor() const;
200  virtual std::string getMonitorContext() const;
201  virtual void reportToMonitor(const SearchReport& report) const;
202 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
203 };
204 
205 } // namespace os
206 } // namespace yarp
207 
208 #endif // YARP_OS_SEARCHABLE_H
A base class for nested structures that can be searched.
Definition: Searchable.h:68
#define YARP_OS_API
Definition: api.h:19
The main, catch-all namespace for YARP.
Definition: numeric.h:47
A simple collection of objects that can be described and transmitted in a portable way...
Definition: Bottle.h:72
A single value (typically within a Bottle).
Definition: Value.h:46
#define YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(x)
Suppress MSVC C4251 warning for the declaration.
Definition: system.h:339
std::string toString(const T &value)
convert an arbitrary type to string.