|
VR-Engage
2.3
|
This class provides a mechanism for registering callbacks that are triggered when attributes are changed. It maintains a list of connected attributes and manages the lifecycle of these connections.
This is a type-agnostic callback. It passes to the callback function an un-typed DtAttributeHandle representing the attribute which was changed. If includeChildren is set false (default), then this will be the same attribute to which the callback was connected. If includeChildren is set true, the changed attribute may also be any child of the connected attribute.
#include <attributeCallback.h>
Public Member Functions | |
| template<class OBJECT_T> | |
| DtAttributeChangeCallback (OBJECT_T *object, void(OBJECT_T::*method)(const DtAttributeHandle &), bool includeChildren=false) | |
| DtAttributeChangeCallback (void(*func)(const DtAttributeHandle &), bool includeChildren=false) | |
| template<typename Callable, typename = std::enable_if_t<!std::is_same<std::decay_t<Callable>, DtAttributeChangeCallback>::value>> | |
| DtAttributeChangeCallback (Callable &&callable, bool includeChildren=false) | |
| virtual | ~DtAttributeChangeCallback () override |
| virtual void | includeChildren (bool on) |
| virtual bool | includesChildren () const |
Public Member Functions inherited from makVre::DtAttributeCallbackBase | |
| DtAttributeCallbackBase () | |
| virtual | ~DtAttributeCallbackBase () |
| virtual void | connect (DtAttributeHandle attribute, bool invokeNowIfSet=false) |
| virtual void | disconnect (DtAttributeHandle attribute) |
| virtual void | disconnectAll () |
| virtual bool | isConnected (const DtAttributeHandle &attribute) const |
| virtual bool | hasConnection () const |
Public Member Functions inherited from makVre::DtDelegate< void, const DtAttributeHandle & > | |
| DtDelegate ()=default | |
| DtDelegate (void(*func)(Args...)) | |
| DtDelegate (T *object, Method method) | |
| DtDelegate (const T *object, Method method) | |
| DtDelegate (Callable &&callable) | |
| DtDelegate (const DtDelegate &other) | |
| DtDelegate (DtDelegate &&other) noexcept | |
| ~DtDelegate ()=default | |
| DtDelegate & | operator= (const DtDelegate &other) |
| DtDelegate & | operator= (DtDelegate &&other) noexcept |
| void | reset () noexcept |
| void | operator() (CallArgs &&... args) const |
| void | operator() (CallArgs &&... args) const |
| operator bool () const noexcept | |
| std::size_t | hash () const noexcept |
| bool | operator== (const DtDelegate &rhs) const noexcept |
| bool | operator!= (const DtDelegate &rhs) const noexcept |
| DelegateType | getType () const noexcept |
Protected Member Functions | |
| virtual void | invoke (const DtAttributeHandle &changedAttribute) const override |
Protected Member Functions inherited from makVre::DtDelegate< void, const DtAttributeHandle & > | |
| void | computeHash () noexcept |
| void | resetHash () const noexcept |
Protected Attributes | |
| bool | myIncludeChildren |
Protected Attributes inherited from makVre::DtAttributeCallbackBase | |
| AttributeList | myConnections |
Protected Attributes inherited from makVre::DtDelegate< void, const DtAttributeHandle & > | |
| std::function< void(Args...)> | myFunction |
| DelegateType | myType |
| std::size_t | myObjectHash |
| std::size_t | myStaticFuncHash |
| std::size_t | myMethodHash |
| std::size_t | myLambdaHash |
| std::size_t | myHash |
| bool | myHashComputed |
Additional Inherited Members | |
Public Types inherited from makVre::DtDelegate< void, const DtAttributeHandle & > | |
| enum | DelegateType |
Static Public Member Functions inherited from makVre::DtDelegate< void, const DtAttributeHandle & > | |
| static std::size_t | hashMethodPtr (const Method &method) noexcept |
| static std::size_t | hashPtr (PtrType ptr) noexcept |
| static std::size_t | hashLambda (const Callable &callable) noexcept |
Protected Types inherited from makVre::DtAttributeCallbackBase | |
| using | AttributeList = std::list<DtAttributeHandle> |
| makVre::DtAttributeChangeCallback::DtAttributeChangeCallback | ( | OBJECT_T * | object, |
| void(OBJECT_T::* | method )(const DtAttributeHandle &), | ||
| bool | includeChildren = false ) |
Constructor for attribute callbacks using member functions.
| OBJECT_T | Type of the object containing the method |
| object | Pointer to the object containing the method |
| method | Method pointer to be called when an attribute changes |
| includeChildren | If true, also invokes the callback for changes to descendants of connected attributes (default: false) |
References includeChildren().
Referenced by DtAttributeChangeCallback().
| makVre::DtAttributeChangeCallback::DtAttributeChangeCallback | ( | void(* | func )(const DtAttributeHandle &), |
| bool | includeChildren = false ) |
Constructor for attribute callbacks using static function.
| func | Pointer to function to be called when attribute changes |
| includeChildren | If true, also invokes the callback for changes to descendants of connected attributes (default: false) |
References DtAttributeChangeCallback(), and includeChildren().
| makVre::DtAttributeChangeCallback::DtAttributeChangeCallback | ( | Callable && | callable, |
| bool | includeChildren = false ) |
Constructor for attribute callbacks using a callable (lambda, functor, etc.)
| Callable | Type of the callable object. Must be invocable with const DtAttributeHandle&. |
| callable | The callable to invoke when an attribute changes |
| includeChildren | If true, also invokes the callback for changes to descendants of connected attributes (default: false) |
References includeChildren().
|
overridevirtual |
Virtual destructor.
Automatically disconnects from all connected attributes
|
virtual |
Set whether this callback should also be invoked for any change to any child attribute.
| on | Set true for callbacks on change to any child. Set false for callbacks only to the connected attribute. Default is false. |
Check current state with includesChildren()
Referenced by DtAttributeChangeCallback(), DtAttributeChangeCallback(), and DtAttributeChangeCallback().
|
virtual |
Get whether this callback is set to trigger on changes to child attributes.
Set state with includeChildren(bool on)
|
overrideprotectedvirtual |
Delivers the change notification to the registered callback function.
If the changed attribute is the directly connected attribute, the callback is invoked immediately. If includeChildren() is true, the callback is also invoked when the changed attribute is a descendant of a connected attribute.
| changedAttribute | Handle to the attribute whose value changed |
Implements makVre::DtAttributeCallbackBase.
|
protected |
Defines whether this callback is also invoked for any changes to children of the connected attribute.