18namespace uhd { 
namespace  {
 
   21class property_impl : 
public property<T>
 
   27            _coercer = DEFAULT_COERCER;
 
   39            uhd::assertion_error(
"cannot register more than one coercer for a property");
 
   43                "cannot register coercer for a manually coerced property");
 
   53                "cannot register more than one publisher for a property");
 
   56        _publisher = publisher;
 
   60    property<T>& add_desired_subscriber(
 
   63        _desired_subscribers.push_back(subscriber);
 
   67    property<T>& add_coerced_subscriber(
 
   70        _coerced_subscribers.push_back(subscriber);
 
   74    property<T>& update(
void)
 
   76        this->set(this->get());
 
   80    void _set_coerced(
const T& value)
 
   82        init_or_set_value(_coerced_value, value);
 
   84            csub(get_value_ref(_coerced_value)); 
 
   88    property<T>& set(
const T& value)
 
   90        init_or_set_value(_value, value);
 
   92            dsub(get_value_ref(_value)); 
 
   95            _set_coerced(_coercer(get_value_ref(_value)));
 
   98                uhd::assertion_error(
"coercer missing for an auto coerced property");
 
  103    property<T>& set_coerced(
const T& value)
 
  106            uhd::assertion_error(
"cannot set coerced value an auto coerced property");
 
  111    const T get(
void)
 const 
  114            throw uhd::runtime_error(
"Cannot get() on an uninitialized (empty) property");
 
  119            if (_coerced_value.get() == NULL
 
  121                throw uhd::runtime_error(
 
  122                    "uninitialized coerced value for manually coerced attribute");
 
  123            return get_value_ref(_coerced_value);
 
  127    const T get_desired(
void)
 const 
  129        if (_value.get() == NULL)
 
  130            throw uhd::runtime_error(
 
  131                "Cannot get_desired() on an uninitialized (empty) property");
 
  133        return get_value_ref(_value);
 
  136    bool empty(
void)
 const 
  138        return !bool(_publisher) and _value.get() == NULL;
 
  142    static T DEFAULT_COERCER(
const T& value)
 
  147    static void init_or_set_value(std::unique_ptr<T>& scoped_value, 
const T& init_val)
 
  149        if (scoped_value.get() == NULL) {
 
  150            scoped_value.reset(
new T(init_val));
 
  152            *scoped_value = init_val;
 
  156    static const T& get_value_ref(
const std::unique_ptr<T>& scoped_value)
 
  158        if (scoped_value.get() == NULL)
 
  159            throw uhd::assertion_error(
"Cannot use uninitialized property data");
 
  160        return *scoped_value.get();
 
  164    std::vector<typename property<T>::subscriber_type> _desired_subscribers;
 
  165    std::vector<typename property<T>::subscriber_type> _coerced_subscribers;
 
  168    std::unique_ptr<T> _value;
 
  169    std::unique_ptr<T> _coerced_value;
 
  182    this->_create(path, std::make_shared<property_impl<T>>(coerce_mode));
 
 
  189    auto ptr = std::dynamic_pointer_cast<property<T>>(this->_access(path));
 
  192            "Property " + path + 
" exists, but was accessed with wrong type");
 
 
  200    auto ptr = std::dynamic_pointer_cast<property<T>>(this->_pop(path));
 
  203            "Property " + path + 
" exists, but was accessed with wrong type");
 
 
property< T > & create(const fs_path &path, coerce_mode_t coerce_mode=AUTO_COERCE)
Create a new property entry in the tree.
Definition property_tree.ipp:180
std::shared_ptr< property< T > > pop(const fs_path &path)
Pop a property off the tree, and returns the property.
Definition property_tree.ipp:198
property< T > & access(const fs_path &path)
Get access to a property in the tree.
Definition property_tree.ipp:187
coerce_mode_t
Definition property_tree.hpp:226
@ AUTO_COERCE
Definition property_tree.hpp:226
@ MANUAL_COERCE
Definition property_tree.hpp:226
Definition property_tree.hpp:80
std::function< T(void)> publisher_type
Definition property_tree.hpp:83
std::function< T(const T &)> coercer_type
Definition property_tree.hpp:84
std::function< void(const T &)> subscriber_type
Definition property_tree.hpp:82
Definition build_info.hpp:12
Definition property_tree.hpp:207
Definition exception.hpp:97