|
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-specific callback. The new value of the connected attribute is passed to the callback function.
#include <attributeCallback.h>
Public Member Functions | |
| template<class OBJECT_T, typename METHOD_T> | |
| DtAttributeValueCallback (OBJECT_T *object, METHOD_T method) | |
| DtAttributeValueCallback (void(*func)(const T &)) | |
| DtAttributeValueCallback (void(*func)(T)) | |
| template<typename Callable, typename = std::enable_if_t<!std::is_same<std::decay_t<Callable>, DtAttributeValueCallback>::value>> | |
| DtAttributeValueCallback (Callable &&callable) | |
| virtual | ~DtAttributeValueCallback () override |
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, T > | |
| 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, T > | |
| void | computeHash () noexcept |
| void | resetHash () const noexcept |
Additional Inherited Members | |
Public Types inherited from makVre::DtDelegate< void, T > | |
| enum | DelegateType |
Static Public Member Functions inherited from makVre::DtDelegate< void, T > | |
| 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> |
Protected Attributes inherited from makVre::DtAttributeCallbackBase | |
| AttributeList | myConnections |
Protected Attributes inherited from makVre::DtDelegate< void, T > | |
| 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 |
| makVre::DtAttributeValueCallback< T >::DtAttributeValueCallback | ( | OBJECT_T * | object, |
| METHOD_T | method ) |
Constructor for attribute callbacks using member functions.
| OBJECT_T | Type of the object containing the method |
| METHOD_T | Pattern of the callback function, should be one of: void(OBJECT_T::*method)(const T&) or void(OBJECT_T::*method)(T) |
| object | Pointer to the object containing the method |
| method | Method pointer to be called when an attribute changes |
Referenced by DtAttributeValueCallback().
| makVre::DtAttributeValueCallback< T >::DtAttributeValueCallback | ( | void(* | func )(const T &) | ) |
Constructor for attribute callbacks using static function.
| func | Pointer to function to be called when attribute changes |
| makVre::DtAttributeValueCallback< T >::DtAttributeValueCallback | ( | void(* | func )(T) | ) |
References DtAttributeValueCallback().
| makVre::DtAttributeValueCallback< T >::DtAttributeValueCallback | ( | Callable && | callable | ) |
Constructor for attribute callbacks using a callable (lambda, functor, etc.)
| Callable | Type of the callable object. Must be invocable with const T&. |
| callable | The callable to invoke when an attribute changes |
|
overridevirtual |
Virtual destructor.
Automatically disconnects from all connected attributes
|
overrideprotectedvirtual |
Delivers the typed attribute value to the registered callback function.
Retrieves the current value of the changed attribute as type T and passes it to the registered functor. Emits a warning if the attribute's runtime type does not match T.
| changedAttribute | Handle to the attribute whose value changed |
Implements makVre::DtAttributeCallbackBase.