File include/brisk/core/Binding.hpp
¶
Callbacks
class¶
template <typename... Args> Callbacks
BindingAddress
class¶
BindingAddress
toBindingAddress
function¶
template <typename T>
constexpr BindingAddress
toBindingAddress(const T *value) noexcept
Converts a pointer of type T to a BindingAddress.
This function creates a BindingAddress that encompasses the memory range
of the specified pointer, allowing for easier management of variable
bindings in a property-like system.
Template param T
The type of the value being pointed to.
Param value
A pointer to the value.
Returns A BindingAddress representing the memory range of the value.
staticBinding
variable¶
inline const Empty staticBinding
A special object for static binding.
staticBindingAddress
variable¶
inline const constinit BindingAddress staticBindingAddress =
toBindingAddress(&staticBinding)
The BindingAddress for the static binding object.
BindingAddresses
typedef¶
BindingAddresses = SmallVector<BindingAddress, 1>
A collection of BindingAddresses.
Value
class¶
template <typename T> Value
Generic Value structure for property management.
The Value class allows for both read and write access to properties,
enabling a more dynamic approach to property handling.
Template param T
The type of the value contained within the Value.
TriggerArgs
class (Internal::TriggerArgs
)¶
template <typename... Args> TriggerArgs
TriggerArgs
template <typename Arg> TriggerArgs
Trigger
class¶
template <typename... Args> Trigger
ValueArgumentImpl
class (Internal::ValueArgumentImpl
)¶
template <typename T> ValueArgumentImpl
template <typename... Args> ValueArgumentImpl
PropertyLike
concept¶
template <typename T>
concept PropertyLike =
requires(T t, const T ct, typename T::ValueType v)
Concept that checks if a type behaves like a property.
Template param T
The type to check.
Value
class¶
template <typename T> Value
Generic Value structure for property management.
The Value class allows for both read and write access to properties,
enabling a more dynamic approach to property handling.
Template param T
The type of the value contained within the Value.
template <typename T> Value
Generic Value structure for property management.
The Value class allows for both read and write access to properties,
enabling a more dynamic approach to property handling.
Template param T
The type of the value contained within the Value.
Value<T>
function (Value::Value<T>
)¶
constexpr Value() noexcept : m_get
Default constructor.
template <PropertyLike U>
[[nodiscard]] explicit Value(U *property)
: Value(Internal::asValue(*property))
Constructs a Value from a PropertyLike type.
Template param U
The property type.
Param property
Pointer to the property.
empty
function (Value::empty
)¶
bool empty() const noexcept
Checks whether the value is empty
constant
function (Value::constant
)¶
static Value constant(T constant)
Creates a Value that holds a constant value.
Param constant
The constant value to hold.
Returns A Value representing the constant.
readOnly
function (Value::readOnly
)¶
Value readOnly() &&
Returns a read-only version of this Value.
Returns A read-only Value instance.
Value readOnly() const &
Returns read-only version of Value
mutableValue
function (Value::mutableValue
)¶
static Value mutableValue(T initialValue)
Returns mutable Value that initially holds the given value.
Param initialValue
value
Operand
class (Value::Operand
)¶
Operand
Value
class (Value::Value
)¶
template <typename U> Value
toString
function¶
template <typename T>
Value<std::string> toString(Value<T> value, std::string fmtstr = "
Converts a Value of any type to a Value of type std::string with optional formatting.
Template param T
The type of the input Value.
Param value
The Value to convert.
Param fmtstr
Optional format string (default: "{}").
Returns Value<std::string> The formatted string representation of the input Value.
int m_num = 42;
// Create a `Text` widget that displays the text `"number: 42"` and updates dynamically
// when `m_num` changes.
rcnew Text{ text = toString(Value<int\>{ &m_num }, "number: {}") };
BindType
enum¶
enum class BindType : uint8_t
Specifies how listeners will be notified in response to a value change.
Immediate
enumerator (BindType::Immediate
)¶
Listeners will be notified immediately.
Deferred
enumerator (BindType::Deferred
)¶
Listeners will be notified via a target object queue.
BindingHandle
class¶
BindingHandle
Handle that allows manually disconnecting bound values.
operator bool
function (BindingHandle::operator bool
)¶
explicit operator bool() const noexcept
Checks if the handle is valid.
Returns True if the handle is valid, false otherwise.
generate
function (BindingHandle::generate
)¶
static uint64_t generate()
Generates a unique ID starting from 1.
Returns A new unique ID.
m_id
variable (BindingHandle::m_id
)¶
uint64_t m_id = 0
The unique identifier for the binding handle.
Listener
class¶
template <typename... Args> Listener
address
variable (Listener::address
)¶
BindingAddress address
The associated binding address.
BindDir
enum¶
enum BindDir : uint8_t
Specifies the binding direction (used for disconnecting values).
Dest
enumerator (BindDir::Dest
)¶
Value is a destination.
Src
enumerator (BindDir::Src
)¶
Value is a source.
Both
enumerator (BindDir::Both
)¶
Value is either a source or a destination.
Bindings
class¶
Bindings
Singleton class for binding values and notifying about changes.
This class provides mechanisms for connecting instances of Value
,
notifying about variable changes (including batch notifications),
and registering regions with associated queues.
Access the singleton instance via the bindings
global variable.
Thread safety All public methods are thread-safe and can be called from any thread.
connectBidir
function (Bindings::connectBidir
)¶
template <typename TDest, typename TSrc>
BindingHandle connectBidir(Value<TDest> dest, Value<TSrc> src, BindType type = BindType::Deferred,
bool updateNow = true, std::string_view destDesc =
Connects two values using bidirectional binding.
When src
changes, dest
is updated to match src
.
When dest
changes, src
is updated to match dest
.
The connection is automatically removed when either dest
or src
region is removed.
Template param TDest
The type of the destination value.
Template param TSrc
The type of the source value.
Param dest
The destination value.
Param src
The source value.
Param type
The binding type (Immediate or Deferred, default: Deferred).
Param updateNow
If true, immediately updates dest
with the current value of src
.
Param destDesc
Optional description for the destination value.
Param srcDesc
Optional description for the source value.
Returns BindingHandle A handle that allows manually disconnecting the binding.
connect
function (Bindings::connect
)¶
template <typename TDest, typename TSrc>
BindingHandle connect(Value<TDest> dest, Value<TSrc> src, BindType type = BindType::Deferred,
bool updateNow = true, std::string_view destDesc =
Connects two values using one-way binding.
When src
changes, dest
is updated to match src
.
The connection is automatically removed when either dest
or src
region is removed.
Template param TDest
The type of the destination value.
Template param TSrc
The type of the source value.
Param dest
The destination value.
Param src
The source value.
Param type
The binding type (Immediate or Deferred, default: Deferred).
Param updateNow
If true, immediately updates dest
with the current value of src
.
Param destDesc
Optional description for the destination value.
Param srcDesc
Optional description for the source value.
Returns BindingHandle A handle that allows manually disconnecting the binding.
disconnect
function (Bindings::disconnect
)¶
template <typename TDest, typename TSrc>
void disconnect(Value<TDest> dest, Value<TSrc> src)
Remove all bindings where the destination address matches dest
and
the source address matches src
.
Template param TDest
The type of the destination value.
Template param TSrc
The type of the source value.
Param dest
The destination value.
Param src
The source value.
template <typename T>
void disconnect(Value<T> val, BindDir dir)
Disconnects all bindings where the given value is either a source or destination.
Template param T
The type of the value.
Param val
The value to disconnect.
Param dir
The direction to disconnect (source, destination, or both).
void disconnect(BindingHandle handle)
Disconnects a binding using a previously saved handle.
Param handle
The handle representing the binding to be disconnected.
registerRegion
function (Bindings::registerRegion
)¶
void registerRegion(BindingAddress region,
RC<Scheduler> queue)
Registers a region with an associated queue.
The region must not be registered before calling this method.
Param region
The binding address representing the region.
Param queue
The scheduler queue associated with the region.
unregisterRegion
function (Bindings::unregisterRegion
)¶
void unregisterRegion(BindingAddress region)
Unregisters a previously registered region.
The region must have been previously registered using registerRegion
.
Param region
The binding address representing the region to unregister.
void unregisterRegion(const uint8_t *regionBegin)
Unregisters a previously registered region by its memory address.
The region must have been previously registered using registerRegion
.
Param regionBegin
Pointer to the beginning of the region to unregister.
notifyRange
function (Bindings::notifyRange
)¶
int notifyRange(BindingAddress range)
Notify that the variable has changed
This triggers update of all dependant values.
Param range
address range
Returns int Number of handlers called
notify
function (Bindings::notify
)¶
template <typename T> int notify(T *variable)
Notify that the variable has changed.
This triggers update of all dependant values.
Returns int Number of handlers called
AutoNotify
class (Bindings::AutoNotify
)¶
template <equality_comparable T> AutoNotify
Entry
class (Bindings::Entry
)¶
Entry
Region
class (Bindings::Region
)¶
Region
Entry
class (Bindings::Entry
)¶
Entry
BindingAddressCmp
class (Bindings::BindingAddressCmp
)¶
BindingAddressCmp
Region
class (Bindings::Region
)¶
Region
DeduceArgs
class (Internal::DeduceArgs
)¶
template <typename Fn> DeduceArgs
BindingRegistration
class¶
BindingRegistration
Automatically registers an object for binding.
This struct can be used as a field within a target object to enable binding registration. Example usage:
struct BindingEnabled {
std::string field;
BindingRegistration reg{ this, nullptr };
};
BindingRegistration
function (BindingRegistration::BindingRegistration
)¶
template <typename T>
BindingRegistration(const T *thiz, RC<Scheduler> queue)
: m_address(toBindingAddress(thiz).min())
Constructs a BindingRegistration for a given object and queue.
Template param T
Type of the object to register.
Param thiz
Pointer to the object being registered.
Param queue
Reference-counted pointer to the queue.
~BindingRegistration
function (BindingRegistration::~BindingRegistration
)¶
~BindingRegistration()
Destructor that unregisters the binding region.
BindingLifetime
class¶
BindingLifetime
Utility struct to link a callback to the lifetime of an associated object.
This struct ensures that a callback is automatically removed when the associated object is deleted.
The object pointed to by thiz
must reside within a registered memory range.
BindingLifetime
function (BindingLifetime::BindingLifetime
)¶
template <typename T>
constexpr BindingLifetime(const T *thiz) noexcept
: m_address(thiz)
Constructs a BindingLifetime for a specific object.
Template param T
Type of the object to associate with.
Param thiz
Pointer to the object whose lifetime is being tracked.
staticLifetime
variable¶
constinit const inline BindingLifetime staticLifetime
Static BindingLifetime instance for callbacks with no lifetime protection.
This can be used for callbacks that only access global or static variables.
lifetimeOf
function¶
template <typename T>
inline BindingLifetime lifetimeOf(T *thiz) noexcept
Constructs a BindingLifetime for a specific object to use in callback binding.
Template param T
Type of the object to associate with.
Param thiz
Pointer to the object whose lifetime is being tracked.
Returns A BindingLifetime instance for the given object.
operator|
function¶
template <typename Fn>
inline constexpr DeduceListener<Fn>
operator|(const BindingRegistration ®, Fn callback)
Combines a BindingRegistration with a callback to create a listener.
Template param Fn
Type of the callback function.
Param reg
The BindingRegistration instance providing the address.
Param callback
The callback function to associate.
Returns A deduced listener type combining the callback and registration address.
template <typename Fn>
inline constexpr DeduceListener<Fn>
operator|(const BindingLifetime <, Fn callback)
Combines a BindingLifetime with a callback to create a listener.
Template param Fn
Type of the callback function.
Param lt
The BindingLifetime instance providing the address.
Param callback
The callback function to associate.
Returns A deduced listener type combining the callback and lifetime address.
mutableValue
function¶
template <typename T>
[[nodiscard]] inline Value<T>
Value<T>::mutableValue(T initialValue)
Returns mutable Value that initially holds the given value.
Param initialValue
value
RegisteredValue
class¶
RegisteredValue
Property
class¶
template <typename Class, typename T,
auto std::type_identity_t<Class>::*field,
std::remove_const_t<T> (Class::*getter)() const =
nullptr,
void (Class::*setter)(std::remove_const_t<T>) =
nullptr,
auto changed = nullptr, bool notify = true>
Property
Dummy1
class (Internal::Dummy1
)¶
Dummy1
Object
class¶
Object
BindingObject
class¶
template <typename Derived,
PointerToScheduler auto scheduler =
static_cast<RC<Scheduler> *>(nullptr >
BindingObject
Auto-generated from sources, Revision , https://github.com/brisklib/brisk/blob//include/brisk/