TAttribute
- Module
- Arc
- Header
#include "Arc/Core/TAttribute.h"- Namespace
Arcf- Template
template<typename T>
Type aliases
| Alias | Description |
|---|---|
using GetterFunc = std::function<T()> |
Constructors
| Signature | Name | Description |
|---|---|---|
TAttribute() : m_value | TAttribute | |
TAttribute(const T& value) : m_value(value), m_isSet(true), m_isBound(false) | TAttribute | |
TAttribute(T&& value) : m_value(std::move(value)), m_isSet(true), m_isBound(fals… | TAttribute | |
template<typename F, typename = std::enable_if_t<std::is_invocable_r<T, F>::valu… | TAttribute | |
TAttribute(const TAttribute& other) : m_value(other.m_value), m_getter(other.m_g… | TAttribute | The owner belongs to the storage location, not to the value: copies never inherit it and assignment keeps the destination's owner, so the ubiquitous m_attr = args._Attr inside Construct cannot unhook it. |
TAttribute(TAttribute&& other) noexcept : m_value(std::move(other.m_value)), m_g… | TAttribute |
Public functions
| Returns | Name | Description |
|---|---|---|
m_isSet | ||
TAttribute& | operator= | |
TAttribute& | operator= | |
TAttribute | CreateLambda | |
T | Get | Get the value (evaluates lambda if bound) |
void | Set | Set a static value (unbinds any lambda) |
void | SetIfUnbound | The write a widget makes to its own attribute while the user edits it (a keystroke, a scrub, a toggle). |
void | Bind | |
bool | IsSet | True for a plain value as well as a binding |
bool | IsBound | |
void | SetOwner | |
AWidget* | GetOwner | |
bool | PollForChange | Re-evaluates a bound getter and reports whether the produced value differs from the one seen at the previous poll. |
bool | PollAndInvalidate | PollForChange plus owner invalidation. |
bool | PollAndInvalidatePaint | PollForChange plus a paint-only invalidation, for an attribute the body paints from but never measures against — a colour, a radius. |
operatorT |
Function details
TAttribute
TAttribute() : m_valueTAttribute
TAttribute(const T& value) : m_value(value), m_isSet(true), m_isBound(false)TAttribute
TAttribute(T&& value) : m_value(std::move(value)), m_isSet(true), m_isBound(false)TAttribute
template<typename F, typename = std::enable_if_t<std::is_invocable_r<T, F>::value && !std::is_same<std::decay_t<F>, TAttribute<T>>::value>> TAttribute(F&& getter) : m_getter(std::forward<F>(getter)), m_isSet(true), m_isBound(true)TAttribute
TAttribute(const TAttribute& other) : m_value(other.m_value), m_getter(other.m_getter), m_isSet(other.m_isSet), m_isBound(other.m_isBound)The owner belongs to the storage location, not to the value: copies never inherit it and assignment keeps the destination's owner, so the ubiquitous m_attr = args._Attr inside Construct cannot unhook it.
TAttribute
TAttribute(TAttribute&& other) noexcept : m_value(std::move(other.m_value)), m_getter(std::move(other.m_getter)), m_isSet(other.m_isSet), m_isBound(other.m_isBound)m_isSet
m_isSet(false), m_isBound(false)operator=
TAttribute& operator=(const TAttribute& other)operator=
TAttribute& operator=(TAttribute&& other) noexceptCreateLambda
static TAttribute CreateLambda(GetterFunc getter)Get
T Get() constGet the value (evaluates lambda if bound)
Set
void Set(const T& value)Set a static value (unbinds any lambda)
SetIfUnbound
void SetIfUnbound(const T& value)The write a widget makes to its own attribute while the user edits it (a keystroke, a scrub, a toggle). A bound attribute belongs to whoever bound it — they hear the edit through the widget's change delegate and the getter reports the result — so the write is skipped instead of replacing the getter with a frozen copy. Using Set here cut the details panel's live binding on the first edit.
Bind
void Bind(GetterFunc getter)IsSet
bool IsSet() constTrue for a plain value as well as a binding
IsBound
bool IsBound() constSetOwner
void SetOwner(AWidget* owner)GetOwner
AWidget* GetOwner() constPollForChange
bool PollForChange()Re-evaluates a bound getter and reports whether the produced value differs from the one seen at the previous poll. A T without operator== always reports a change, so a bound attribute can never silently stop updating just because its type is not comparable.
PollAndInvalidate
bool PollAndInvalidate()PollForChange plus owner invalidation. Returns true when it fired.
PollAndInvalidatePaint
bool PollAndInvalidatePaint()PollForChange plus a paint-only invalidation, for an attribute the body paints from but never measures against — a colour, a radius.
operatorT
operator T() const