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