YARP  2.3.68+272-20170522.1+git50f0ae7
Yet Another Robot Platform
Searchable.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006 RobotCub Consortium
3  * Authors: Paul Fitzpatrick
4  * CopyPolicy: Released under the terms of the LGPLv2.1 or later, see LGPL.TXT
5  */
6 
7 #ifndef YARP_OS_SEARCHABLE_H
8 #define YARP_OS_SEARCHABLE_H
9 
10 #include <cstddef>
11 #include <yarp/os/ConstString.h>
12 
13 namespace yarp {
14  namespace os {
15  class Value;
16  class Bottle;
17  class Searchable;
18  class SearchMonitor;
19  class SearchReport;
20  }
21 }
22 
23 #ifndef DOXYGEN_SHOULD_SKIP_THIS
24 
25 class YARP_OS_API yarp::os::SearchReport {
26 public:
27  ConstString key;
28  ConstString value;
29  bool isFound;
30  bool isGroup;
31  bool isComment;
32  bool isDefault;
33 
34  explicit SearchReport();
35 };
36 
37 class YARP_OS_API yarp::os::SearchMonitor {
38 public:
39  virtual ~SearchMonitor();
40  virtual void report(const SearchReport& report, const char *context) = 0;
41 };
42 
43 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
44 
45 
56 class YARP_OS_API yarp::os::Searchable {
57 private:
58  SearchMonitor *monitor;
60 public:
64  explicit Searchable();
65 
69  virtual ~Searchable();
70 
77  virtual bool check(const ConstString& key) const = 0;
78 
79 
87  virtual bool check(const ConstString& key,
88  const ConstString& comment) const;
89 
98  virtual Value& find(const ConstString& key) const = 0;
99 
110  virtual Bottle& findGroup(const ConstString& key) const = 0;
111 
123  Bottle& findGroup(const ConstString& key, const ConstString& comment) const;
124 
150  virtual bool check(const ConstString& key, Value *& result,
151  const ConstString& comment = "") const;
152 
153 
163  virtual Value check(const ConstString& key, const Value& fallback,
164  const ConstString& comment = "") const;
165 
170  virtual bool isNull() const;
171 
179  virtual ConstString toString() const = 0;
180 
181 #ifndef DOXYGEN_SHOULD_SKIP_THIS
182  virtual void setMonitor(SearchMonitor *monitor, const char *context="");
183  virtual SearchMonitor *getMonitor() const;
184  virtual ConstString getMonitorContext() const;
185  virtual void reportToMonitor(const SearchReport& report) const;
186 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
187 };
188 
189 
190 #endif // YARP_OS_SEARCHABLE_H
SearchMonitor * monitor
Definition: Searchable.h:58
A base class for nested structures that can be searched.
Definition: Searchable.h:56
The main, catch-all namespace for YARP.
A string with almost the same api as std::string.
Definition: ConstString.h:44
A simple collection of objects that can be described and transmitted in a portable way...
Definition: Bottle.h:57
ConstString monitorContext
Definition: Searchable.h:59
A single value (typically within a Bottle).
Definition: Value.h:36
std::string toString(const T &value)
convert an arbitary type to string.