VR-Engage  2.3
Loading...
Searching...
No Matches
ifVreSensorDataRequest.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file ifVreSensorDataRequest.h
7//! \ingroup vreVrfMessages
8//! \brief Interface message class for requesting VREngage sensor data
9//!
10//! This file defines the DtIfVreSensorDataRequest class, which is used to
11//! request sensor data from various sensor types in the VREngage simulation.
12//! It supports one-time requests, subscription, and unsubscription operations.
13
14//! The DtIfVreSensorDataRequest class provides a mechanism for requesting
15//! sensor data from sensor objects in the simulation system.
16
17#pragma once
18
20#include <vrfExtProtocol/simInterfaceContent.h>
21#include <vrfutil/rwUUID.h>
22#include <vlutil/vlString.h>
23
24//! \brief Interface message for requesting sensor data
25//!
26//! This class is used to request sensor data messages to be sent from a DtObjectSensor.
27//! It supports three types of requests: one-time updates, subscriptions for continuous
28//! updates, and unsubscribe operations to cancel existing subscriptions.
29class VRFMESSAGES_DLL DtIfVreSensorDataRequest : public DtSimInterfaceContent
30{
31public:
32 //! \brief Enumeration of available request types
34 {
35 ONE_UPDATE, //!< Request a single update of sensor data
36 SUBSCRIBE, //!< Subscribe to receive continuous sensor data updates
37 UNSUBSCRIBE //!< Cancel an existing subscription
38 };
39
40 //! \brief Default constructor
41 //!
42 //! Initializes an empty sensor data request message.
44
45 //! \brief Copy constructor
46 //! \param orig The sensor data request to copy from
47 //!
48 //! Creates a new sensor data request message by copying an existing one.
50
51 //! \brief Assignment operator
52 //! \param orig The sensor data request to copy from
53 //! \return Reference to this object after assignment
54 //!
55 //! Copies the contents of another sensor data request message into this one.
57
58 //! \brief Virtual destructor
59 virtual ~DtIfVreSensorDataRequest() override;
60
61 //! \brief Gets the interface message type
62 //! \return The message type identifier
63 //!
64 //! Returns DtVreSensorDataRequestMessageType as defined in vreVrfMessageTypes.h.
65 virtual int type() const override;
66
67 //! \brief Creates a copy of this message
68 //! \return Pointer to the new copy
69 //!
70 //! Creates a dynamically allocated copy of this message.
71 virtual DtSimInterfaceContent* clone() const override;
72
73 //! \brief Sets the UUID of the entity whose sensor data is being requested
74 //! \param uuid The entity UUID to set
75 //!
76 //! Sets the UUID of the entity whose sensor data is being requested.
77 //! This identifies the specific entity in the simulation that has the sensor.
78 virtual void setUUID(const DtUUID& uuid);
79
80 //! \brief Gets the UUID of the entity whose sensor data is being requested
81 //! \return The entity UUID
82 virtual const DtUUID& uuid() const;
83
84 //! \brief Sets the name of the sensor for which data is being requested
85 //! \param name The sensor name
86 virtual void setSensorName(const DtString& name);
87
88 //! \brief Gets the name of the sensor for which data is being requested
89 // \return The sensor name
90 virtual const DtString& sensorName() const;
91
92 //! \brief Sets the sensor type for which data is being requested
93 //! \param type The sensor type identifier
94 //!
95 //! Sensor types are defined in the system and determine what kind of
96 //! sensor data will be provided in response.
97 virtual void setSensorType(const int type);
98
99 //! \brief Gets the sensor type for which data is being requested
100 //! \return The sensor type identifier
101 virtual int sensorType() const;
102
103 //! \brief Sets the subscriber identifier
104 //! \param id The subscriber identifier
105 //!
106 //! Sets the unique identifier for the subscriber requesting the data.
107 //! This is used to manage multiple subscriptions and route responses.
108 virtual void setSubscriberId(const DtString& id);
109
110 //! \brief Gets the subscriber identifier
111 //! \return The subscriber identifier
112 virtual const DtString& subscriberId() const;
113
114 //! \brief Sets the request type
115 //! \param type The request type (ONE_UPDATE, SUBSCRIBE, or UNSUBSCRIBE)
116 //!
117 //! Sets the type of request being made. This determines how the sensor
118 //! system will handle the request (single update vs. continuous updates).
119 virtual void setRequestType(const RequestType type);
120
121 //! \brief Gets the request type
122 //! \return The request type (ONE_UPDATE, SUBSCRIBE, or UNSUBSCRIBE)
123 virtual RequestType requestType() const;
124
125 //! \brief Gets the network representation size
126 //! \return Size in bytes of the network representation
127 //!
128 //! Returns the size of the network buffer needed to store this message.
129 virtual int netRepSize() const override;
130
131 //! \brief Deserializes the message from a network buffer
132 //! \param contentBuffer Pointer to the network buffer
133 //! \param contentSize Size of the buffer in bytes
134 //! \return True if deserialization was successful
135 //!
136 //! Fills the message from the provided network buffer.
137 virtual bool setFromNet(const char* contentBuffer, unsigned contentSize) override;
138
139 //! \brief Serializes the message for network transmission
140 //! \return True if serialization was successful
141 //!
142 //! Prepares the message for network transmission.
143 virtual bool setToNet() override;
144
145 //! \brief Formats the message data as a string
146 //! \param str String to store the formatted message data
147 //!
148 //! Appends a human-readable representation of the message to the provided string.
149 virtual void printDataToString(DtString& str) override;
150
151 //! \brief Static creator function for factory registration
152 //! \return Pointer to a new instance of DtIfVreSensorDataRequest
153 //!
154 //! This static function is used for registration with DtInterfaceContentFactory.
155 static DtSimInterfaceContent* creator();
156
157protected:
158 //! \brief UUID of the entity whose sensor data is being requested
159 DtUUID myUUID;
160
161 //!\ brief Name of sensor for which data is being requested
162 DtString mySensorName;
163
164 //! \brief Type of sensor(s) for which data is being requested
166
167 //! \brief Unique identifier for the subscriber requesting the data
169
170 //! \brief Type of request (ONE_UPDATE, SUBSCRIBE, or UNSUBSCRIBE)
172};
virtual const DtUUID & uuid() const
Gets the UUID of the entity whose sensor data is being requested.
virtual void setUUID(const DtUUID &uuid)
Sets the UUID of the entity whose sensor data is being requested.
virtual const DtString & sensorName() const
Gets the name of the sensor for which data is being requested.
virtual DtSimInterfaceContent * clone() const override
Creates a copy of this message.
DtU32 myRequestType
Type of request (ONE_UPDATE, SUBSCRIBE, or UNSUBSCRIBE)
Definition ifVreSensorDataRequest.h:171
DtString mySubscriberId
Unique identifier for the subscriber requesting the data.
Definition ifVreSensorDataRequest.h:168
virtual bool setFromNet(const char *contentBuffer, unsigned contentSize) override
Deserializes the message from a network buffer.
virtual RequestType requestType() const
Gets the request type.
virtual void setSensorType(const int type)
Sets the sensor type for which data is being requested.
virtual void setRequestType(const RequestType type)
Sets the request type.
virtual bool setToNet() override
Serializes the message for network transmission.
RequestType
Enumeration of available request types.
Definition ifVreSensorDataRequest.h:34
@ UNSUBSCRIBE
Cancel an existing subscription.
Definition ifVreSensorDataRequest.h:37
@ SUBSCRIBE
Subscribe to receive continuous sensor data updates.
Definition ifVreSensorDataRequest.h:36
@ ONE_UPDATE
Request a single update of sensor data.
Definition ifVreSensorDataRequest.h:35
virtual void printDataToString(DtString &str) override
Formats the message data as a string.
virtual const DtString & subscriberId() const
Gets the subscriber identifier.
virtual ~DtIfVreSensorDataRequest() override
Virtual destructor.
DtIfVreSensorDataRequest(const DtIfVreSensorDataRequest &orig)
Copy constructor.
static DtSimInterfaceContent * creator()
Static creator function for factory registration.
DtIfVreSensorDataRequest()
Default constructor.
virtual void setSensorName(const DtString &name)
Sets the name of the sensor for which data is being requested.
virtual int sensorType() const
Gets the sensor type for which data is being requested.
DtString mySensorName
\ brief Name of sensor for which data is being requested
Definition ifVreSensorDataRequest.h:162
virtual void setSubscriberId(const DtString &id)
Sets the subscriber identifier.
const DtIfVreSensorDataRequest & operator=(const DtIfVreSensorDataRequest &orig)
Assignment operator.
DtUUID myUUID
UUID of the entity whose sensor data is being requested.
Definition ifVreSensorDataRequest.h:159
virtual int type() const override
Gets the interface message type.
DtU32 mySensorType
Type of sensor(s) for which data is being requested.
Definition ifVreSensorDataRequest.h:165
virtual int netRepSize() const override
Gets the network representation size.
Export/import macros for the VRF Messages library.
#define VRFMESSAGES_DLL
Definition export.h:23