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

Detailed Description

Resuable generic message type supports variable parameters using template methods.

Does not support network replication. Use only within the application instance.

#include <localMessage.h>

Inheritance diagram for makVre::DtLocalMessage:
[legend]

Classes

struct  Parameter
 
struct  ParameterBase
 

Public Types

using ParameterMap = std::map<std::string, std::shared_ptr<ParameterBase>>
 

Public Member Functions

virtual void setType (const std::string &type)
 
virtual ~DtLocalMessage () override
 
virtual const std::string & type () const override
 
virtual const makVre::DtVreMessageId & messageId () const override
 
virtual const ParameterMap & parameterMap () const
 
template<typename T>
const T & getParameter (const std::string &name)
 
template<typename T>
void addParameter (const std::string &name, T data)
 
- Public Member Functions inherited from makVre::DtVreMessage
 DtVreMessage ()
 
virtual ~DtVreMessage ()
 
virtual char * encode ()
 
virtual void encode (char *buffer, int bufferSize)
 
virtual int messageSize () const
 
virtual const UInt64 originatingApplicationId () const
 
virtual void setOriginatingApplicationId (UInt64 appId)
 
virtual void setDelay (double delay)
 
virtual bool isDelayed ()
 
virtual void reduceDelay (double dt)
 
virtual const UInt64 versionNumber () const
 

Static Public Member Functions

static DtLocalMessage * create ()
 
static const std::string & theType ()
 
static const makVre::DtVreMessageId & theId ()
 

Protected Member Functions

 DtLocalMessage ()
 
- Protected Member Functions inherited from makVre::DtVreMessage
virtual void serialize (DtStreamWriter &writer) const
 
virtual void deserialize (DtStreamReader &reader)
 

Protected Attributes

DtVreMessageId myMessageId
 
ParameterMap myParameters
 
- Protected Attributes inherited from makVre::DtVreMessage
double myDelay
 
UInt64 myApplicationId
 
UInt64 myVersion
 

Static Protected Attributes

static makVre::DtVreMessageId theMessageId
 

Member Typedef Documentation

◆ ParameterMap

using makVre::DtLocalMessage::ParameterMap = std::map<std::string, std::shared_ptr<ParameterBase>>

Type definition for parameter map.

Constructor & Destructor Documentation

◆ ~DtLocalMessage()

virtual makVre::DtLocalMessage::~DtLocalMessage ( )
overridevirtual

Virtual destructor.

Cleans up resources used by the message, including allocated Parameter objects.

◆ DtLocalMessage()

makVre::DtLocalMessage::DtLocalMessage ( )
protected

Protected constructor.

Initializes a new message with default values. This constructor is protected to enforce the use of the static create() method for creating new instances.

Referenced by create().

Member Function Documentation

◆ setType()

virtual void makVre::DtLocalMessage::setType ( const std::string & type)
virtual

Used to define the message type.

Given type string is used to define the (non-static) messageId and messageType, as "local.message.{type}"

References type().

◆ create()

static DtLocalMessage * makVre::DtLocalMessage::create ( )
static

Creates a new instance of this message type.

Returns
Pointer to a newly created message of this specific type

This static method creates a new instance of this message type and returns a pointer to the specific message type, avoiding the need for casting by the caller.

References DtLocalMessage().

◆ theType()

static const std::string & makVre::DtLocalMessage::theType ( )
static

◆ theId()

static const makVre::DtVreMessageId & makVre::DtLocalMessage::theId ( )
static

◆ type()

virtual const std::string & makVre::DtLocalMessage::type ( ) const
overridevirtual

Get the name of the message type.

Implements makVre::DtVreMessage.

Referenced by setType().

◆ messageId()

virtual const makVre::DtVreMessageId & makVre::DtLocalMessage::messageId ( ) const
overridevirtual

Gets the message ID object.

Returns
Reference to the message ID object

This pure virtual method must be implemented by derived classes to return a unique identifier object for the message. The message ID contains both the type name and a hash value for efficient routing.

Implements makVre::DtVreMessage.

◆ parameterMap()

virtual const ParameterMap & makVre::DtLocalMessage::parameterMap ( ) const
virtual

Return const ref to parameter map.

References addParameter(), and getParameter().

◆ getParameter()

template<typename T>
const T & makVre::DtLocalMessage::getParameter ( const std::string & name)

Return value of parameter with given name.

Template Parameters
TType of parameter value
Parameters
nameName of parameter to find
Returns
Value of parameter

References DtASSERT, and myParameters.

Referenced by parameterMap().

◆ addParameter()

template<typename T>
void makVre::DtLocalMessage::addParameter ( const std::string & name,
T data )

Adds an parameter to this message.

Template Parameters
TType of the parameter value
Parameters
nameName of the parameter
dataValue of the parameter

References myParameters.

Referenced by parameterMap().

Member Data Documentation

◆ theMessageId

makVre::DtVreMessageId makVre::DtLocalMessage::theMessageId
staticprotected

Static message ID for this message type.

This static member holds the unique identifier for this message type.

◆ myMessageId

DtVreMessageId makVre::DtLocalMessage::myMessageId
protected

Holds a type ID for this message.

◆ myParameters

ParameterMap makVre::DtLocalMessage::myParameters
protected

List of parameters for this message.

Referenced by addParameter(), and getParameter().


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