Skip to content

KDBindings::PropertyUpdater

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

#include <property_updater.h>

Inherited by KDBindings::Binding< T, BindingEvaluator >, KDBindings::Binding< T, EvaluatorT >

Public Functions

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

Detailed Description

1
2
template <typename T >
class KDBindings::PropertyUpdater;

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

Public Functions Documentation

function PropertyUpdater

1
PropertyUpdater() =default

A PropertyUpdater can be default constructed.

function PropertyUpdater

1
2
3
PropertyUpdater(
    PropertyUpdater && other
) =default

A PropertyUpdater can be move constructed.

function PropertyUpdater

1
2
3
PropertyUpdater(
    PropertyUpdater const & other
) =default

A PropertyUpdater can be copy constructed.

function ~PropertyUpdater

1
virtual ~PropertyUpdater() =default

A PropertyUpdater has a virtual destructor.

function get

1
virtual T get() const =0

Reimplemented by: KDBindings::Binding::get, KDBindings::Binding::get

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

It is called from the Property constructor.

function operator=

1
2
3
PropertyUpdater & operator=(
    PropertyUpdater && other
) =default

A PropertyUpdater can be move assigned.

function operator=

1
2
3
PropertyUpdater & operator=(
    PropertyUpdater const & other
) =default

A PropertyUpdater can be copy assigned.

function setUpdateFunction

1
2
3
virtual void setUpdateFunction(
    std::function< void(T &&)> const & updateFunction
) =0

Reimplemented by: KDBindings::Binding::setUpdateFunction, KDBindings::Binding::setUpdateFunction

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.


Updated on 2024-07-13 at 00:00:32 +0000