DtAttributeCallbackManager simplifies callback lifetime management by owning all registered callbacks internally. Each attribute path maps to exactly one callback; registering a new callback for an attribute that already has one replaces the old entry. All connections are automatically cleaned up when the manager is destroyed.
#include <attributeCallback.h>
|
| | DtAttributeCallbackManager () |
| |
| virtual | ~DtAttributeCallbackManager () |
| |
| | DtAttributeCallbackManager (const DtAttributeCallbackManager &)=delete |
| |
| DtAttributeCallbackManager & | operator= (const DtAttributeCallbackManager &)=delete |
| |
| template<class OBJECT_T> |
| void | connect (DtAttributeHandle attr, OBJECT_T *object, void(OBJECT_T::*method)(const DtAttributeHandle &), bool includeChildren=false, bool invokeNowIfSet=false) |
| |
| void | connect (DtAttributeHandle attr, void(*func)(const DtAttributeHandle &), bool includeChildren=false, bool invokeNowIfSet=false) |
| |
| template<class OBJECT_T, typename ATTRIBUTE_T> |
| void | connect (DtAttributeHandle attr, OBJECT_T *object, void(OBJECT_T::*method)(const ATTRIBUTE_T &), bool invokeNowIfSet=false) |
| |
| template<class OBJECT_T, typename ATTRIBUTE_T> |
| void | connect (DtAttributeHandle attr, OBJECT_T *object, void(OBJECT_T::*method)(ATTRIBUTE_T), bool invokeNowIfSet=false) |
| |
| template<typename ATTRIBUTE_T> |
| void | connect (DtAttributeHandle attr, void(*func)(const ATTRIBUTE_T &), bool invokeNowIfSet=false) |
| |
| template<typename ATTRIBUTE_T> |
| void | connect (DtAttributeHandle attr, void(*func)(ATTRIBUTE_T), bool invokeNowIfSet=false) |
| |
| template<typename Callable> |
| void | connect (DtAttributeHandle attr, Callable &&callable, bool includeChildren=false, bool invokeNowIfSet=false) |
| |
| template<typename ATTRIBUTE_T, typename Callable> |
| void | connect (DtAttributeHandle attr, Callable &&callable, bool invokeNowIfSet=false) |
| |
| bool | isConnected (DtAttributeHandle attr) const |
| |
| DtAttributeCallbackBase * | connection (DtAttributeHandle attr) |
| |
| void | disconnect (DtAttributeHandle attr) |
| |
| void | disconnectAll () |
| |
◆ DtAttributeCallbackManager() [1/2]
| makVre::DtAttributeCallbackManager::DtAttributeCallbackManager |
( |
| ) |
|
◆ ~DtAttributeCallbackManager()
| virtual makVre::DtAttributeCallbackManager::~DtAttributeCallbackManager |
( |
| ) |
|
|
virtual |
Virtual destructor.
Destroys all owned callbacks, which disconnects them from their attributes.
◆ DtAttributeCallbackManager() [2/2]
◆ operator=()
◆ connect() [1/8]
template<class OBJECT_T>
| void makVre::DtAttributeCallbackManager::connect |
( |
DtAttributeHandle | attr, |
|
|
OBJECT_T * | object, |
|
|
void(OBJECT_T::* | method )(const DtAttributeHandle &), |
|
|
bool | includeChildren = false, |
|
|
bool | invokeNowIfSet = false ) |
Connects a member function callback for untyped attribute changes.
The callback receives a DtAttributeHandle whenever the attribute at attr changes.
- Template Parameters
-
| OBJECT_T | Type of the object that owns the method |
- Parameters
-
| attr | The attribute to observe |
| object | Pointer to the owning object |
| method | Member function to invoke on change |
| includeChildren | If true, also observes changes to descendants of attr (default: false) |
| invokeNowIfSet | If true, invokes the callback immediately when connecting if attr already has a value (default: false) |
◆ connect() [2/8]
| void makVre::DtAttributeCallbackManager::connect |
( |
DtAttributeHandle | attr, |
|
|
void(* | func )(const DtAttributeHandle &), |
|
|
bool | includeChildren = false, |
|
|
bool | invokeNowIfSet = false ) |
Connects a free-function callback for untyped attribute changes.
- Parameters
-
| attr | The attribute to observe |
| func | Free function to invoke when the attribute changes |
| includeChildren | If true, also observes changes to descendants of attr (default: false) |
| invokeNowIfSet | If true, invokes the callback immediately when connecting if attr already has a value (default: false) |
◆ connect() [3/8]
template<class OBJECT_T, typename ATTRIBUTE_T>
| void makVre::DtAttributeCallbackManager::connect |
( |
DtAttributeHandle | attr, |
|
|
OBJECT_T * | object, |
|
|
void(OBJECT_T::* | method )(const ATTRIBUTE_T &), |
|
|
bool | invokeNowIfSet = false ) |
Connects a member function callback receiving the new attribute value by const reference.
- Template Parameters
-
| OBJECT_T | Type of the object that owns the method |
| ATTRIBUTE_T | Value type of the attribute |
- Parameters
-
| attr | The attribute to observe |
| object | Pointer to the owning object |
| method | Member function invoked with the new value as const ATTRIBUTE_T& |
| invokeNowIfSet | If true, invokes the callback immediately when connecting if attr already has a value (default: false) |
◆ connect() [4/8]
template<class OBJECT_T, typename ATTRIBUTE_T>
| void makVre::DtAttributeCallbackManager::connect |
( |
DtAttributeHandle | attr, |
|
|
OBJECT_T * | object, |
|
|
void(OBJECT_T::* | method )(ATTRIBUTE_T), |
|
|
bool | invokeNowIfSet = false ) |
Connects a member function callback receiving the new attribute value by value.
- Template Parameters
-
| OBJECT_T | Type of the object that owns the method |
| ATTRIBUTE_T | Value type of the attribute |
- Parameters
-
| attr | The attribute to observe |
| object | Pointer to the owning object |
| method | Member function invoked with the new value as ATTRIBUTE_T |
| invokeNowIfSet | If true, invokes the callback immediately when connecting if attr already has a value (default: false) |
◆ connect() [5/8]
template<typename ATTRIBUTE_T>
| void makVre::DtAttributeCallbackManager::connect |
( |
DtAttributeHandle | attr, |
|
|
void(* | func )(const ATTRIBUTE_T &), |
|
|
bool | invokeNowIfSet = false ) |
Connects a free-function callback receiving the new attribute value by const reference.
- Template Parameters
-
| ATTRIBUTE_T | Value type of the attribute |
- Parameters
-
| attr | The attribute to observe |
| func | Free function invoked with the new value as const ATTRIBUTE_T& |
| invokeNowIfSet | If true, invokes the callback immediately when connecting if attr already has a value (default: false) |
◆ connect() [6/8]
template<typename ATTRIBUTE_T>
| void makVre::DtAttributeCallbackManager::connect |
( |
DtAttributeHandle | attr, |
|
|
void(* | func )(ATTRIBUTE_T), |
|
|
bool | invokeNowIfSet = false ) |
Connects a free-function callback receiving the new attribute value by value.
- Template Parameters
-
| ATTRIBUTE_T | Value type of the attribute |
- Parameters
-
| attr | The attribute to observe |
| func | Free function invoked with the new value as ATTRIBUTE_T |
| invokeNowIfSet | If true, invokes the callback immediately when connecting if attr already has a value (default: false) |
◆ connect() [7/8]
template<typename Callable>
| void makVre::DtAttributeCallbackManager::connect |
( |
DtAttributeHandle | attr, |
|
|
Callable && | callable, |
|
|
bool | includeChildren = false, |
|
|
bool | invokeNowIfSet = false ) |
Connects a callable (lambda, functor) for untyped attribute changes.
The callback receives a DtAttributeHandle whenever the attribute at attr changes.
- Template Parameters
-
| Callable | Type of the callable object |
- Parameters
-
| attr | The attribute to observe |
| callable | Callable to invoke on change; must accept const DtAttributeHandle& |
| includeChildren | If true, also observes changes to descendants of attr (default: false) |
| invokeNowIfSet | If true, invokes the callback immediately when connecting if attr already has a value (default: false) |
◆ connect() [8/8]
template<typename ATTRIBUTE_T, typename Callable>
| void makVre::DtAttributeCallbackManager::connect |
( |
DtAttributeHandle | attr, |
|
|
Callable && | callable, |
|
|
bool | invokeNowIfSet = false ) |
Connects a callable (lambda, functor) for typed attribute value changes.
The callback receives the new value of type ATTRIBUTE_T when the attribute changes. The value type must be explicitly specified, e.g. connect<int>(attr, callable).
- Template Parameters
-
| ATTRIBUTE_T | Value type of the attribute |
| Callable | Type of the callable object |
- Parameters
-
| attr | The attribute to observe |
| callable | Callable to invoke with the new attribute value |
| invokeNowIfSet | If true, invokes the callback immediately when connecting if attr already has a value (default: false) |
◆ isConnected()
Checks whether a callback is currently registered for the given attribute.
- Parameters
-
| attr | The attribute to check |
- Returns
- True if a callback is registered and connected for
attr
◆ connection()
Returns a non-owning pointer to the callback registered for the given attribute.
- Parameters
-
| attr | The attribute whose callback is requested |
- Returns
- Pointer to the registered callback, or nullptr if none is registered
◆ disconnect()
Removes and destroys the callback registered for the given attribute.
- Parameters
-
| attr | The attribute whose callback should be removed |
◆ disconnectAll()
| void makVre::DtAttributeCallbackManager::disconnectAll |
( |
| ) |
|
Removes and destroys all registered callbacks.
◆ myCallbackMap
Owns all registered callbacks, keyed by the full attribute path.
The documentation for this class was generated from the following file: