| 
 AUI Framework
                         master
 
Cross-platform base for C++ UI apps 
 | 
Property implementation to use with custom getter/setter. More...
#include <AUI/Common/AProperty.h>
Public Types# | |
| using | Model = M | 
| using | GetterReturnT = decltype(std::invoke(get, base)) | 
| using | Underlying = std::decay_t<GetterReturnT> | 
Public Member Functions# | |
| APropertyDef (const M *base, Getter get, Setter set, const emits< SignalArg > &changed) | |
| template<aui::convertible_to< Underlying > U> | |
| APropertyDef & | operator= (U &&u) | 
| GetterReturnT | value () const noexcept | 
| GetterReturnT | operator* () const noexcept | 
| const Underlying * | operator-> () const noexcept | 
| operator GetterReturnT () const noexcept | |
| M * | boundObject () const | 
| template<aui::invocable< const Underlying & > Projection> | |
| auto | readProjected (Projection &&projection) noexcept | 
| Makes a readonly projection of this property.  | |
| template<aui::invocable< const Underlying & > ProjectionRead, aui::invocable< const std::invoke_result_t< ProjectionRead, Underlying > & > ProjectionWrite> | |
| auto | biProjected (ProjectionRead &&projectionRead, ProjectionWrite &&projectionWrite) noexcept | 
| Makes a bidirectional projection of this property.  | |
| template<aui::detail::property::ProjectionBidirectional< Underlying > Projection> | |
| auto | biProjected (Projection &&projectionBidirectional) noexcept | 
| Makes a bidirectional projection of this property (by a single aui::lambda_overloaded).  | |
| void | notify () | 
| Notify observers that a change was occurred (no preconditions).  | |
Signals and public fields# | |
| const M * | base | 
| AObject which this property belongs to.  | |
| Getter | get | 
| Getter. Can be pointer-to-member(function or field) or lambda.  | |
| Setter | set | 
| Setter. Can be pointer-to-member(function or field) or lambda.   | |
| const emits< SignalArg > & | changed | 
| Reference to underlying signal emitting on value changes.  | |
AObject. Most of AView's properties are defined this way.See property system for usage examples.
APropertyDef does not involve extra runtime overhead between assignment and getter/setter.
To declare a property with custom getter/setter, use APropertyDef template. APropertyDef-based property is defined by const member function as follows:
APropertyDef behaves like a class/struct function member:
(). We can't get rid of them, as APropertyDef is defined thanks to member function. In comparison to user->name, think of user->name() as the same kind of property except defining custom behaviour via function, hence the braces ().For the rest, APropertyDef is identical to AProperty including seamless interaction:
APropertyDef calls getter/setter instead of using += on your property directly. Equivalent code will be: The implicit conversions work the same way as with AProperty:
If it doesn't, simply put an asterisk:
 All property types offer .changed field which is a signal reporting value changes. Let's make little observer object for demonstration: 
The usage is close to AProperty: 
Code produces the following output:
Making connection to property directly instead of .changed: 
Code above produces the following output:
Subsequent changes to field would send updates as well:
Assignment operation above makes an additional line to output:
Whole program output when connecting to property directly:
| Setter APropertyDef< M, Getter, Setter, SignalArg >::set | 
The setter implementation typically emits changed signal. If it is, it must emit changes only if value is actually changed.