UHD 003.005.002-0-unknown

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
property_tree.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2011 Ettus Research LLC
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 //
17
18 #ifndef INCLUDED_UHD_PROPERTY_TREE_HPP
19 #define INCLUDED_UHD_PROPERTY_TREE_HPP
20
21 #include <uhd/config.hpp>
22 #include <boost/utility.hpp>
23 #include <boost/shared_ptr.hpp>
24 #include <boost/function.hpp>
25 #include <vector>
26
27 namespace uhd{
28
33 template <typename T> class property : boost::noncopyable{
34 public:
35 typedef boost::function<void(const T &)> subscriber_type;
36 typedef boost::function<T(void)> publisher_type;
37 typedef boost::function<T(const T &)> coercer_type;
38
47 virtual property<T> &coerce(const coercer_type &coercer) = 0;
48
58 virtual property<T> &publish(const publisher_type &publisher) = 0;
59
67 virtual property<T> &subscribe(const subscriber_type &subscriber) = 0;
68
73 virtual property<T> &update(void) = 0;
74
82 virtual property<T> &set(const T &value) = 0;
83
90 virtual T get(void) const = 0;
91
97 virtual bool empty(void) const = 0;
98 };
99
107 struct fs_path : std::string{
108 UHD_API fs_path(void);
109 UHD_API fs_path(const char *);
110 UHD_API fs_path(const std::string &);
111 UHD_API std::string leaf(void) const;
112 UHD_API fs_path branch_path(void) const;
113 };
114
115 UHD_API fs_path operator/(const fs_path &, const fs_path &);
116
120 class UHD_API property_tree : boost::noncopyable{
121 public:
122 typedef boost::shared_ptr<property_tree> sptr;
123
125 static sptr make(void);
126
128 virtual sptr subtree(const fs_path &path) const = 0;
129
131 virtual void remove(const fs_path &path) = 0;
132
134 virtual bool exists(const fs_path &path) const = 0;
135
137 virtual std::vector<std::string> list(const fs_path &path) const = 0;
138
140 template <typename T> property<T> &create(const fs_path &path);
141
143 template <typename T> property<T> &access(const fs_path &path);
144
145 private:
147 virtual void _create(const fs_path &path, const boost::shared_ptr<void> &prop) = 0;
148
150 virtual boost::shared_ptr<void> &_access(const fs_path &path) const = 0;
151
152 };
153
154 } //namespace uhd
155
156 #include <uhd/property_tree.ipp>
157
158 #endif /* INCLUDED_UHD_PROPERTY_TREE_HPP */
uhd::property::subscriber_type
boost::function< void(const T &)> subscriber_type
Definition: property_tree.hpp:35
uhd::property::update
virtual property< T > & update(void)=0
uhd::fs_path::fs_path
UHD_API fs_path(void)
uhd::fs_path
Definition: property_tree.hpp:107
config.hpp
uhd::property_tree::sptr
boost::shared_ptr< property_tree > sptr
Definition: property_tree.hpp:122
uhd::property::publish
virtual property< T > & publish(const publisher_type &publisher)=0
uhd::fs_path::branch_path
UHD_API fs_path branch_path(void) const
UHD_API
#define UHD_API
Definition: config.hpp:76
uhd::property::coercer_type
boost::function< T(const T &)> coercer_type
Definition: property_tree.hpp:37
uhd::property::empty
virtual bool empty(void) const =0
uhd::property::coerce
virtual property< T > & coerce(const coercer_type &coercer)=0
uhd::property::set
virtual property< T > & set(const T &value)=0
uhd::property::publisher_type
boost::function< T(void)> publisher_type
Definition: property_tree.hpp:36
uhd::property::subscribe
virtual property< T > & subscribe(const subscriber_type &subscriber)=0
uhd::property_tree
Definition: property_tree.hpp:120
uhd::operator/
UHD_API fs_path operator/(const fs_path &, const fs_path &)
uhd::property
Definition: property_tree.hpp:33
uhd::fs_path::leaf
UHD_API std::string leaf(void) const