VR-Engage  2.3
Loading...
Searching...
No Matches
makVre::DtVreMessageHandlerGroup Class Reference

Detailed Description

Allows for managing the lifetime of multiple handler connections using a single manager instance.

#include <vreMessageManager.h>

Public Member Functions

 DtVreMessageHandlerGroup ()
 
virtual ~DtVreMessageHandlerGroup ()
 
template<class OBJECT_T>
void connect (const std::string &messageType, OBJECT_T *object, DtVreMessageResult(OBJECT_T::*method)(DtVreMessage *), DtVreMessageManager::HandlerPosition position=DtVreMessageManager::HandlerPosition::BACK)
 
void connect (const std::string &messageType, DtVreMessageResult(*function)(DtVreMessage *), DtVreMessageManager::HandlerPosition position=DtVreMessageManager::HandlerPosition::BACK)
 
template<typename Callable>
void connect (const std::string &messageType, Callable &&callable, DtVreMessageManager::HandlerPosition position=DtVreMessageManager::HandlerPosition::BACK)
 
bool isConnected (const std::string &messageType) const
 
void disconnect (const std::string &messageType)
 
void disconnectAll ()
 

Protected Attributes

std::map< std::string, std::shared_ptr< DtVreMessageHandler > > myConnectors
 

Constructor & Destructor Documentation

◆ DtVreMessageHandlerGroup()

makVre::DtVreMessageHandlerGroup::DtVreMessageHandlerGroup ( )
inline

◆ ~DtVreMessageHandlerGroup()

virtual makVre::DtVreMessageHandlerGroup::~DtVreMessageHandlerGroup ( )
inlinevirtual

Member Function Documentation

◆ connect() [1/3]

template<class OBJECT_T>
void makVre::DtVreMessageHandlerGroup::connect ( const std::string & messageType,
OBJECT_T * object,
DtVreMessageResult(OBJECT_T::* method )(DtVreMessage *),
DtVreMessageManager::HandlerPosition position = DtVreMessageManager::HandlerPosition::BACK )
inline

Connects a handler method to a specific message type.

Creates a new Connector instance to manage the lifetime of the connection. The Connector is added to the manager's map and will automatically disconnect when the manager instance is destroyed, so there is no need for explicit disconnect calls, unless it is necessary to disconnect the handler before the manager is destroyed.

Template Parameters
OBJECT_TThe type of the object that will handle messages
Parameters
messageTypeThe type of message to connect to
objectPointer to the object that will handle messages
methodPointer to the member function that will handle messages
positionThe position in the handler list (front or back). Optional, defaults to back

References makVre::DtVreMessageManager::BACK, and myConnectors.

◆ connect() [2/3]

void makVre::DtVreMessageHandlerGroup::connect ( const std::string & messageType,
DtVreMessageResult(* function )(DtVreMessage *),
DtVreMessageManager::HandlerPosition position = DtVreMessageManager::HandlerPosition::BACK )
inline

Connects a free function or static member function to a specific message type.

Creates a new Connector instance to manage the lifetime of the connection. The Connector is added to the manager's map and will automatically disconnect when the manager instance is destroyed, so there is no need for explicit disconnect calls, unless it is necessary to disconnect the handler before the manager is destroyed.

Parameters
messageTypeThe type of message to connect to
functionPointer to the function that will handle messages
positionThe position in the handler list (front or back). Optional, defaults to back

References makVre::DtVreMessageManager::BACK, and myConnectors.

◆ connect() [3/3]

template<typename Callable>
void makVre::DtVreMessageHandlerGroup::connect ( const std::string & messageType,
Callable && callable,
DtVreMessageManager::HandlerPosition position = DtVreMessageManager::HandlerPosition::BACK )
inline

Connects a callable handler to a specific message type.

Template Parameters
CallableThe type of the callable that will handle messages
Parameters
messageTypeThe type of message to connect to
callableThe callable that will handle messages
positionThe position in the handler list (front or back). Optional, defaults to back

References makVre::DtVreMessageManager::BACK, and myConnectors.

◆ isConnected()

bool makVre::DtVreMessageHandlerGroup::isConnected ( const std::string & messageType) const
inline

Checks if a handler is currently connected for a specific message type.

Parameters
messageTypeThe type of message to check
Returns
True if a handler is currently connected to the specified message type, false otherwise

References myConnectors.

◆ disconnect()

void makVre::DtVreMessageHandlerGroup::disconnect ( const std::string & messageType)
inline

Disconnects a handler from a specific message type.

Parameters
messageTypeThe type of message to disconnect from

References myConnectors.

◆ disconnectAll()

void makVre::DtVreMessageHandlerGroup::disconnectAll ( )
inline

Disconnects all handlers for all message types.

References myConnectors.

Member Data Documentation

◆ myConnectors

std::map<std::string, std::shared_ptr<DtVreMessageHandler> > makVre::DtVreMessageHandlerGroup::myConnectors
protected

The documentation for this class was generated from the following file: