VR-Engage  2.3
Loading...
Searching...
No Matches
laserDesignatorConnector.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file laserDesignatorConnector.h
7//! \brief Defines the DtLaserDesignatorConnector class for handling laser designator events
8//!
9//! This connector monitors laser designators in the simulation, providing position
10//! updates and status changes to VREngage components on request.
11
12#pragma once
13
14#include "export.h"
15
18
19//! \brief Forward declaration of the reflected designator class
20class DtReflectedDesignator;
21
22namespace makVrv
23{
25{
26//! \brief Forward declaration of the reflected laser designator list class
27class DtVrlinkReflectedLaserDesignatorList;
28} // namespace DT_PROTOCOL_NAMESPACE
29} // namespace makVrv
30
31namespace makVre
32{
33//! \brief Forward declaration of the VREngage message class
34class DtVreMessage;
35
36//! \brief Connector for monitoring and reporting laser designator events
37//!
38//! DtLaserDesignatorConnector listens for Start/StopMonitoringDesignatorMessages
39//! and provides updates on designator position and removal for monitored laser codes.
40//! It tracks designators by their code and sends position updates when they change or
41//! are removed from the simulation.
43{
44public:
45 //! \brief Default constructor
47
48 //! \brief Virtual destructor
49 virtual ~DtLaserDesignatorConnector() override;
50
51 //! \brief Installs the laser designator connector with shared infrastructure.
52 //!
53 //! \param connection Non-owning pointer to the protocol-specific VR-Link connection.
54 //! \param laserDesignatorList Non-owning pointer to the reflected laser designator list.
55 //!
56 //! Registers designator added/removed callbacks on the reflected list and registers handlers
57 //! for Start/StopMonitoringDesignatorMessages
58 virtual void install(
59 makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection* connection,
60 makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkReflectedLaserDesignatorList* laserDesignatorList);
61
62 //! \brief Performs periodic checks of monitored designator positions
63 //!
64 //! For each designator code being monitored (that exists), checks if its location
65 //! has changed. If so, sends an update message with the new position.
66 //!
67 //! \param dt The elapsed time in seconds since the last tick
68 virtual void tick(double dt) override;
69
70 //! \brief Shuts down the laser designator connector
71 //!
72 //! Removes all callback registrations and message handlers
73 virtual void shutdown() override;
74
75 //! \brief Handles the addition of a new designator
76 //! \param des Pointer to the newly added designator
77 //!
78 //! Callback triggered when a new designator is discovered.
79 //! If this code is being monitored, sends an initial update with the position.
80 virtual void handleDesignatorAdded(DtReflectedDesignator* des);
81
82 //! \brief Handles the removal of a designator
83 //! \param des Pointer to the designator about to be removed
84 //!
85 //! Callback triggered when a designator is about to be destroyed.
86 //! If this code is being monitored, sends a deletion notification.
87 virtual void handleDesignatorRemoved(DtReflectedDesignator* des);
88
89protected:
90 //! \brief Handles requests to start monitoring a laser designator
91 //! \param msg Pointer to the monitoring request message
92 //! \return Message result indicating the message was handled
93 //!
94 //! Processes StartMonitoringDesignatorMessages by adding the requested code to myCodesToMonitor.
95 //! If the designator already exists, sends an initial position update.
97
98 //! \brief Handles requests to stop monitoring a laser designator
99 //! \param msg Pointer to the message requesting monitoring to stop
100 //! \return Message result indicating the message was handled
101 //!
102 //! Processes StopMonitoringDesignatorMessages by removing the code from myCodesToMonitor.
104
105 //! \brief Searches the reflected laser designator list for a designator with the given code
106 //! \param laserCode The laser designator code to search for
107 //! \return Pointer to the matching DtReflectedDesignator, or nullptr if not found
108 //!
109 //! Iterates myLaserDesignatorList to find a designator whose designator code
110 //! matches \a laserCode. Returns nullptr if the list is empty or no match is found.
111 virtual DtReflectedDesignator* findDesignator(int laserCode);
112
113 //! \brief Sends a position update (or deletion notification) for the given designator
114 //! \param des Pointer to the designator to report; if nullptr the message is skipped
115 //! \param toBeDeleted When true, sends a deletion notification instead of a position update;
116 //! defaults to false
117 //!
118 //! Builds and queues a LaserDesignatorUpdateMessage containing the current geocentric
119 //! position and laser code of \a des. When \a toBeDeleted is true the message signals
120 //! that the designator has been removed from the simulation.
121 virtual void sendDesignatorUpdate(DtReflectedDesignator* des, bool toBeDeleted = false);
122
123protected:
124 //! \brief Type alias for the map of monitored designator codes
125 //!
126 //! Key is the designator code to monitor (integer).
127 //! Value is a pair containing:
128 //! - Pointer to the reflected designator (nullptr if not yet discovered)
129 //! - Last sent position (used to detect changes)
130 using CodeMonitorMap = std::map<int, std::pair<DtReflectedDesignator*, DtVector>>;
131
132 //! \brief Map of laser codes being monitored
133 //!
134 //! Tracks which designator codes are being monitored, along with their
135 //! current designator object and last reported position
137
138 //! \brief Pointer to the reflected laser designator list (NON-OWNING)
139 //!
140 //! Provided by DtConnectorAccessory via the \c laserDesignatorList parameter of install().
141 //! Used to iterate existing designators and register add/remove callbacks.
142 //! Lifetime is managed by the VR-Link connection; guaranteed to outlive this connector
143 //! while the connection is active.
144 makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkReflectedLaserDesignatorList* myLaserDesignatorList;
145};
146} // namespace makVre
Base class for all simulation event connectors in VREngage.
Definition simEventConnector.h:53
CodeMonitorMap myCodesToMonitor
Map of laser codes being monitored.
Definition laserDesignatorConnector.h:136
virtual ~DtLaserDesignatorConnector() override
Virtual destructor.
DtLaserDesignatorConnector()
Default constructor.
virtual void handleDesignatorAdded(DtReflectedDesignator *des)
Handles the addition of a new designator.
virtual DtVreMessageResult handleStartMonitoringDesignator(DtVreMessage *msg)
Handles requests to start monitoring a laser designator.
virtual void sendDesignatorUpdate(DtReflectedDesignator *des, bool toBeDeleted=false)
Sends a position update (or deletion notification) for the given designator.
virtual DtVreMessageResult handleStopMonitoringDesignator(DtVreMessage *msg)
Handles requests to stop monitoring a laser designator.
virtual void shutdown() override
Shuts down the laser designator connector.
std::map< int, std::pair< DtReflectedDesignator *, DtVector > > CodeMonitorMap
Type alias for the map of monitored designator codes.
Definition laserDesignatorConnector.h:130
makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkReflectedLaserDesignatorList * myLaserDesignatorList
Pointer to the reflected laser designator list (NON-OWNING)
Definition laserDesignatorConnector.h:144
virtual void install(makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection *connection, makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkReflectedLaserDesignatorList *laserDesignatorList)
Installs the laser designator connector with shared infrastructure.
virtual DtReflectedDesignator * findDesignator(int laserCode)
Searches the reflected laser designator list for a designator with the given code.
virtual void handleDesignatorRemoved(DtReflectedDesignator *des)
Handles the removal of a designator.
virtual void tick(double dt) override
Performs periodic checks of monitored designator positions.
Abstract base class for all VREngage messages.
Definition vreMessage.h:50
Defines export macros and protocol namespace for vrePlayerStationConnector.
#define VRL_DLL
Empty definition for non-Windows platforms.
Definition export.h:52
!
Definition glsVreMessageUtil.h:50
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33
Definition connectorAccessory.h:32
Definition appLauncherComponent.h:28
Defines the base DtSimEventConnector class for VREngage simulation events.
Defines the central message manager for the VREngage messaging system.