|
VR-Engage
2.3
|
This class provides a convenient interface for defining message handlers that can be connected to specific message types. It inherits from DtVreMessageDelegate and adds functionality for managing connections to message types, including tracking which message types the handler is connected to.
Most importantly, this class automatically disconnects all handler connections when it is destroyed, allowing for scope-managed handler cleanup, avoiding the need for explicit removeHandler calls. Define instances of this class as members of the delegate object to avoid accidental invokation of member handler methods for objects which have been destroyed.
#include <vreMessageManager.h>
Public Member Functions | |
| template<class OBJECT_T> | |
| DtVreMessageHandler (OBJECT_T *object, DtVreMessageResult(OBJECT_T::*method)(DtVreMessage *)) | |
| DtVreMessageHandler (DtVreMessageResult(*function)(DtVreMessage *)) | |
| template<typename Callable, typename = std::enable_if_t<!std::is_same<std::decay_t<Callable>, DtVreMessageHandler>::value>> | |
| DtVreMessageHandler (Callable &&callable) | |
| virtual | ~DtVreMessageHandler () |
| virtual void | connect (const std::string &messageType, DtVreMessageManager::HandlerPosition position=DtVreMessageManager::HandlerPosition::BACK) |
| virtual void | disconnect (const std::string &messageType) |
| virtual void | disconnectAll () |
| virtual bool | isConnected (const std::string &messageType) const |
Public Member Functions inherited from makVre::DtDelegate< DtVreMessageResult, DtVreMessage * > | |
| DtDelegate ()=default | |
| DtDelegate (DtVreMessageResult(*func)(Args...)) | |
| DtDelegate (T *object, Method method) | |
| DtDelegate (const T *object, Method method) | |
| DtDelegate (Callable &&callable) | |
| ~DtDelegate ()=default | |
| DtDelegate (const DtDelegate &other) | |
| DtDelegate (DtDelegate &&other) noexcept | |
| DtDelegate & | operator= (const DtDelegate &other) |
| DtDelegate & | operator= (DtDelegate &&other) noexcept |
| void | reset () noexcept |
| DtVreMessageResult | 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 |
| DtDelegate ()=default | |
| DtDelegate (DtVreMessageResult(*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 |
| DtVreMessageResult | 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 Types | |
| using | ConnectedList = std::set<std::string> |
Protected Attributes | |
| ConnectedList | myConnectedList |
Protected Attributes inherited from makVre::DtDelegate< DtVreMessageResult, DtVreMessage * > | |
| std::function< DtVreMessageResult(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 |
| std::function< DtVreMessageResult(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< DtVreMessageResult, DtVreMessage * > | |
| enum | DelegateType |
Static Public Member Functions inherited from makVre::DtDelegate< DtVreMessageResult, DtVreMessage * > | |
| 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 |
| 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 Member Functions inherited from makVre::DtDelegate< DtVreMessageResult, DtVreMessage * > | |
| void | computeHash () noexcept |
| void | resetHash () const noexcept |
| void | computeHash () noexcept |
| void | resetHash () const noexcept |
|
protected |
|
inline |
|
inline |
|
inline |
Constructor for callable handlers.
| Callable | The type of the callable that will handle messages |
| callable | The callable that will handle messages |
|
virtual |
Virtual destructor.
Disconnects all handler connections to ensure proper cleanup when the handler object is destroyed.
|
virtual |
Connects this handler to a specific message type.
| messageType | The type of message to connect to |
| position | The position in the handler list (front or back). Optional, defaults to back |
References makVre::DtVreMessageManager::BACK.
|
virtual |
Disconnects this handler from a specific message type.
|
virtual |
Disconnects this handler from all message types it is connected to.
|
virtual |
Checks if this handler is currently connected to a specific message type.
|
protected |
List of message types this handler is currently connected to.