VR-Engage  2.2
Loading...
Searching...
No Matches
friendlyUnitsConnector.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file friendlyUnitsConnector.h
7//! \brief Defines the DtFriendlyUnitsConnector class for tracking friendly units
8//!
9//! This connector tracks entities and aggregates with the same force ID as the player's
10//! entity and provides updates when the set of friendly units changes.
11
12#pragma once
13
14#include "export.h"
15
17
18//! \brief Forward declaration of the exercise connection class
19class DtExerciseConn;
20
21//! \brief Forward declaration of the reflected entity class
22class DtReflectedEntity;
23
24//! \brief Forward declaration of the reflected aggregate class
25class DtReflectedAggregate;
26
27//! \brief Forward declaration of the reflected entity list class
28class DtReflectedEntityList;
29
30//! \brief Forward declaration of the reflected aggregate list class
31class DtReflectedAggregateList;
32
33namespace makVre
34{
35//! \brief Connector for tracking and reporting friendly units in the simulation
36//!
37//! DtFriendlyUnitsConnector monitors entities and aggregates that have the same
38//! force ID as the player's entity. It maintains an alphabetically sorted list
39//! of friendly unit names and sends updates when the list changes.
41{
42public:
43 //! \brief Default constructor
44 //!
45 //! Initializes member variables with default values and sets the connector name to "FriendlyUnitsTime"
47
48 //! \brief Virtual destructor
49 virtual ~DtFriendlyUnitsConnector() override;
50
51 //! \brief Installs the friendly units connector with the application and connection
52 //! \param app Pointer to the player station application
53 //! \param connection Pointer to the protocol-specific VR-Link connection
54 //!
55 //! Registers callbacks for entity and aggregate addition/removal and retrieves the
56 //! player's entity ID and reflected entity list
57 virtual void install(
58 DtPlayerStationApp* app, makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection* connection) override;
59
60 //! \brief Performs periodic checking of friendly units
61 //!
62 //! Determines the player's force ID if not yet known and updates the
63 //! friendly units list if changes have been detected
64 virtual void tick() override;
65
66 //! \brief Shuts down the friendly units connector
67 //!
68 //! Removes entity and aggregate callbacks and cleans up resources
69 virtual void shutdown() override;
70
71 //! \brief Handles changes to the entity list
72 //! \param ent Pointer to the entity that was added or removed
73 //!
74 //! Called when an entity is added to or removed from the reflected entity list
75 //! Sets the update flag to trigger a refresh of the friendly units list
76 virtual void handleEntityListChanged(DtReflectedEntity* ent);
77
78 //! \brief Handles changes to the aggregate list
79 //! \param agg Pointer to the aggregate that was added or removed
80 //!
81 //! Called when an aggregate is added to or removed from the reflected aggregate list
82 //! Sets the update flag to trigger a refresh of the friendly units list
83 virtual void handleAggregateListChanged(DtReflectedAggregate* agg);
84
85protected:
86 //! \brief Updates the list of friendly unit names and sends a message
87 //!
88 //! Collects all entities and aggregates with the same force ID as the player,
89 //! sorts them alphabetically, and sends an EntityFriendlyUnitsMessage with the results
91
92 //! \brief Force ID of the player's entity
93 //!
94 //! Used to identify which entities and aggregates are friendly
95 DtForceType myForceId;
96
97 //! \brief Entity ID of the player's entity
98 DtEntityIdentifier myEntityId;
99
100 //! \brief Pointer to the reflected entity list
101 DtReflectedEntityList* myRel;
102
103 //! \brief Pointer to the reflected aggregate list
104 //!
105 //! This is created and owned by the connector, not just referenced
106 DtReflectedAggregateList* myRal;
107
108 //! \brief Flag indicating whether an update is needed
109 //!
110 //! Set to true when entities or aggregates are added or removed
112};
113} // namespace makVre
Base class for all simulation event connectors in VREngage.
Definition simEventConnector.h:54
void updateNames()
Updates the list of friendly unit names and sends a message.
bool myUpdateNeeded
Flag indicating whether an update is needed.
Definition friendlyUnitsConnector.h:111
virtual ~DtFriendlyUnitsConnector() override
Virtual destructor.
DtEntityIdentifier myEntityId
Entity ID of the player's entity.
Definition friendlyUnitsConnector.h:98
virtual void install(DtPlayerStationApp *app, makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection *connection) override
Installs the friendly units connector with the application and connection.
DtReflectedEntityList * myRel
Pointer to the reflected entity list.
Definition friendlyUnitsConnector.h:101
DtReflectedAggregateList * myRal
Pointer to the reflected aggregate list.
Definition friendlyUnitsConnector.h:106
DtFriendlyUnitsConnector()
Default constructor.
virtual void handleAggregateListChanged(DtReflectedAggregate *agg)
Handles changes to the aggregate list.
DtForceType myForceId
Force ID of the player's entity.
Definition friendlyUnitsConnector.h:95
virtual void tick() override
Performs periodic checking of friendly units.
virtual void handleEntityListChanged(DtReflectedEntity *ent)
Handles changes to the entity list.
virtual void shutdown() override
Shuts down the friendly units connector.
Top-level class representing the VR-Engage application.
Definition playerStationApp.h:163
Defines export macros and protocol namespace for vrePlayerStationConnector.
#define VRL_DLL
Empty definition for non-Windows platforms.
Definition export.h:52
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
Defines the base DtSimEventConnector class for VREngage simulation events.