YARP
Yet Another Robot Platform
Searchable.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2018 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 #include <string>
15 #include <cstddef>
16 
17 #ifndef YARP_NO_DEPRECATED // Since YARP 3.0.0
18 # include <yarp/os/ConstString.h>
19 #endif // YARP_NO_DEPRECATED
20 
21 
22 namespace yarp {
23  namespace os {
24  class Value;
25  class Bottle;
26  class Searchable;
27  class SearchMonitor;
28  class SearchReport;
29  }
30 }
31 
32 #ifndef DOXYGEN_SHOULD_SKIP_THIS
33 
34 class YARP_OS_API yarp::os::SearchReport {
35 public:
37  YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(std::string) value;
38  bool isFound;
39  bool isGroup;
40  bool isComment;
41  bool isDefault;
42 
43  explicit SearchReport();
44 };
45 
46 class YARP_OS_API yarp::os::SearchMonitor {
47 public:
48  virtual ~SearchMonitor();
49  virtual void report(const SearchReport& report, const char *context) = 0;
50 };
51 
52 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
53 
54 
66 private:
67  SearchMonitor *monitor;
69 public:
73  explicit Searchable();
74 
78  virtual ~Searchable();
79 
86  virtual bool check(const std::string& key) const = 0;
87 
88 
96  virtual bool check(const std::string& key,
97  const std::string& comment) const;
98 
107  virtual Value& find(const std::string& key) const = 0;
108 
119  virtual Bottle& findGroup(const std::string& key) const = 0;
120 
132  Bottle& findGroup(const std::string& key, const std::string& comment) const;
133 
159  virtual bool check(const std::string& key, Value *& result,
160  const std::string& comment = "") const;
161 
162 
172  virtual Value check(const std::string& key, const Value& fallback,
173  const std::string& comment = "") const;
174 
179  virtual bool isNull() const;
180 
188  virtual std::string toString() const = 0;
189 
190 #ifndef DOXYGEN_SHOULD_SKIP_THIS
191  virtual void setMonitor(SearchMonitor *monitor, const char *context="");
192  virtual SearchMonitor *getMonitor() const;
193  virtual std::string getMonitorContext() const;
194  virtual void reportToMonitor(const SearchReport& report) const;
195 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
196 };
197 
198 
199 #endif // YARP_OS_SEARCHABLE_H
SearchMonitor * monitor
Definition: Searchable.h:67
std::string monitorContext
Definition: Searchable.h:68
A base class for nested structures that can be searched.
Definition: Searchable.h:65
#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:70
A single value (typically within a Bottle).
Definition: Value.h:40
#define YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(x)
Suppress MSVC C4251 warning for the declaration.
Definition: system.h:346
std::string toString(const T &value)
convert an arbitrary type to string.