core::Property< T > Class Template Reference

A very simple, templated class that allows for uniform declaration of get-able/set-able/observable members. More...

`#include <property.h>`

Collaboration diagram for core::Property< T >:

## 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

## Detailed Description

template<typename T>
class core::Property< T >

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.

Template Parameters

  The | type of the value contained within the property.

Definition at line 37 of file property.h.

## Member Typedef Documentation

## Getter

template<typename T >

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.

## Setter

template<typename T >

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.

## ValueType

template<typename T >

typedef T core::Property< T >::ValueType

ValueType refers to the type of the contained value.

Definition at line 43 of file property.h.

## Constructor & Destructor Documentation

## Property() [1/2]

template<typename T >

core::Property< T >::Property | ( | const T & | t = `T{}` | ) |

inline explicit

Property creates a new instance of property and initializes the contained value.

Parameters

  t | The initial value, defaults to Property<T>::default_value().

Definition at line 59 of file property.h.

## Property() [2/2]

template<typename T >

core::Property< T >::Property | ( | const Property< T > & | rhs | ) |

inline

Copy c'tor, only copies the contained value, not the changed signal and its connections.

Parameters

  rhs |

Definition at line 70 of file property.h.

## ~Property()

template<typename T >

virtual core::Property< T >::~Property | ( |  | ) |

inline virtual default

## Member Function Documentation

## changed()

template<typename T >

const Signal< T > & core::Property< T >::changed | ( |  | ) | const

inline

Access to the changed signal, allows observers to subscribe to change notifications.

Returns
  A non-mutable reference to the changed signal.

Definition at line 169 of file property.h.

Referenced by TEST(), TEST(), and TEST().

## get()

template<typename T >

virtual const T & core::Property< T >::get | ( |  | ) | const

inline virtual

Access the value contained within this property.

Returns
  A non-mutable reference to the property value.

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->(), TEST(), TEST(), TEST(), TEST(), and TEST().

Here is the call graph for this function:

## install() [1/2]

template<typename T >

void core::Property< T >::install | ( | const Getter & | getter | ) |

inline

install takes the provided functor and installs it for dispatching all get operations.

Parameters

  getter | The functor to be invoked for get operations.

Definition at line 207 of file property.h.

## install() [2/2]

template<typename T >

void core::Property< T >::install | ( | const Setter & | setter | ) |

inline

install takes the provided functor and installs it for dispatching all set operations.

Parameters

  setter | The functor to be invoked for set operations.

Definition at line 198 of file property.h.

Referenced by TEST(), and TEST().

## mutable_get()

template<typename T >

virtual T & core::Property< T >::mutable_get | ( |  | ) | const

inline protected virtual

Definition at line 224 of file property.h.

Referenced by core::Property< T >::get(), and core::Property< T >::update().

## operator const T &()

template<typename T >

core::Property< T >::operator const T & | ( |  | ) | const

inline

Explicit casting operator to the contained value type.

Returns
  A non-mutable reference to the contained value.

Definition at line 100 of file property.h.

References core::Property< T >::get().

Here is the call graph for this function:

## operator->()

template<typename T >

const T * core::Property< T >::operator-> | ( |  | ) | const

inline

Provides access to a pointer to the contained value.

Definition at line 108 of file property.h.

References core::Property< T >::get().

Here is the call graph for this function:

## operator=() [1/2]

template<typename T >

Property & core::Property< T >::operator= | ( | const Property< T > & | rhs | ) |

inline

Assignment operator, only assigns to the contained value, not the changed signal and its connections.

Parameters

  rhs | The right-hand-side property to assign from.

Definition at line 90 of file property.h.

References core::Property< T >::set().

Here is the call graph for this function:

## operator=() [2/2]

template<typename T >

Property & core::Property< T >::operator= | ( | const T & | rhs | ) |

inline

Assignment operator, only assigns to the contained value.

Parameters

  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().

Here is the call graph for this function:

## set()

template<typename T >

virtual void core::Property< T >::set | ( | const T & | new_value | ) |

inline virtual

Set the contained value to the provided value. Notify observers of the change.

Parameters

  [in] | new_value | The new value to assign to this property.

Postcondition
  get() == new_value;

Definition at line 140 of file property.h.

Referenced by core::Property< T >::operator=(), core::Property< T >::operator=(), TEST(), TEST(), and TEST().

## update()

template<typename T >

virtual bool core::Property< T >::update | ( | const std::function< bool(T &t)> & | update_functor | ) |

inline virtual

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.

Parameters

  update_functor | The update function to be applied to the contained value.

Returns
  true iff application of the update functor has been successful.

Definition at line 183 of file property.h.

References core::Property< T >::mutable_get().

Referenced by TEST().

Here is the call graph for this function:

The documentation for this class was generated from the following file:

- property.h