VR-Engage  2.3
Loading...
Searching...
No Matches
objectProximitySensorMonitor.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file objectProximitySensorMonitor.h
7//! \ingroup vreVrfmodel
8//! \brief Monitor for managing sensor contact information communication
9//!
10//! This file defines the DtObjectProximitySensorMonitor class which manages
11//! the communication of sensor contact information between a proximity sensor
12//! and visualization systems. It handles sensor data subscriptions and notifications
13//! when detected objects change.
14
15#pragma once
16
17#include "vreVrfmodel/export.h"
18#include <list>
19
20class DtSimMessage;
21class DtSensorContactInfoList;
22
23namespace makVre
24{
25
26//! \brief Monitor for managing proximity sensor contact information
27//!
28//! DtObjectProximitySensorMonitor manages the communication of sensor contact
29//! information between a proximity sensor and visualization systems. It handles
30//! subscription requests from clients, maintains a list of current subscribers,
31//! and sends sensor data messages when the detected object list changes.
32//!
33//! This class serves a similar purpose to DtObjectSensorMonitor in VR-Forces,
34//! but is specifically designed for the DtObjectProximitySensor which does not
35//! use a DtObjectSensorPSR.
37{
38private:
39 //! \brief Default constructor (not implemented)
40 //!
41 //! Default constructor is private and not implemented to prevent
42 //! creation of instances without proper initialization.
44
45 //! \brief Copy constructor (not implemented)
46 //!
47 //! Copy constructor is private and not implemented to prevent
48 //! copy construction.
50
51 //! \brief Assignment operator (not implemented)
52 //! \return Reference to this object
53 //!
54 //! Assignment operator is private and not implemented to prevent assignment.
56
57public:
58 //! \brief Constructor
59 //! \param hostObject The local object that owns the sensor this monitor is for
60 //! \param contactInfoList Pointer to the list of sensor contacts maintained by the sensor
61 //! \param sensorName The name of the sensor being monitored
62 //! \param sensorType The type identifier for the sensor being monitored
63 //!
64 //! Creates a new sensor monitor that will handle communication between the
65 //! specified sensor and visualization clients.
66 DtObjectProximitySensorMonitor(DtLocalObject* hostObject, const DtSensorContactInfoList* contactInfoList,
67 const DtString& sensorName, int sensorType);
68
69 //! \brief Virtual destructor
70 //!
71 //! Cleans up resources used by the object proximity sensor monitor.
73
74 //! \brief Initializes the monitor
75 //! \return True if initialization is successful, false otherwise
76 //!
77 //! Initializes the monitor by registering message callbacks to handle
78 //! subscription requests from clients. Called after construction.
79 virtual bool init();
80
81 //! \brief Registers message callbacks for sensor data requests
82 //!
83 //! Registers callback functions to handle sensorDataRequest and
84 //! sensorDataUnsubscribe messages from visualization clients.
86
87 //! \brief Static callback function for sensor data request messages
88 //! \param msg The simulation message containing the request
89 //! \param usrData User data pointer (contains the monitor instance)
90 //!
91 //! Static function registered as a callback to handle sensor data request
92 //! messages. Forwards the request to the appropriate monitor instance.
93 static void sensorDataRequestCallback(DtSimMessage* msg, void* usrData);
94
95 //! \brief Processes a sensor data request message
96 //! \param msg The simulation message containing the request
97 //!
98 //! Handles subscription or unsubscription requests for sensor data,
99 //! updating the subscriber list and sending initial data when needed.
100 virtual void processSensorDataRequest(DtSimMessage* msg);
101
102 //! \brief Creates and sends a sensor data message to subscribers
103 //!
104 //! Constructs a DtSensorData message based on the current state of
105 //! the sensor's contact list and sends it to all current subscribers.
106 //! This provides visualization clients with up-to-date sensor contact information.
108
109 //! \brief Notifies that the sensor's target list has changed
110 //!
111 //! Called by the object proximity sensor whenever the list of detected objects
112 //! changes. This triggers sensor data messages to be sent out to all current
113 //! subscribers, ensuring they have the latest detection information.
114 virtual void notifyTargetsChanged();
115
116protected:
117 //! \brief Checks if an address is on the subscriber list
118 //! \param id The client identifier to check
119 //! \return True if the client is a current subscriber, false otherwise
120 //!
121 //! Determines if the specified client identifier is currently in the
122 //! list of subscribers for this sensor's data.
123 virtual bool onSubscriberList(const DtString& id) const;
124
125 //! \brief Adds a client to the subscriber list
126 //! \param id The client identifier to add
127 //!
128 //! Adds the specified client identifier to the list of subscribers
129 //! for this sensor's data.
130 virtual void addToSubscriberList(const DtString& id);
131
132 //! \brief Removes a client from the subscriber list
133 //! \param id The client identifier to remove
134 //!
135 //! Removes the specified client identifier from the list of subscribers
136 //! for this sensor's data.
137 virtual void removeFromSubscriberList(const DtString& id);
138
139 //! \brief Gets the number of current subscribers
140 //! \return The number of clients currently subscribed to this sensor's data
141 //!
142 //! Returns the count of clients currently subscribed to receive
143 //! sensor data updates.
144 virtual int numberOfSubscribers();
145
146protected:
147 //! \brief Pointer to the local object that owns the sensor
148 //!
149 //! The entity object that owns the sensor this monitor is associated with.
150 DtLocalObject* myHostObject;
151
152 //! \brief Pointer to the sensor's contact information list
153 //!
154 //! Contains the current list of objects detected by the sensor.
155 const DtSensorContactInfoList* mySensorContactInfoList;
156
157 //! \brief Type identifier for the sensor
158 //!
159 //! Numeric identifier for the type of sensor being monitored.
161
162 //! \brief Name of the sensor
163 //!
164 //! String identifier for the sensor being monitored.
165 DtString mySensorName;
166
167 //! \brief Type definition for the subscriber list
168 //!
169 //! Defines the container type used to store the list of subscriber IDs.
170 using DtSubscriberList = std::list<DtString>;
171
172 //! \brief List of current subscribers
173 //!
174 //! Contains the identifiers of all clients currently subscribed
175 //! to receive sensor data updates.
177};
178
179} // namespace makVre
DtObjectProximitySensorMonitor()
Default constructor (not implemented)
DtString mySensorName
Name of the sensor.
Definition objectProximitySensorMonitor.h:165
virtual bool onSubscriberList(const DtString &id) const
Checks if an address is on the subscriber list.
virtual void registerMessageCallbacks()
Registers message callbacks for sensor data requests.
virtual void removeFromSubscriberList(const DtString &id)
Removes a client from the subscriber list.
virtual ~DtObjectProximitySensorMonitor()
Virtual destructor.
virtual void addToSubscriberList(const DtString &id)
Adds a client to the subscriber list.
virtual int numberOfSubscribers()
Gets the number of current subscribers.
DtObjectProximitySensorMonitor(DtLocalObject *hostObject, const DtSensorContactInfoList *contactInfoList, const DtString &sensorName, int sensorType)
Constructor.
const DtSensorContactInfoList * mySensorContactInfoList
Pointer to the sensor's contact information list.
Definition objectProximitySensorMonitor.h:155
const DtObjectProximitySensorMonitor & operator=(const DtObjectProximitySensorMonitor &orig)
Assignment operator (not implemented)
DtLocalObject * myHostObject
Pointer to the local object that owns the sensor.
Definition objectProximitySensorMonitor.h:150
virtual bool init()
Initializes the monitor.
DtObjectProximitySensorMonitor(const DtObjectProximitySensorMonitor &orig)
Copy constructor (not implemented)
int mySensorType
Type identifier for the sensor.
Definition objectProximitySensorMonitor.h:160
virtual void processSensorDataRequest(DtSimMessage *msg)
Processes a sensor data request message.
static void sensorDataRequestCallback(DtSimMessage *msg, void *usrData)
Static callback function for sensor data request messages.
DtSubscriberList mySubscriberList
List of current subscribers.
Definition objectProximitySensorMonitor.h:176
virtual void notifyTargetsChanged()
Notifies that the sensor's target list has changed.
std::list< DtString > DtSubscriberList
Type definition for the subscriber list.
Definition objectProximitySensorMonitor.h:170
virtual void createAndSendSensorDataMessage()
Creates and sends a sensor data message to subscribers.
Defines export macros for the vreVrfmodel library.
#define VREVRFMODEL_DLL
Definition export.h:22
!
Definition glsVreMessageUtil.h:50