VR-Engage  2.2
Loading...
Searching...
No Matches
makVre::VrfScriptedEntityTaskMessage Class Reference

Detailed Description

This class represents a message for executing a script on a specific entity with a set of named attributes. It supports multiple attribute types including boolean, integer, double, string, vector, and entity identifier. Attributes are added to the message using the templated addAttribute method, which automatically determines the appropriate attribute type based on the template parameter.

The message contains the entity identifier, script name, and a list of attributes that are passed to the script when it is executed.

#include <vrfTaskEntityScript.h>

Inheritance diagram for makVre::VrfScriptedEntityTaskMessage:
[legend]

Classes

struct  Attribute
 
struct  BaseAttribute
 

Public Types

enum  AttrType {
  BOOL , INT , DOUBLE , STRING ,
  VECTOR , ENTITY_ID
}
 

Public Member Functions

virtual ~VrfScriptedEntityTaskMessage () override
 
virtual const std::string & type () const override
 
virtual const makVre::DtVreMessageIdmessageId () const override
 
virtual DtEntityIdentifier getEntityId () const
 
virtual void setEntityId (const DtEntityIdentifier &val)
 
virtual std::string getScriptName () const
 
virtual void setScriptName (const std::string &script)
 
virtual int getAttributeCount () const
 
BaseAttributegetAttribute (int i)
 
template<typename T>
void addAttribute (const std::string &name, T data)
 
virtual int messageSize () const override
 
- Public Member Functions inherited from makVre::DtVreMessage
 DtVreMessage ()
 
virtual ~DtVreMessage ()
 
virtual char * encode ()
 
virtual void encode (char *buffer, int bufferSize)
 
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 const std::string & theType ()
 
static const makVre::DtVreMessageIdtheId ()
 
static makVre::DtVreMessagedecode (char *buffer, int length)
 
Message Creation Methods
static DtVreMessagecreator ()
 
static VrfScriptedEntityTaskMessagecreate ()
 

Protected Types

using AttributeList = std::vector<BaseAttribute*>
 

Protected Member Functions

virtual void serialize (DtStreamWriter &writer) const override
 
virtual void deserialize (DtStreamReader &reader) override
 
 VrfScriptedEntityTaskMessage ()
 
template<typename T>
AttrType getType ()
 

Protected Attributes

DtEntityIdentifier myEntityId
 
std::string myScriptName
 
AttributeList myAttributes
 
- Protected Attributes inherited from makVre::DtVreMessage
double myDelay
 
UInt64 myApplicationId
 
UInt64 myVersion
 

Static Protected Attributes

static makVre::DtVreMessageId theMessageId
 

Member Typedef Documentation

◆ AttributeList

Type definition for the list of attributes.

Member Enumeration Documentation

◆ AttrType

Enumeration of supported attribute data types.

This enumeration defines the data types that can be used for attributes in scripted entity task messages.

Enumerator
BOOL 

Boolean value.

INT 

Integer value.

DOUBLE 

Double-precision floating point value.

STRING 

String value.

VECTOR 

Vector value (vlVector)

ENTITY_ID 

Entity identifier (DtEntityIdentifier)

Constructor & Destructor Documentation

◆ ~VrfScriptedEntityTaskMessage()

virtual makVre::VrfScriptedEntityTaskMessage::~VrfScriptedEntityTaskMessage ( )
overridevirtual

Virtual destructor.

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

◆ VrfScriptedEntityTaskMessage()

makVre::VrfScriptedEntityTaskMessage::VrfScriptedEntityTaskMessage ( )
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

◆ creator()

static DtVreMessage * makVre::VrfScriptedEntityTaskMessage::creator ( )
static

Creates a new instance of this message type as a DtVreMessage.

Returns
Pointer to a newly created message

This static method is used by the message factory to create instances of this message type. It returns a base message pointer that must be cast to the appropriate type by the caller.

References makVre::DtVreMessage::DtVreMessage().

◆ create()

static VrfScriptedEntityTaskMessage * makVre::VrfScriptedEntityTaskMessage::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 VrfScriptedEntityTaskMessage().

Referenced by makVre::lowerGate(), and makVre::raiseGate().

◆ theType()

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

◆ theId()

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

◆ type()

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

Get the name of the message type.

Implements makVre::DtVreMessage.

Reimplemented in makVre::VrfScriptedEntitySetMessage.

◆ messageId()

virtual const makVre::DtVreMessageId & makVre::VrfScriptedEntityTaskMessage::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.

Reimplemented in makVre::VrfScriptedEntitySetMessage.

◆ getEntityId()

virtual DtEntityIdentifier makVre::VrfScriptedEntityTaskMessage::getEntityId ( ) const
virtual

Gets the entity identifier for this message.

Returns
Entity identifier of the target entity

This method returns the entity identifier of the target entity for this message. The entity identifier specifies which entity the script should be executed on.

◆ setEntityId()

virtual void makVre::VrfScriptedEntityTaskMessage::setEntityId ( const DtEntityIdentifier & val)
virtual

Sets the entity identifier for this message.

Parameters
valEntity identifier of the target entity

