3#include <AUI/Common/detail/property.h>
51 using GetterReturnT =
decltype(std::invoke(
get,
base));
52 using Underlying = std::decay_t<GetterReturnT>;
75 template <aui::convertible_to<Underlying> U>
77 std::invoke(
set, *
const_cast<Model*
>(
base), std::forward<U>(u));
82 GetterReturnT value() const noexcept {
87 GetterReturnT operator*() const noexcept {
92 const Underlying* operator->() const noexcept {
96 [[nodiscard]]
operator GetterReturnT() const noexcept {
return std::invoke(
get,
base); }
99 M* boundObject()
const {
100 return const_cast<M*
>(
base);
106 template <aui::invocable<const Underlying&> Projection>
109 return aui::detail::property::makeReadonlyProjection(std::move(*
this), std::forward<Projection>(projection));
119 auto biProjected(ProjectionRead&& projectionRead, ProjectionWrite&& projectionWrite)
noexcept {
120 return aui::detail::property::makeBidirectionalProjection(
121 std::move(*
this), std::forward<ProjectionRead>(projectionRead),
122 std::forward<ProjectionWrite>(projectionWrite));
128 template <aui::detail::property::ProjectionB
idirectional<Underlying> Projection>
131 return aui::detail::property::makeBidirectionalProjection(std::move(*
this), projectionBidirectional);
138 return { std::move(*
this) };
145 if (
changed.hasOutgoingConnections()) {
156 auto assignment() noexcept {
157 return aui::detail::property::makeAssignment(std::move(*
this));
170 using Underlying = std::decay_t<typename Property::Underlying>;
171 PropertyModifier(Property owner): mOwner(std::move(owner)), mCopyOfValue(*mOwner) {}
172 ~PropertyModifier() {
173 mOwner = std::move(mCopyOfValue);
177 Underlying& value()
const noexcept {
182 Underlying* operator->()
const noexcept {
188 mutable Underlying mCopyOfValue;
A base object class.
Definition AObject.h:39
Temporary transparent object that gains write access to underlying property's value,...
Definition PropertyModifier.h:26
Invokable concept.
Definition concepts.h:37
ASignal< Args... > emits
A signal declaration.
Definition ASignal.h:577
#define emit
emits the specified signal in context of this object.
Definition AObject.h:344
Property implementation to use with custom getter/setter.
Definition APropertyDef.h:23
void notify()
Notify observers that a change was occurred (no preconditions).
Definition APropertyDef.h:144
const M * base
AObject which this property belongs to.
Definition APropertyDef.h:27
Getter get
Getter. Can be pointer-to-member(function or field) or lambda.
Definition APropertyDef.h:33
aui::PropertyModifier< APropertyDef > writeScope() noexcept
Definition APropertyDef.h:137
Setter set
Setter. Can be pointer-to-member(function or field) or lambda.
Definition APropertyDef.h:50
auto biProjected(ProjectionRead &&projectionRead, ProjectionWrite &&projectionWrite) noexcept
Makes a bidirectional projection of this property.
Definition APropertyDef.h:119
const emits< SignalArg > & changed
Reference to underlying signal emitting on value changes.
Definition APropertyDef.h:57
auto biProjected(Projection &&projectionBidirectional) noexcept
Makes a bidirectional projection of this property (by a single aui::lambda_overloaded).
Definition APropertyDef.h:130
auto readProjected(Projection &&projection) noexcept
Makes a readonly projection of this property.
Definition APropertyDef.h:108