Qx v0.6
Qt Extensions Library
Loading...
Searching...
No Matches
Qx::Property< T > Class Template Reference

The Property class is a template class that enables automatic property bindings. More...

#include <qx/core/qx-property.h>

Inheritance diagram for Qx::Property< T >:
[legend]

Public Member Functions

 Property ()
 
 Property (const PropertyBinding< T > &binding)
 
 Property (const T &initialValue)
 
template<std::invocable Functor>
 Property (Functor &&f)
 
 Property (Property &&other) noexcept
 
 Property (T &&initialValue)
 
Propertyoperator= (const T &newValue)
 
Propertyoperator= (Property &&other) noexcept
 
Propertyoperator= (T &&newValue)
 
void setValueBypassingBindings (T &&v) override
 
const T & valueBypassingBindings () const override
 
- Public Member Functions inherited from Qx::AbstractBindableProperty< T >
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)
 
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
 

Additional Inherited Members

- Protected Member Functions inherited from Qx::AbstractBindableProperty< T >
 AbstractBindableProperty ()
 
 AbstractBindableProperty (AbstractBindableProperty &&other) noexcept=default
 
AbstractBindablePropertyoperator= (AbstractBindableProperty &&other) noexcept=default
 

Detailed Description

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

Property is the principal implementation of the Qx Bindable Properties System. It is a container that holds an instance of T.

It can be used in all of the ways described in AbstractBindableProperty to build a web of dynamic properties.

Constructor & Destructor Documentation

◆ Property() [1/6]

template<typename T >
Qx::Property< T >::Property ( )
inline

Constructs a property with a default constructed instance of T.

◆ Property() [2/6]

template<typename T >
Qx::Property< T >::Property ( Property< T > && other)
inlinenoexcept

Move-constructs a property from other.

◆ Property() [3/6]

template<typename T >
template<std::invocable Functor>
Qx::Property< T >::Property ( Functor && f)
inline

Constructs a property that is tied to the provided binding expression f. The binding is immediately evaluated to establish the initial value of the property. Whenever a dependency of the binding changes, the binding will be re-evaluated, and the property's value will be updated accordingly.

◆ Property() [4/6]

template<typename T >
Qx::Property< T >::Property ( const PropertyBinding< T > & binding)
inline

Constructs a property that is tied to the provided binding expression. The binding is immediately evaluated to establish the initial value of the property. Whenever a dependency of the binding changes, the binding will be re-evaluated, and the property's value will be updated accordingly.

◆ Property() [5/6]

template<typename T >
Qx::Property< T >::Property ( T && initialValue)
inline

Move-constructs a property with the provided initialValue.

◆ Property() [6/6]

template<typename T >
Qx::Property< T >::Property ( const T & initialValue)
inline

Constructs a property with the provided initialValue.

Member Function Documentation

◆ operator=() [1/3]

template<typename T >
Property & Qx::Property< T >::operator= ( const T & newValue)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ operator=() [2/3]

template<typename T >
Property & Qx::Property< T >::operator= ( Property< T > && other)
inlinenoexcept

Move assigns other to this.

◆ operator=() [3/3]

template<typename T >
Property & Qx::Property< T >::operator= ( T && newValue)
inline

Assigns newValue to this property and returns a reference to this property.

◆ setValueBypassingBindings()

template<typename T >
void Qx::Property< T >::setValueBypassingBindings ( T && v)
inlineoverridevirtual

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.

Note
Using this method will bypass any potential binding registered for this property.

Implements Qx::AbstractBindableProperty< T >.

◆ valueBypassingBindings()

template<typename T >
const T & Qx::Property< T >::valueBypassingBindings ( ) const
inlineoverridevirtual

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.

Note
Using this method will not register the property access with any currently executing binding.

Implements Qx::AbstractBindableProperty< T >.


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