KDBindings API Documentation  1.0.95
Public Member Functions | List of all members
KDBindings::PropertyUpdater< T > Class Template Referenceabstract

A PropertyUpdater defines the interface used to update a Property, e.g. from a binding expression. More...

#include <property_updater.h>

Public Member Functions

 PropertyUpdater ()=default
 
 PropertyUpdater (PropertyUpdater &&other)=default
 
 PropertyUpdater (PropertyUpdater const &other)=default
 
virtual ~PropertyUpdater ()=default
 
virtual T get () const =0
 
PropertyUpdateroperator= (PropertyUpdater &&other)=default
 
PropertyUpdateroperator= (PropertyUpdater const &other)=default
 
virtual void setUpdateFunction (std::function< void(T &&)> const &updateFunction)=0
 

Detailed Description

template<typename T>
class KDBindings::PropertyUpdater< T >

A PropertyUpdater defines the interface used to update a Property, e.g. from a binding expression.

An instance of this class (wrapped in a std::unique_ptr) can be passed to the Property constructor. The Property will then become read-only, meaning an instance of ReadOnlyProperty will be thrown if the Property's value is updated through any other means than through the PropertyUpdater.

The Property constructor will pass a function to setUpdateFunction() for this purpose. This function is then the only way to update the Property without encountering a ReadOnlyProperty error.

The most typical use of PropertyUpdater is in instances of Binding, which are created by makeBoundProperty().

Definition at line 31 of file property_updater.h.

Constructor & Destructor Documentation

◆ PropertyUpdater() [1/3]

template<typename T >
KDBindings::PropertyUpdater< T >::PropertyUpdater ( )
default

A PropertyUpdater can be default constructed.

◆ ~PropertyUpdater()

template<typename T >
virtual KDBindings::PropertyUpdater< T >::~PropertyUpdater ( )
virtualdefault

A PropertyUpdater has a virtual destructor.

◆ PropertyUpdater() [2/3]

template<typename T >
KDBindings::PropertyUpdater< T >::PropertyUpdater ( PropertyUpdater< T > const &  other)
default

A PropertyUpdater can be copy constructed.

◆ PropertyUpdater() [3/3]

template<typename T >
KDBindings::PropertyUpdater< T >::PropertyUpdater ( PropertyUpdater< T > &&  other)
default

A PropertyUpdater can be move constructed.

Member Function Documentation

◆ get()

template<typename T >
virtual T KDBindings::PropertyUpdater< T >::get ( ) const
pure virtual

The get() function must return the current value the PropertyUpdater wants to assign to the Property.

It is called from the Property constructor.

Implemented in KDBindings::Binding< T, EvaluatorT >, and KDBindings::Binding< T, BindingEvaluator >.

◆ operator=() [1/2]

template<typename T >
PropertyUpdater& KDBindings::PropertyUpdater< T >::operator= ( PropertyUpdater< T > &&  other)
default

A PropertyUpdater can be move assigned.

◆ operator=() [2/2]

template<typename T >
PropertyUpdater& KDBindings::PropertyUpdater< T >::operator= ( PropertyUpdater< T > const &  other)
default

A PropertyUpdater can be copy assigned.

◆ setUpdateFunction()

template<typename T >
virtual void KDBindings::PropertyUpdater< T >::setUpdateFunction ( std::function< void(T &&)> const &  updateFunction)
pure virtual

The Property will call this function when it constructed and pass a std::function as argument that allows the PropertyUpdater to update the Property value.

A PropertyUpdater typically saves this function and calls it once the value it computes changes.

Implemented in KDBindings::Binding< T, EvaluatorT >, and KDBindings::Binding< T, BindingEvaluator >.


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

© Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
KDBindings
Reactive programming & data binding in C++
https://github.com/KDAB/KDBindings/
Generated by doxygen 1.9.1