Qx v0.6
Qt Extensions Library
|
The AbstractBindableProperty class provides the baseline feature for bindable properties of the Qx Bindable Properties System. More...
#include <qx/core/qx-property.h>
Public Member Functions | |
template<std::invocable Functor> | |
void | addLifetimeNotifier (Functor &&f) const |
template<std::invocable Functor> | |
PropertyNotifier | addNotifier (Functor &&f) const |
PropertyBinding< T > | binding () const |
bool | hasBinding () const |
operator const T & () const | |
const T & | operator* () const |
decltype(auto) | operator-> () const |
void | removeBinding () |
PropertyBinding< T > | setBinding (const PropertyBinding< T > &binding) |
template<std::invocable Functor> | |
PropertyBinding< T > | setBinding (Functor &&f) |
void | setValue (const T &newValue) |
void | setValue (T &&newValue) |
void | setValueBypassingBindings (const T &v) |
virtual void | setValueBypassingBindings (T &&v)=0 |
template<std::invocable Functor> | |
PropertyNotifier | subscribe (Functor &&f) const |
template<std::invocable Functor> | |
void | subscribeLifetime (Functor &&f) const |
PropertyBinding< T > | takeBinding () |
const T & | value () const |
virtual const T & | valueBypassingBindings () const =0 |
Protected Member Functions | |
AbstractBindableProperty () | |
AbstractBindableProperty (AbstractBindableProperty &&other) noexcept=default | |
AbstractBindableProperty & | operator= (AbstractBindableProperty &&other) noexcept=default |
AbstractBindableProperty is the standard interface shared by all bindable properties and contains most of the functionality that any given implementation will provide to user code; that is, most individual implementations are minimal annex that simply dictate how the underlying data of the property is read/written, and the bulk of the Bindable Properties System is contained within this base class.
You can assign a value to properties and you can read them via value(), operator*(), or operator const T&(). You can also tie a property to an expression that computes the value dynamically, called a "binding expression". The binding expression can be any C++ functor, though most often a lambda, and can be used to express relationships between different properties in your application.
|
inlineprotected |
Constructs an AbstractBindableProperty.
|
protecteddefaultnoexcept |
Move-constructs an AbstractBindableProperty using other.
|
inline |
Same as addNotifier(), but the lifetime of the subscription is tied to the lifetime of the property so no change handler object is returned.
|
inline |
Subscribes the given functor f as a callback that is called whenever the value of the property changes.
The callback f is expected to be a type that has a plain call operator()
without any parameters. This means that you can provide a C++ lambda expression, a std::function or even a custom struct with a call operator.
The returned property change handler object keeps track of the subscription. When it goes out of scope, the callback is unsubscribed.
|
inline |
Returns the binding expression that is associated with this property. A default constructed PropertyBinding will be returned if no such association exists.
|
inline |
Returns true
if the property has a binding associated with it; otherwise, returns false.
|
inline |
Type-conversion operator for a const reference to the underlying type.
|
inline |
Same as value().
|
inline |
Returns a pointer to the underlying property data (bindings are still respected).
|
protecteddefaultnoexcept |
Move-assigns an AbstractBindableProperty using other.
|
inline |
Disassociates the binding expression from this property. After calling this function, the value of the property will only change if you assign a new value to it, or when a new binding is set.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Associates the value of this property with the provided binding expression and returns the previously associated binding. The property's value is set to the result of evaluating the new binding. Whenever a dependency of the binding changes, the binding will be re-evaluated, and the property's value gets updated accordingly.
|
inline |
Associates the value of this property with the provided functor f and returns the previously associated binding. The property's value is set to the result of evaluating the new binding. Whenever a dependency of the binding changes, the binding will be re-evaluated, and the property's value gets updated accordingly.
|
inline |
Assigns newValue to this property and removes the property's associated binding, if present.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Directly sets the value of the property to v.
This is generally only used by a derived class to control how the underlying data is written when a copy of T is provided, but there are some cases (like maintaining class invariants) where it is useful externally.
|
pure virtual |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Directly sets the value of this property to v.
This is generally only used by a derived class to control how the underlying data is written when an rvalue of T is provided, but there are some cases (like maintaining class invariants) where it is useful externally.
Implemented in Qx::Property< T >.
|
inline |
Same as invoking f (e.g. f()
), followed by addNotifier(f)
.
That is, the callback functor is called immediately before it's registered.
|
inline |
Same as invoking f (e.g. f()
), followed by addLifetimeNotifier(f)
.
That is, the callback functor is called immediately before it's registered.
|
inline |
Disassociates the binding expression from this property and returns it. After calling this function, the value of the property will only change if you assign a new value to it, or when a new binding is set.
|
inline |
Returns the value of the property. This may evaluate a binding expression that is tied to this property, before returning the value.
|
pure virtual |
Returns the direct value of the property.
This is generally only used by a derived class to control how the underlying data is read when requested, but there are some cases where it is useful externally.
Implemented in Qx::Property< T >.