Loading [MathJax]/extensions/tex2jax.js
USRP Hardware Driver and USRP Manual  Version: 4.8.0.0
UHD and USRP Manual
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
property_tree.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2011,2014-2016 Ettus Research
3 // Copyright 2018 Ettus Research, a National Instruments Company
4 // Copyright 2019 Ettus Research, a National Instruments Brand
5 //
6 // SPDX-License-Identifier: GPL-3.0-or-later
7 //
8 
9 #pragma once
10 
11 #include <uhd/config.hpp>
13 #include <cstddef>
14 #include <functional>
15 #include <memory>
16 #include <string>
17 #include <vector>
18 
19 namespace uhd {
20 
26 {
27 public:
28  virtual ~property_iface() = default;
29 };
30 
78 template <typename T>
80 {
81 public:
82  typedef std::function<void(const T&)> subscriber_type;
83  typedef std::function<T(void)> publisher_type;
84  typedef std::function<T(const T&)> coercer_type;
85 
86  virtual ~property(void) = 0;
87 
98  virtual property<T>& set_coercer(const coercer_type& coercer) = 0;
99 
110  virtual property<T>& set_publisher(const publisher_type& publisher) = 0;
111 
121  virtual property<T>& add_desired_subscriber(const subscriber_type& subscriber) = 0;
122 
132  virtual property<T>& add_coerced_subscriber(const subscriber_type& subscriber) = 0;
133 
140  virtual property<T>& update(void) = 0;
141 
154  virtual property<T>& set(const T& value) = 0;
155 
167  virtual property<T>& set_coerced(const T& value) = 0;
168 
177  virtual const T get(void) const = 0;
178 
185  virtual const T get_desired(void) const = 0;
186 
193  virtual bool empty(void) const = 0;
194 };
195 
196 template <typename T>
198 {
199  /* NOP */
200 }
201 
206 struct UHD_API_HEADER fs_path : std::string
207 {
208  UHD_API fs_path(void);
209  UHD_API fs_path(const char*);
210  UHD_API fs_path(const std::string&);
211  UHD_API std::string leaf(void) const;
212  UHD_API fs_path branch_path(void) const;
213 };
214 
215 UHD_API fs_path operator/(const fs_path&, const fs_path&);
216 UHD_API fs_path operator/(const fs_path&, size_t);
217 
222 {
223 public:
224  typedef std::shared_ptr<property_tree> sptr;
225 
226  enum coerce_mode_t { AUTO_COERCE, MANUAL_COERCE };
227 
228  virtual ~property_tree(void) = 0;
229 
231  static sptr make(void);
232 
234  virtual sptr subtree(const fs_path& path) const = 0;
235 
237  virtual void remove(const fs_path& path) = 0;
238 
240  virtual bool exists(const fs_path& path) const = 0;
241 
243  virtual std::vector<std::string> list(const fs_path& path) const = 0;
244 
246  template <typename T>
247  property<T>& create(const fs_path& path, coerce_mode_t coerce_mode = AUTO_COERCE);
248 
250  template <typename T>
251  property<T>& access(const fs_path& path);
252 
254  template <typename T>
255  std::shared_ptr<property<T>> pop(const fs_path& path);
256 
257 private:
259  virtual std::shared_ptr<property_iface> _pop(const fs_path& path) = 0;
260 
262  virtual void _create(
263  const fs_path& path, const std::shared_ptr<property_iface>& prop) = 0;
264 
266  virtual std::shared_ptr<property_iface>& _access(const fs_path& path) const = 0;
267 };
268 
269 } // namespace uhd
270 
271 #include <uhd/property_tree.ipp>
uhd::property_iface
Definition: property_tree.hpp:25
config.hpp
uhd::property::coercer_type
std::function< T(const T &)> coercer_type
Definition: property_tree.hpp:84
property_tree.ipp
UHD_API
#define UHD_API
Definition: config.h:87
uhd::property::publisher_type
std::function< T(void)> publisher_type
Definition: property_tree.hpp:83
uhd::property_tree::sptr
std::shared_ptr< property_tree > sptr
Definition: property_tree.hpp:224
noncopyable.hpp
uhd::operator/
UHD_API fs_path operator/(const fs_path &, const fs_path &)
uhd::property_tree::coerce_mode_t
coerce_mode_t
Definition: property_tree.hpp:226
uhd
Definition: build_info.hpp:12
uhd::fs_path
Definition: property_tree.hpp:206
uhd::property
Definition: property_tree.hpp:79
uhd::property_tree
Definition: property_tree.hpp:221
uhd::property::subscriber_type
std::function< void(const T &)> subscriber_type
Definition: property_tree.hpp:82
uhd::property::~property
virtual ~property(void)=0
Definition: property_tree.hpp:197
uhd::noncopyable
boost::noncopyable noncopyable
Definition: noncopyable.hpp:45
UHD_API_HEADER
#define UHD_API_HEADER
Definition: config.h:88