VR-Engage  2.3
Loading...
Searching...
No Matches
setVreControlled.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file setVreControlled.h
7//! \ingroup vreVrfMessages
8//! \brief VREngage control state request message
9//!
10//! This file defines the DtSetVreControlledRequest class, which is used to set the
11//! VREngage control state of an entity, including which roles are controlled, in the
12//! VRForces back-end simulation.
13
14#pragma once
15
17#include <vrftasks/setDataRequest.h>
18#include <vrfutil/rwSimulationAddress.h>
19#include <readerWriter/rwBoolean.h>
20#include <readerWriter/rwString.h>
21#include <vrftasks/radioMessageTypes.h>
22
23#include <string>
24#include <vector>
25
26namespace makVre
27{
28//! \brief Message type for VREngage control state requests
29//!
30//! Unique identifier for the set-vre-controlled message type used in the factory system.
31//! This must be a unique string to distinguish from other set types defined in msgTypes.h.
32const DtSetMessageType DtSetVreControlledType("set-vre-controlled");
33
34//! \brief Request to set the VREngage control state of an entity
35//!
36//! This class is used to inform a VRForces back-end that an entity is being controlled
37//! by a VREngage player station. The message includes the identity of the controlling
38//! application, station information, and role information (e.g., gunner, driver,
39//! commander, or entity-level control).
40class VRFMESSAGES_DLL DtSetVreControlledRequest : public DtSetDataRequest
41{
42public:
43 //! \brief Default constructor
44 //!
45 //! Initializes an empty VREngage control state request.
47
48 //! \brief Named constructor for reader/writer functionality
49 //! \param writeName The name to identify this request
50 //! \param parentRegistry Optional reader-writer registry for serialization
51 //!
52 //! If you have a request 'put' itself, the writeName will preface it.
53 DtSetVreControlledRequest(const DtString& writeName, DtReaderWriterRegistry* parentRegistry = 0);
54
55 //! \brief Copy constructor
56 //! \param writeName The name to identify this request
57 //! \param orig The request to copy from
58 //! \param parentRegistry Optional reader-writer registry for serialization
59 //!
60 //! Creates a new request by copying an existing one.
62 const DtString& writeName, const DtSetVreControlledRequest& orig, DtReaderWriterRegistry* parentRegistry = 0);
63
64 //! \brief Assignment operator
65 //! \param orig The request to copy from
66 //! \return Reference to this object after assignment
67 //!
68 //! Copies the contents of another request into this one.
70
71 //! \brief Virtual destructor
72 virtual ~DtSetVreControlledRequest() override;
73
74 //! \brief Gets the message type
75 //! \return The message type identifier
76 //!
77 //! Returns DtSetVreControlledType as the message type identifier.
78 virtual const DtSetMessageType& type() const override;
79
80 //! \brief Creates a copy of this request
81 //! \param name The name to identify the cloned request
82 //! \param parentRegistry Optional reader-writer registry for serialization
83 //! \return Pointer to a new dynamically allocated copy
84 //!
85 //! Creates a deep copy of the request for factory system use.
86 virtual DtSetDataRequest* clone(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0) const override;
87
88 //! \brief Gets a human-readable string representation
89 //! \return String containing a human-readable representation of the request
90 //!
91 //! Provides a human-readable representation of this request for debugging and logging.
92 virtual DtString stringRep() const override;
93
94 //! \brief Gets the simulation address of the player station
95 //! \return The simulation address of the controlling player station
96 //!
97 //! Returns the simulation address of the VREngage player station that is
98 //! controlling the entity.
99 virtual DtSimulationAddress simulationAddress() const;
100
101 //! \brief Sets the simulation address of the player station
102 //! \param address The simulation address to set
103 //!
104 //! Sets the simulation address of the VREngage player station that is
105 //! controlling the entity.
106 virtual void setSimulationAddress(const DtSimulationAddress& address);
107
108 //! \brief Gets the published ID of the player station
109 //! \return The unique ID of the controlling player station
110 //!
111 //! Returns the unique identifier for the VREngage player station that is
112 //! controlling the entity.
113 virtual std::string stationId() const;
114
115 //! \brief Sets the published ID of the player station
116 //! \param id The unique ID to set
117 //!
118 //! Sets the unique identifier for the VREngage player station that is
119 //! controlling the entity.
120 virtual void setStationId(const std::string& id);
121
122 //! \brief Gets the player station control state
123 //! \return True if the entity is player station controlled, false otherwise
124 //!
125 //! Returns whether the entity is currently controlled by a VREngage player station.
126 virtual bool playerStationControlled() const;
127
128 //! \brief Sets the player station control state
129 //! \param trueFalse True to enable player station control, false to disable
130 //!
131 //! Sets whether the entity is controlled by a VREngage player station.
132 //! When set to false, this can be used to release control back to AI.
133 virtual void setPlayerStationControlled(bool trueFalse);
134
135 //! \brief Gets the controlled role types for the entity
136 //! \return List of role-type strings indicating which role entries are controlled
137 //!
138 //! Returns a list of strings indicating which role-type keys are controlled
139 //! by the VREngage player station, such as "gunner", "driver", "commander",
140 //! or "entity" for entity-level control.
141 virtual std::vector<std::string> roles() const;
142
143 //! \brief Sets the controlled role types for the entity
144 //! \param description List of role-type strings indicating which role entries are controlled
145 //!
146 //! Sets the list of strings indicating which role-type keys are controlled
147 //! by the VREngage player station, such as "gunner", "driver", "commander",
148 //! or "entity" for entity-level control.
149 virtual void setRoles(const std::vector<std::string>& description);
150
151 //! \brief Gets the entity-role name associated with the control request.
152 //! \return The entity-role name stored in the request.
153 //!
154 //! Returns the role name that should be written into the "Role" field of the
155 //! structured station entry in the published "Roles" state property.
156 virtual std::string roleName() const;
157
158 //! \brief Sets the entity-role name associated with the control request.
159 //! \param roleName The entity-role name to store in the request.
160 //!
161 //! Sets the role name that should be written into the "Role" field of the
162 //! structured station entry in the published "Roles" state property.
163 virtual void setRoleName(const std::string& roleName);
164
165 //! \brief Gets the network representation size
166 //! \return Size in bytes of the network representation
167 //!
168 //! Returns the size of the network buffer needed to store this request,
169 //! padded to an 8-byte boundary for alignment.
170 virtual int netRepSize() const override;
171
172 //! \brief Deserializes the request from a network buffer
173 //! \param contentBuffer Pointer to the network buffer
174 //! \param contentSize Size of the buffer in bytes
175 //! \return True if deserialization was successful
176 //!
177 //! Fills the request from the provided network buffer.
178 virtual bool setFromNet(const char* contentBuffer, unsigned contentSize) override;
179
180 //! \brief Serializes the request for network transmission
181 //! \return True if serialization was successful
182 //!
183 //! Fills in the network buffer (created by base class setDataRequest) with
184 //! the request contents for transmission.
185 virtual bool setToNet() override;
186
187 //! \brief Static creator function for factory registration
188 //! \return Pointer to a new instance of DtSetVreControlledRequest
189 //!
190 //! This static function is used for registration with the request factory system.
191 static DtSetDataRequest* creator();
192
193protected:
194 //! \brief Simulation address of the controlling player station
195 DtRwSimulationAddress mySimulationAddress;
196
197 //! \brief Unique identifier for the controlling player station
198 DtRwString myStationId;
199
200 //! \brief Entity-role name stored for the structured "Role" field.
201 DtRwString myRoleName;
202
203 //! \brief Flag indicating whether the entity is player station controlled
205
206 //! \brief List of role-type keys that are controlled
207 //!
208 //! Contains strings like "gunner", "driver", "commander", or "entity".
209 DtRwStringList myRoleTypes;
210};
211} // namespace makVre
virtual DtString stringRep() const override
Gets a human-readable string representation.
DtSetVreControlledRequest(const DtString &writeName, DtReaderWriterRegistry *parentRegistry=0)
Named constructor for reader/writer functionality.
DtSetVreControlledRequest()
Default constructor.
DtSetVreControlledRequest(const DtString &writeName, const DtSetVreControlledRequest &orig, DtReaderWriterRegistry *parentRegistry=0)
Copy constructor.
virtual std::string roleName() const
Gets the entity-role name associated with the control request.
virtual ~DtSetVreControlledRequest() override
Virtual destructor.
DtRwSimulationAddress mySimulationAddress
Simulation address of the controlling player station.
Definition setVreControlled.h:195
virtual void setStationId(const std::string &id)
Sets the published ID of the player station.
DtRwBoolean myIsPlayerStationControlled
Flag indicating whether the entity is player station controlled.
Definition setVreControlled.h:204
DtRwString myRoleName
Entity-role name stored for the structured "Role" field.
Definition setVreControlled.h:201
virtual int netRepSize() const override
Gets the network representation size.
virtual const DtSetMessageType & type() const override
Gets the message type.
DtRwString myStationId
Unique identifier for the controlling player station.
Definition setVreControlled.h:198
virtual bool playerStationControlled() const
Gets the player station control state.
virtual void setPlayerStationControlled(bool trueFalse)
Sets the player station control state.
virtual void setRoles(const std::vector< std::string > &description)
Sets the controlled role types for the entity.
virtual bool setFromNet(const char *contentBuffer, unsigned contentSize) override
Deserializes the request from a network buffer.
virtual std::vector< std::string > roles() const
Gets the controlled role types for the entity.
const DtSetVreControlledRequest & operator=(const DtSetVreControlledRequest &orig)
Assignment operator.
virtual void setSimulationAddress(const DtSimulationAddress &address)
Sets the simulation address of the player station.
virtual DtSimulationAddress simulationAddress() const
Gets the simulation address of the player station.
virtual DtSetDataRequest * clone(const DtString &name, DtReaderWriterRegistry *parentRegistry=0) const override
Creates a copy of this request.
virtual bool setToNet() override
Serializes the request for network transmission.
static DtSetDataRequest * creator()
Static creator function for factory registration.
DtRwStringList myRoleTypes
List of role-type keys that are controlled.
Definition setVreControlled.h:209
virtual void setRoleName(const std::string &roleName)
Sets the entity-role name associated with the control request.
virtual std::string stationId() const
Gets the published ID of the player station.
Export/import macros for the VRF Messages library.
#define VRFMESSAGES_DLL
Definition export.h:23
!
Definition glsVreMessageUtil.h:50
const DtSetMessageType DtSetVreControlledType("set-vre-controlled")
Message type for VREngage control state requests.