VR-Engage  2.2
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 sensor type
85 //! \param type The sensor type identifier
86 //!
87 //! Sets the type of sensor for which data is being requested.
88 //! Sensor types are defined in the system and determine what kind of
89 //! sensor data will be provided in response.
90 virtual void setSensorType(const int type);
91
92 //! \brief Gets the sensor type
93 //! \return The sensor type identifier
94 virtual int sensorType() const;
95
96 //! \brief Sets the subscriber identifier
97 //! \param id The subscriber identifier
98 //!
99 //! Sets the unique identifier for the subscriber requesting the data.
100 //! This is used to manage multiple subscriptions and route responses.
101 virtual void setSubscriberId(const unsigned long id);
102
103 //! \brief Gets the subscriber identifier
104 //! \return The subscriber identifier
105 virtual unsigned long subscriberId() const;
106
107 //! \brief Sets the request type
108 //! \param type The request type (ONE_UPDATE, SUBSCRIBE, or UNSUBSCRIBE)
109 //!
110 //! Sets the type of request being made. This determines how the sensor
111 //! system will handle the request (single update vs. continuous updates).
112 virtual void setRequestType(const RequestType type);
113
114 //! \brief Gets the request type
115 //! \return The request type (ONE_UPDATE, SUBSCRIBE, or UNSUBSCRIBE)
116 virtual RequestType requestType() const;
117
118 //! \brief Gets the network representation size
119 //! \return Size in bytes of the network representation
120 //!
121 //! Returns the size of the network buffer needed to store this message.
122 virtual int netRepSize() const override;
123
124 //! \brief Deserializes the message from a network buffer
125 //! \param contentBuffer Pointer to the network buffer
126 //! \param contentSize Size of the buffer in bytes
127 //! \return True if deserialization was successful
128 //!
129 //! Fills the message from the provided network buffer.
130 virtual bool setFromNet(const char* contentBuffer, unsigned contentSize) override;
131
132 //! \brief Serializes the message for network transmission
133 //! \return True if serialization was successful
134 //!
135 //! Prepares the message for network transmission.
136 virtual bool setToNet() override;
137
138 //! \brief Formats the message data as a string
139 //! \param str String to store the formatted message data
140 //!
141 //! Appends a human-readable representation of the message to the provided string.
142 virtual void printDataToString(DtString& str) override;
143
144 //! \brief Static creator function for factory registration
145 //! \return Pointer to a new instance of DtIfVreSensorDataRequest
146 //!
147 //! This static function is used for registration with DtInterfaceContentFactory.
148 static DtSimInterfaceContent* creator();
149
150protected:
151 //! \brief UUID of the entity whose sensor data is being requested
152 DtUUID myUUID;
153
154 //! \brief Type of sensor for which data is being requested
156
157 //! \brief Unique identifier for the subscriber requesting the data
159
160 //! \brief Type of request (ONE_UPDATE, SUBSCRIBE, or UNSUBSCRIBE)
162};
DtU64 mySubscriberId
Unique identifier for the subscriber requesting the data.
Definition ifVreSensorDataRequest.h:158
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 DtSimInterfaceContent * clone() const override
Creates a copy of this message.
DtU32 myRequestType
Type of request (ONE_UPDATE, SUBSCRIBE, or UNSUBSCRIBE)
Definition ifVreSensorDataRequest.h:161
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.
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 unsigned long subscriberId() const
Gets the subscriber identifier.
virtual void printDataToString(DtString &str) override
Formats the message data as a string.
virtual ~DtIfVreSensorDataRequest() override
Virtual destructor.
DtIfVreSensorDataRequest(const DtIfVreSensorDataRequest &orig)
Copy constructor.
static DtSimInterfaceContent * creator()
Static creator function for factory registration.
DtIfVreSensorDataRequest()
Default constructor.
virtual int sensorType() const
Gets the sensor type.
virtual void setSubscriberId(const unsigned long 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:152
virtual int type() const override
Gets the interface message type.
DtU32 mySensorType
Type of sensor for which data is being requested.
Definition ifVreSensorDataRequest.h:155
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