|
VR-Engage
2.2
|
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>
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::DtVreMessageId & | messageId () 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 |
| BaseAttribute * | getAttribute (int i) |
| template<typename T> | |
| void | addAttribute (const std::string &name, T data) |
| virtual int | messageSize () const override |
Static Public Member Functions | |
| static const std::string & | theType () |
| static const makVre::DtVreMessageId & | theId () |
| static makVre::DtVreMessage * | decode (char *buffer, int length) |
Message Creation Methods | |
| static DtVreMessage * | creator () |
| static VrfScriptedEntityTaskMessage * | create () |
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 |
Static Protected Attributes | |
| static makVre::DtVreMessageId | theMessageId |
|
protected |
Type definition for the list of attributes.
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) |
|
overridevirtual |
Virtual destructor.
Cleans up resources used by the message, including allocated attribute objects.
|
protected |
|
static |
Creates a new instance of this message type as a DtVreMessage.
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().
|
static |
Creates a new instance of this message 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().
|
static |
|
static |
|
overridevirtual |
Get the name of the message type.
Implements makVre::DtVreMessage.
Reimplemented in makVre::VrfScriptedEntitySetMessage.
|
overridevirtual |
Gets 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.
|
virtual |
Gets the entity identifier for this message.
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.
|
virtual |
Sets the entity identifier for this message.
| val | Entity 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().
|
virtual |
Gets the script name for this message.
This method returns the name of the script that should be executed on the target entity.
|
virtual |
Sets the script name for this message.
| script | Name 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().
|
virtual |
Gets the number of attributes in this message.
This method returns the number of attributes that have been added to this message.
| BaseAttribute * makVre::VrfScriptedEntityTaskMessage::getAttribute | ( | int | i | ) |
Gets an attribute at the specified index.
| i | Index of the attribute to retrieve (0-based) |
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().
| void makVre::VrfScriptedEntityTaskMessage::addAttribute | ( | const std::string & | name, |
| T | data ) |
Adds an attribute to this message.
Implementation of the addAttribute template method.
| T | Data type of the attribute value |
| name | Name of the attribute |
| data | Value 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.
| T | Data type of the attribute value |
| name | Name of the attribute |
| data | Value 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().
|
overridevirtual |
Gets the total size of the serialized 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.
|
static |
Decodes a serialized message.
| buffer | Pointer to the buffer containing the serialized message |
| length | Length of the buffer in bytes |
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.
|
overrideprotectedvirtual |
Serializes the message to a stream writer.
| writer | Reference 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.
|
overrideprotectedvirtual |
Deserializes the message from a stream reader.
| reader | Reference 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.
|
protected |
Gets the attribute type for a template parameter type.
| T | Data type of the attribute value |
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().
|
staticprotected |
Static message ID for this message type.
This static member holds the unique identifier for this message type.
|
protected |
Entity identifier of the target entity.
|
protected |
Name of the script to execute.
|
protected |
List of attributes for this message.
Referenced by addAttribute().