This method sets the entity identifier of the target entity for this message. The entity identifier specifies which entity the script should be executed on.

Referenced by makVre::lowerGate(), and makVre::raiseGate().

◆ getScriptName()

virtual std::string makVre::VrfScriptedEntityTaskMessage::getScriptName ( ) const
virtual

Gets the script name for this message.

Returns
Name of the script to execute

This method returns the name of the script that should be executed on the target entity.

◆ setScriptName()

virtual void makVre::VrfScriptedEntityTaskMessage::setScriptName ( const std::string & script)
virtual

Sets the script name for this message.

Parameters
scriptName of the script to execute

This method sets the name of the script that should be executed on the target entity.

Referenced by makVre::lowerGate(), and makVre::raiseGate().

◆ getAttributeCount()

virtual int makVre::VrfScriptedEntityTaskMessage::getAttributeCount ( ) const
virtual

Gets the number of attributes in this message.

Returns
Number of attributes

This method returns the number of attributes that have been added to this message.

◆ getAttribute()

BaseAttribute * makVre::VrfScriptedEntityTaskMessage::getAttribute ( int i)

Gets an attribute at the specified index.

Parameters
iIndex of the attribute to retrieve (0-based)
Returns
Pointer to the base attribute structure

This method returns a pointer to the base attribute structure at the specified index. The returned pointer must be cast to the appropriate Attribute<T> type to access the value field.

References addAttribute().

◆ addAttribute()

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

Adds an attribute to this message.

Implementation of the addAttribute template method.

Template Parameters
TData type of the attribute value
Parameters
nameName of the attribute
dataValue of the attribute

This templated method adds an attribute with the specified name and value to this message. The attribute type is automatically determined based on the template parameter type. Supported types include bool, int, double, std::string, vlVector, and DtEntityIdentifier.

Template Parameters
TData type of the attribute value
Parameters
nameName of the attribute
dataValue of the attribute

This method creates a new Attribute object with the specified name and value, determines the attribute type using the getType template method, and adds the attribute to the message's attribute list.

References getType(), myAttributes, makVre::VrfScriptedEntityTaskMessage::BaseAttribute::name, makVre::VrfScriptedEntityTaskMessage::BaseAttribute::type, and makVre::VrfScriptedEntityTaskMessage::Attribute< T >::value.

Referenced by getAttribute().

◆ messageSize()

virtual int makVre::VrfScriptedEntityTaskMessage::messageSize ( ) const
overridevirtual

Gets the total size of the serialized message in bytes.

Returns
Size of the message in bytes

This method calculates the total size of the message when serialized, including the base message header and all attributes. It overrides the base class implementation to include the size of the entity ID, script name, and attributes.

Reimplemented from makVre::DtVreMessage.

◆ decode()

static makVre::DtVreMessage * makVre::VrfScriptedEntityTaskMessage::decode ( char * buffer,
int length )
static

Decodes a serialized message.

Parameters
bufferPointer to the buffer containing the serialized message
lengthLength of the buffer in bytes
Returns
Pointer to a newly created message instance

This static method deserializes a message from the provided buffer and creates a new message instance with the deserialized data. It is used by the message factory to create messages from received network data.

◆ serialize()

virtual void makVre::VrfScriptedEntityTaskMessage::serialize ( DtStreamWriter & writer) const
overrideprotectedvirtual

Serializes the message to a stream writer.

Parameters
writerReference to the stream writer

This method writes the message data to the stream writer, including the entity ID, script name, and all attributes. It overrides the base class implementation to include the specific data for this message type.

Reimplemented from makVre::DtVreMessage.

◆ deserialize()

virtual void makVre::VrfScriptedEntityTaskMessage::deserialize ( DtStreamReader & reader)
overrideprotectedvirtual

Deserializes the message from a stream reader.

Parameters
readerReference to the stream reader

This method reads the message data from the stream reader, including the entity ID, script name, and all attributes. It overrides the base class implementation to include the specific data for this message type.

Reimplemented from makVre::DtVreMessage.

◆ getType()

template<typename T>
AttrType makVre::VrfScriptedEntityTaskMessage::getType ( )
protected

Gets the attribute type for a template parameter type.

Template Parameters
TData type of the attribute value
Returns
Attribute type enumeration value corresponding to the template parameter type

This templated method determines the appropriate attribute type enumeration value for a given template parameter type. Specialized implementations exist for bool, int, double, std::string, vlVector, and DtEntityIdentifier.

Referenced by addAttribute().

Member Data Documentation

◆ theMessageId

makVre::DtVreMessageId makVre::VrfScriptedEntityTaskMessage::theMessageId
staticprotected

Static message ID for this message type.

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

◆ myEntityId

DtEntityIdentifier makVre::VrfScriptedEntityTaskMessage::myEntityId
protected

Entity identifier of the target entity.

◆ myScriptName

std::string makVre::VrfScriptedEntityTaskMessage::myScriptName
protected

Name of the script to execute.

◆ myAttributes

AttributeList makVre::VrfScriptedEntityTaskMessage::myAttributes
protected

List of attributes for this message.

Referenced by addAttribute().


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