All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
property_tree.hpp
Go to the documentation of this file.
//
// Copyright 2011 Ettus Research LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#ifndef INCLUDED_UHD_PROPERTY_TREE_HPP
#define INCLUDED_UHD_PROPERTY_TREE_HPP
#include <uhd/config.hpp>
#include <boost/utility.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
#include <vector>
namespace uhd{
template <typename T> class property : boost::noncopyable{
public:
typedef boost::function<void(const T &)> subscriber_type;
typedef boost::function<T(void)> publisher_type;
typedef boost::function<T(const T &)> coercer_type;
virtual property<T> &coerce(const coercer_type &coercer) = 0;
virtual property<T> &publish(const publisher_type &publisher) = 0;
virtual property<T> &subscribe(const subscriber_type &subscriber) = 0;
virtual property<T> &update(void) = 0;
virtual property<T> &set(const T &value) = 0;
virtual T get(void) const = 0;
virtual bool empty(void) const = 0;
};
struct fs_path : std::string{
UHD_API fs_path(void);
UHD_API fs_path(const char *);
UHD_API fs_path(const std::string &);
UHD_API std::string leaf(void) const;
UHD_API fs_path branch_path(void) const;
};
UHD_API fs_path operator/(const fs_path &, const fs_path &);
class UHD_API property_tree : boost::noncopyable{
public:
typedef boost::shared_ptr<property_tree> sptr;
static sptr make(void);
virtual sptr subtree(const fs_path &path) const = 0;
virtual void remove(const fs_path &path) = 0;
virtual bool exists(const fs_path &path) const = 0;
virtual std::vector<std::string> list(const fs_path &path) const = 0;
template <typename T> property<T> &create(const fs_path &path);
template <typename T> property<T> &access(const fs_path &path);
private:
virtual void _create(const fs_path &path, const boost::shared_ptr<void> &prop) = 0;
virtual boost::shared_ptr<void> &_access(const fs_path &path) const = 0;
};
} //namespace uhd
#include <uhd/property_tree.ipp>
#endif /* INCLUDED_UHD_PROPERTY_TREE_HPP */