CoreComponents 3.0.0
A Modern C++ Toolkit
Loading...
Searching...
No Matches
Property< T > Class Template Reference

Property bindings More...

#include <cc/Property>

Public Member Functions

 Property ()
 Create property with default value (T{})
 
 Property (const T &b)
 Create property with initial value b.
 
 Property (std::initializer_list< T > b)
 Create property with initial value b.
 
 Property (Function< T()> &&f)
 Create property with defining function f.
 
 Property (const Property &b)
 
 Property (Property *b)
 Create an alias of property b.
 
Propertyoperator= (const Property &b)
 Assign value of (and break prior bindings)
 
 Property (Property &&b)
 
Propertyoperator= (Property &&b)
 
 ~Property ()
 Cleanup: disconnect all bindings and listeners.
 
void define (Function< T()> &&f)
 Set a new defining function f
 
void operator() (const T &b)
 Assign a new value b (and break prior bindings)
 
void operator() (Function< T()> &&f)
 Set a new defining function f
 
void restrict (Function< bool(T &, T)> &&g)
 Setup restrictor function g The restrictor gets the new and the old value passed.
 
void onChanged (Function< void()> &&f) const
 Register function f to be called when the property value changes.
 
bool readFrom (const String &text)
 Read value from text.
 
operator() () const
 Evaluate current property value.
 
 operator T () const
 Evaluate current property value.
 
Propertyoperator= (const T &b)
 Assign a new value b (and break prior bindings)
 
template<class T2 >
Propertyoperator= (const T2 &b)
 Assign a new value b (and break prior bindings)
 
template<class T2 >
Propertyoperator+= (const T2 &b)
 Increment the current value by b (and break prior bindings)
 
template<class T2 >
Propertyoperator-= (const T2 &b)
 Decrement the current value by b (and break prior bindings)
 
template<class T2 >
Propertyoperator*= (const T2 &b)
 Multiply the current value by b (and break prior bindings)
 
template<class T2 >
Propertyoperator/= (const T2 &b)
 Divide the current value by b (and break prior bindings)
 
template<class T2 >
Propertyoperator<<= (const T2 &b)
 Shift left the current value by b (and break prior bindings)
 
template<class T2 >
Propertyoperator>>= (const T2 &b)
 Shift right the current value by b (and break prior bindings)
 
Propertyoperator++ ()
 Prefix increment operator: Add 1 to the current value and return the new value
 
Propertyoperator-- ()
 Prefix decrement operator: Subtract 1 from the current value and return the new value
 
operator++ (int)
 Postfix increment operator: Add 1 to the current value and return the old value.
 
T & operator-- (int)
 Postfix decrement operator: Subtract 1 from the current value and return the old value.
 

Detailed Description

template<class T>
class cc::Property< T >

Property bindings

Template Parameters
TValue type

Constructor & Destructor Documentation

◆ Property() [1/5]

template<class T >
Property ( )

Create property with default value (T{})

◆ Property() [2/5]

template<class T >
Property ( const T & b)

Create property with initial value b.

◆ Property() [3/5]

template<class T >
Property ( std::initializer_list< T > b)

Create property with initial value b.

Todo
improve list initialization

◆ Property() [4/5]

template<class T >
Property ( Function< T()> && f)
explicit

Create property with defining function f.

◆ Property() [5/5]

template<class T >
Property ( Property< T > * b)
explicit

Create an alias of property b.

◆ ~Property()

template<class T >
~Property ( )

Cleanup: disconnect all bindings and listeners.

Member Function Documentation

◆ operator=() [1/3]

template<class T >
Property & operator= ( const Property< T > & b)

Assign value of (and break prior bindings)

◆ define()

template<class T >
void define ( Function< T()> && f)

Set a new defining function f

◆ operator()() [1/3]

template<class T >
void operator() ( const T & b)

Assign a new value b (and break prior bindings)

◆ operator()() [2/3]

template<class T >
void operator() ( Function< T()> && f)

Set a new defining function f

◆ restrict()

template<class T >
void restrict ( Function< bool(T &, T)> && g)

Setup restrictor function g The restrictor gets the new and the old value passed.

It returns true if the value change is allowed to take place. The restrictor function can also modify the new value.

◆ onChanged()

template<class T >
void onChanged ( Function< void()> && f) const

Register function f to be called when the property value changes.

◆ readFrom()

template<class T >
bool readFrom ( const String & text)

Read value from text.

◆ operator()() [3/3]

template<class T >
T operator() ( ) const

Evaluate current property value.

◆ operator T()

template<class T >
operator T ( ) const

Evaluate current property value.

◆ operator=() [2/3]

template<class T >
Property & operator= ( const T & b)

Assign a new value b (and break prior bindings)

◆ operator=() [3/3]

template<class T >
template<class T2 >
Property & operator= ( const T2 & b)

Assign a new value b (and break prior bindings)

Template Parameters
T2Value type

◆ operator+=()

template<class T >
template<class T2 >
Property & operator+= ( const T2 & b)

Increment the current value by b (and break prior bindings)

Template Parameters
T2Delta type

◆ operator-=()

template<class T >
template<class T2 >
Property & operator-= ( const T2 & b)

Decrement the current value by b (and break prior bindings)

Template Parameters
T2Delta type

◆ operator*=()

template<class T >
template<class T2 >
Property & operator*= ( const T2 & b)

Multiply the current value by b (and break prior bindings)

Template Parameters
T2Multiplication factor type

◆ operator/=()

template<class T >
template<class T2 >
Property & operator/= ( const T2 & b)

Divide the current value by b (and break prior bindings)

Template Parameters
T2Divisor type

◆ operator<<=()

template<class T >
template<class T2 >
Property & operator<<= ( const T2 & b)

Shift left the current value by b (and break prior bindings)

Template Parameters
T2Shift distance type

◆ operator>>=()

template<class T >
template<class T2 >
Property & operator>>= ( const T2 & b)

Shift right the current value by b (and break prior bindings)

Template Parameters
T2Shift distance type

◆ operator++() [1/2]

template<class T >
Property & operator++ ( )

Prefix increment operator: Add 1 to the current value and return the new value

◆ operator--() [1/2]

template<class T >
Property & operator-- ( )

Prefix decrement operator: Subtract 1 from the current value and return the new value

◆ operator++() [2/2]

template<class T >
T operator++ ( int )

Postfix increment operator: Add 1 to the current value and return the old value.

◆ operator--() [2/2]

template<class T >
T & operator-- ( int )

Postfix decrement operator: Subtract 1 from the current value and return the old value.