UHD  003.004.000-16-stable
Public Types | Public Member Functions
uhd::property Class Reference

#include <property_tree.hpp>

List of all members.

Public Types

typedef boost::function< void(const
T &)> 
subscriber_type
typedef boost::function< T(void)> publisher_type
typedef boost::function< T(const
T &)> 
coercer_type

Public Member Functions

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

Detailed Description

A templated property interface for holding a value and registering callbacks when that value changes.


Member Typedef Documentation

typedef boost::function<T(const T &)> uhd::property::coercer_type
typedef boost::function<T(void)> uhd::property::publisher_type
typedef boost::function<void(const T &)> uhd::property::subscriber_type

Member Function Documentation

virtual property<T>& uhd::property::coerce ( const coercer_type coercer) [pure virtual]

Register a coercer into the property. A coercer is a special subscribes that coerces the value. Only one coercer may be registered per property. Registering a coercer replaces the previous coercer.

Parameters:
coercerthe coercer callback function
Returns:
a reference to this property for chaining
virtual bool uhd::property::empty ( void  ) const [pure virtual]

A property is empty if it has never been set. A property with a publisher is never empty.

Returns:
true if the property is empty
virtual T uhd::property::get ( void  ) const [pure virtual]

Get the current value of this property. The publisher (when provided) yields the value, otherwise an internal shadow is used for the value.

Returns:
the current value in the property
virtual property<T>& uhd::property::publish ( const publisher_type publisher) [pure virtual]

Register a publisher into the property. A publisher is a special callback the provides the value. Publishers are useful for creating read-only properties. Only one publisher may be registered per property. Registering a publisher replaces the previous publisher.

Parameters:
publisherthe publisher callback function
Returns:
a reference to this property for chaining
virtual property<T>& uhd::property::set ( const T &  value) [pure virtual]

Set the new value and call all subscribers. The coercer (when provided) is called initially, and the coerced value is used to set the subscribers.

Parameters:
valuethe new value to set on this property
Returns:
a reference to this property for chaining
virtual property<T>& uhd::property::subscribe ( const subscriber_type subscriber) [pure virtual]

Register a subscriber into the property. All subscribers are called when the value changes. Once a subscriber is registered, it cannot be unregistered.

Parameters:
subscriberthe subscriber callback function
Returns:
a reference to this property for chaining
virtual property<T>& uhd::property::update ( void  ) [pure virtual]

Update calls all subscribers w/ the current value.

Returns:
a reference to this property for chaining

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines