properties-cpp 0.0.1
A very simple convenience library for handling properties and signals in C++11.
|
A very simple, templated class that allows for uniform declaration of get-able/set-able/observable members. More...
#include <property.h>
Public Types | |
typedef T | ValueType |
ValueType refers to the type of the contained value. | |
typedef std::function< ValueType()> | Getter |
Getter refers to the function type for dispatching get operations to. | |
typedef std::function< void(const ValueType &)> | Setter |
Setter refers to the function type for dispatching set operations to. | |
Public Member Functions | |
Property (const T &t=T{}) | |
Property creates a new instance of property and initializes the contained value. | |
Property (const Property< T > &rhs) | |
Copy c'tor, only copies the contained value, not the changed signal and its connections. | |
virtual | ~Property ()=default |
Property & | operator= (const T &rhs) |
Assignment operator, only assigns to the contained value. | |
Property & | operator= (const Property< T > &rhs) |
Assignment operator, only assigns to the contained value, not the changed signal and its connections. | |
operator const T & () const | |
Explicit casting operator to the contained value type. | |
const T * | operator-> () const |
Provides access to a pointer to the contained value. | |
virtual void | set (const T &new_value) |
Set the contained value to the provided value. Notify observers of the change. | |
virtual const T & | get () const |
Access the value contained within this property. | |
const Signal< T > & | changed () const |
Access to the changed signal, allows observers to subscribe to change notifications. | |
virtual bool | update (const std::function< bool(T &t)> &update_functor) |
Provides in-place update facilities. | |
void | install (const Setter &setter) |
install takes the provided functor and installs it for dispatching all set operations. | |
void | install (const Getter &getter) |
install takes the provided functor and installs it for dispatching all get operations. | |
Protected Member Functions | |
virtual T & | mutable_get () const |
A very simple, templated class that allows for uniform declaration of get-able/set-able/observable members.
A note on thread-safety: The property class itself does not give any thread-safety guarantees. That is, consumers must not assume that concurrent get() and set() operations are synchronized by this class.
The | type of the value contained within the property. |
Definition at line 37 of file property.h.
typedef std::function<ValueType()> core::Property< T >::Getter |
Getter refers to the function type for dispatching get operations to.
Definition at line 48 of file property.h.
typedef std::function<void(const ValueType&)> core::Property< T >::Setter |
Setter refers to the function type for dispatching set operations to.
Definition at line 53 of file property.h.
typedef T core::Property< T >::ValueType |
ValueType refers to the type of the contained value.
Definition at line 43 of file property.h.
|
inlineexplicit |
Property creates a new instance of property and initializes the contained value.
t | The initial value, defaults to Property<T>::default_value(). |
Definition at line 59 of file property.h.
|
inline |
Copy c'tor, only copies the contained value, not the changed signal and its connections.
rhs |
Definition at line 70 of file property.h.
|
inlinevirtualdefault |
|
inline |
Access to the changed signal, allows observers to subscribe to change notifications.
Definition at line 169 of file property.h.
Referenced by TEST().
|
inlinevirtual |
Access the value contained within this property.
Definition at line 157 of file property.h.
References core::Property< T >::mutable_get().
Referenced by core::Property< T >::operator const T &(), core::Property< T >::operator->(), and TEST().
|
inline |
install takes the provided functor and installs it for dispatching all get operations.
getter | The functor to be invoked for get operations. |
Definition at line 207 of file property.h.
|
inline |
install takes the provided functor and installs it for dispatching all set operations.
setter | The functor to be invoked for set operations. |
Definition at line 198 of file property.h.
Referenced by TEST().
|
inlineprotectedvirtual |
Definition at line 224 of file property.h.
Referenced by core::Property< T >::get(), and core::Property< T >::update().
|
inline |
Explicit casting operator to the contained value type.
Definition at line 100 of file property.h.
References core::Property< T >::get().
|
inline |
Provides access to a pointer to the contained value.
Definition at line 108 of file property.h.
References core::Property< T >::get().
|
inline |
Assignment operator, only assigns to the contained value, not the changed signal and its connections.
rhs | The right-hand-side property to assign from. |
Definition at line 90 of file property.h.
References core::Property< T >::set().
|
inline |
Assignment operator, only assigns to the contained value.
rhs | The right-hand-side, raw value to assign to this property. |
Definition at line 80 of file property.h.
References core::Property< T >::set().
|
inlinevirtual |
Set the contained value to the provided value. Notify observers of the change.
[in] | new_value | The new value to assign to this property. |
Definition at line 140 of file property.h.
Referenced by core::Property< T >::operator=(), and TEST().
|
inlinevirtual |
Provides in-place update facilities.
The provided update_functor is applied to the contained value. If the update functor returns true, indicating that the value has been changed, the changed signal is emitted.
update_functor | The update function to be applied to the contained value. |
Definition at line 183 of file property.h.
References core::Property< T >::mutable_get().
Referenced by TEST().