VR-Engage  2.2
Loading...
Searching...
No Matches
rwrMonitor.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file rwrMonitor.h
7//! \ingroup vreVrfmodel
8//! \brief Monitor for managing radar warning receiver (RWR) contact information
9//!
10//! This file defines the DtRwrMonitor class which manages the communication
11//! of radar warning receiver contact information between an RWR system and
12//! visualization systems. It handles subscription requests and notifications
13//! when RWR contacts change.
14
15#pragma once
16
17#include "vreVrfmodel/export.h"
18
19class DtSimMessage;
20
21namespace makVre
22{
24
25//! \brief Monitor for managing radar warning receiver (RWR) contact information
26//!
27//! DtRwrMonitor manages the communication of radar warning receiver contact information
28//! between an RWR system and visualization systems. It handles subscription
29//! requests from clients, maintains a list of current subscribers, and sends
30//! RWR data messages when the contact list changes.
32{
33private:
34 //! \brief Default constructor (not implemented)
35 //!
36 //! Default constructor is private and not implemented to prevent
37 //! creation of instances without proper initialization.
39
40 //! \brief Copy constructor (not implemented)
41 //!
42 //! Copy constructor is private and not implemented to prevent
43 //! copy construction.
45
46 //! \brief Assignment operator (not implemented)
47 //! \return Reference to this object
48 //!
49 //! Assignment operator is private and not implemented to prevent assignment.
50 const DtRwrMonitor& operator=(const DtRwrMonitor& orig);
51
52public:
53 //! \brief Constructor
54 //! \param hostObject The local object that owns the RWR this monitor is for
55 //! \param contactInfoList Pointer to the RWR contact information list maintained by the RWR
56 //!
57 //! Creates a new RWR monitor that will handle communication between the
58 //! specified RWR system and visualization clients.
59 DtRwrMonitor(DtLocalObject* hostObject, const DtRwrContactInfoList* contactInfoList);
60
61 //! \brief Virtual destructor
62 //!
63 //! Cleans up resources used by the RWR monitor.
64 virtual ~DtRwrMonitor();
65
66 //! \brief Initializes the monitor
67 //! \return True if initialization is successful, false otherwise
68 //!
69 //! Initializes the monitor by registering message callbacks to handle
70 //! subscription requests from clients. Called after construction.
71 virtual bool init();
72
73 //! \brief Registers message callbacks for RWR data requests
74 //!
75 //! Registers callback functions to handle rwrDataRequest and
76 //! rwrDataUnsubscribe messages from visualization clients.
78
79 //! \brief Static callback function for RWR data request messages
80 //! \param msg The simulation message containing the request
81 //! \param usrData User data pointer (contains the monitor instance)
82 //!
83 //! Static function registered as a callback to handle RWR data request
84 //! messages. Forwards the request to the appropriate monitor instance.
85 static void rwrDataRequestCallback(DtSimMessage* msg, void* usrData);
86
87 //! \brief Processes an RWR data request message
88 //! \param msg The simulation message containing the request
89 //!
90 //! Handles subscription requests for RWR data,
91 //! adding the client to the subscriber list and sending initial data.
92 virtual void processRwrDataRequest(DtSimMessage* msg);
93
94 //! \brief Static callback function for RWR data unsubscribe messages
95 //! \param msg The simulation message containing the unsubscribe request
96 //! \param usrData User data pointer (contains the monitor instance)
97 //!
98 //! Static function registered as a callback to handle RWR data unsubscribe
99 //! messages. Forwards the request to the appropriate monitor instance.
100 static void rwrDataUnsubscribeCallback(DtSimMessage* msg, void* usrData);
101
102 //! \brief Processes an RWR data unsubscribe message
103 //! \param msg The simulation message containing the unsubscribe request
104 //!
105 //! Handles unsubscription requests for RWR data,
106 //! removing the client from the subscriber list.
107 virtual void processRwrDataUnsubscribe(DtSimMessage* msg);
108
109 //! \brief Creates and sends an RWR data message to subscribers
110 //!
111 //! Constructs a DtRwrData message based on the current state of
112 //! the RWR contact list and sends it to all current subscribers.
113 //! This provides visualization clients with up-to-date RWR contact information.
115
116 //! \brief Notifies that the RWR contact list has changed
117 //!
118 //! Called by the RWR system whenever its contact list changes. This triggers
119 //! RWR data messages to be sent out to all current subscribers,
120 //! ensuring they have the latest contact information.
121 virtual void notifyTargetsChanged();
122
123protected:
124 //! \brief Adds a client to the subscriber list
125 //! \param add The simulation address of the client to add
126 //!
127 //! Adds the specified client address to the list of subscribers
128 //! for this RWR's data. Maintains a counter for each address
129 //! to support multiple subscriptions from the same client.
130 virtual void addToSubscriberList(const DtSimulationAddress& add);
131
132 //! \brief Removes a client from the subscriber list
133 //! \param add The simulation address of the client to remove
134 //!
135 //! Removes one subscription entry for the specified client address
136 //! from the list of subscribers. Only completely removes the client
137 //! when all subscription instances are removed.
138 virtual void removeFromSubscriberList(const DtSimulationAddress& add);
139
140 //! \brief Gets the number of current subscribers
141 //! \return The number of clients currently subscribed to this RWR's data
142 //!
143 //! Returns the count of unique clients currently subscribed to receive
144 //! RWR data updates.
145 virtual int numberOfSubscribers();
146
147protected:
148 //! \brief Pointer to the local object that owns the RWR
149 //!
150 //! The entity object that owns the RWR this monitor is associated with.
151 DtLocalObject* myHostObject;
152
153 //! \brief Pointer to the RWR contact information list
154 //!
155 //! Contains the current list of radar contacts detected by the RWR system.
157
158 //! \brief Type definition for the subscriber list with counter
159 //!
160 //! Defines the container type used to store simulation addresses of subscribers
161 //! with a counter for each to track multiple subscriptions from the same client.
162 using DtSubscriberListCounter = std::map<DtSimulationAddress, int>;
163
164 //! \brief List of current subscribers with subscription counts
165 //!
166 //! Contains the simulation addresses of all clients currently subscribed
167 //! to receive RWR data updates, with a count of subscriptions for each.
169};
170
171} // namespace makVre
A reader-writer list of RWR contact information elements.
Definition rwrContactInfoList.h:43
DtRwrMonitor(const DtRwrMonitor &orig)
Copy constructor (not implemented)
virtual void processRwrDataUnsubscribe(DtSimMessage *msg)
Processes an RWR data unsubscribe message.
static void rwrDataRequestCallback(DtSimMessage *msg, void *usrData)
Static callback function for RWR data request messages.
std::map< DtSimulationAddress, int > DtSubscriberListCounter
Type definition for the subscriber list with counter.
Definition rwrMonitor.h:162
virtual void registerMessageCallbacks()
Registers message callbacks for RWR data requests.
virtual void addToSubscriberList(const DtSimulationAddress &add)
Adds a client to the subscriber list.
virtual void notifyTargetsChanged()
Notifies that the RWR contact list has changed.
virtual int numberOfSubscribers()
Gets the number of current subscribers.
static void rwrDataUnsubscribeCallback(DtSimMessage *msg, void *usrData)
Static callback function for RWR data unsubscribe messages.
virtual bool init()
Initializes the monitor.
virtual void removeFromSubscriberList(const DtSimulationAddress &add)
Removes a client from the subscriber list.
virtual ~DtRwrMonitor()
Virtual destructor.
DtLocalObject * myHostObject
Pointer to the local object that owns the RWR.
Definition rwrMonitor.h:151
DtRwrMonitor()
Default constructor (not implemented)
DtSubscriberListCounter mySubscriberListCounter
List of current subscribers with subscription counts.
Definition rwrMonitor.h:168
virtual void createAndSendRwrDataMessage()
Creates and sends an RWR data message to subscribers.
const DtRwrMonitor & operator=(const DtRwrMonitor &orig)
Assignment operator (not implemented)
const DtRwrContactInfoList * myRwrContactList
Pointer to the RWR contact information list.
Definition rwrMonitor.h:156
virtual void processRwrDataRequest(DtSimMessage *msg)
Processes an RWR data request message.
DtRwrMonitor(DtLocalObject *hostObject, const DtRwrContactInfoList *contactInfoList)
Constructor.
Defines export macros for the vreVrfmodel library.
#define VREVRFMODEL_DLL
Definition export.h:22
Include export definitions for this library.
Definition glsVreMessageUtil.h:49