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. More...
typedef std::function< ValueType()> | Getter
| Getter refers to the function type for dispatching get operations to. More...
typedef std::function< void(const ValueType &)> | Setter
| Setter refers to the function type for dispatching set operations to. More...

## Public Member Functions

| Property (const T &t=T{})
| Property creates a new instance of property and initializes the contained value. More...
| Property (const Property< T > &rhs)
| Copy c'tor, only copies the contained value, not the changed signal and its connections. More...
virtual | ~Property ()=default
Property & | operator= (const T &rhs)
| Assignment operator, only assigns to the contained value. More...
Property & | operator= (const Property< T > &rhs)
| Assignment operator, only assigns to the contained value, not the changed signal and its connections. More...
| operator const T & () const
| Explicit casting operator to the contained value type. More...
const T * | operator-> () const
| Provides access to a pointer to the contained value. More...
virtual void | set (const T &new_value)
| Set the contained value to the provided value. Notify observers of the change. More...
virtual const T & | get () const
| Access the value contained within this property. More...
const Signal< T > & | changed () const
| Access to the changed signal, allows observers to subscribe to change notifications. More...
virtual bool | update (const std::function< bool(T &t)> &update_functor)
| Provides in-place update facilities. More...
void | install (const Setter &setter)
| install takes the provided functor and installs it for dispatching all set operations. More...
void | install (const Getter &getter)
| install takes the provided functor and installs it for dispatching all get operations. More...

## Protected Member Functions

virtual T & | mutable_get () const

## Friends

bool | operator== (const Property< T > &lhs, const T &rhs)
| operator == checks if the value of a property and a raw value are equal. More...
bool | operator== (const Property< T > &lhs, const Property< T > &rhs)
| operator == checks if the value of two properties are equal. More...
const Property< T > & | operator| (const Property< T > &lhs, Property< T > &rhs)

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

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.

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.

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

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.

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.

template<typename T>

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

inline virtual default

## Member Function Documentation

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

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

Here is the call graph for this function:
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().

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.

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

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.

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.

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

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:

## Friends And Related Function Documentation

template<typename T>

bool operator== | ( | const Property< T > & | lhs,
|  | const T & | rhs
| ) |  |

friend

operator == checks if the value of a property and a raw value are equal.

Parameters

  lhs | Non-mutable reference to a property.
  rhs | Non-mutable reference to a raw value.

Returns
  True iff the value contained in lhs equals rhs.

Definition at line 119 of file property.h.

template<typename T>

bool operator== | ( | const Property< T > & | lhs,
|  | const Property< T > & | rhs
| ) |  |

friend

operator == checks if the value of two properties are equal.

Parameters

  lhs | Non-mutable reference to a property.
  rhs | Non-mutable reference to a property.

Returns
  True iff the value contained in lhs equals the value contained in rhs.

Definition at line 130 of file property.h.

template<typename T>

const Property<T>& operator| | ( | const Property< T > & | lhs,
|  | Property< T > & | rhs
| ) |  |

friend

Definition at line 212 of file property.h.

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

- /build/buildd/properties-cpp-0.0.1+14.10.20140730/include/core/property.h