VR-Engage  2.2
Loading...
Searching...
No Matches
vreVrvExtensions.h
Go to the documentation of this file.
1/*********************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*********************************************************************************/
5
6//! \file vreVrvExtensions.h
7//! \brief Provides VREngage-specific extensions to the VR-Vantage runtime system
8//!
9//! This file contains declarations of classes needed to override the type of
10//! reflected entity list created in a DtVrlinkConnection. By default, VR-Vantage
11//! creates reflected entity list derived from DtReflectedEntityList. However, VR-Engage
12//! creates a DtVrfRemoteController that requires a DtReflectedExtEntityList. Therefore
13//! the reflected entity list created by VR-Vantage must be a DtReflectedExtEntityList,
14//! enabling a single list to be used and shared by multiple classes in the VR-Engage
15//! front-end. Overriding this requires replacing the DtReflectedEntityList and
16//! DtEntityStateRepository with corresponding DtReflectedExtEntityList and
17//! DtExtEntityStateRepository types.
18//!
19//! DtVreEntityReflectedListCreator and DtVreEntityStateInterceptorCreator instances
20//! are registered in DtConnectorAccessory::slot_onSimCreated(), ensuring that our
21//! derived reflected list and derived state repository classes get created by VR-Vantage.
22
23#pragma once
24
26
27#include <vrvVrl/DtVrlinkConnection.h>
28#include <vrvVrl/DtEntityStateInterceptorCreator.h>
29#include <vrvVrl/DtCustomReflectedEntityList.h>
30#include <vrvVrl/DtVrlinkReflectedAerodromeList.h>
31#include <vrfExtObjects/extEntityStateRepository.h>
32
34#include <vrfobjparam/smsLoader.h>
35
36class DtReflectedExtEntityList;
37class DtReflectedExtEntity;
38class DtExtEntityStateRepository;
39
40
41namespace makVre
42{
43//! \brief Type of derived reflected entity list to create in VR-Vantage's DtVrlinkConnection
44//!
45//! This type alias defines a custom reflected entity list based on DtReflectedExtEntityList,
46//! DtReflectedExtEntity, and DtExtEntityStateRepository classes
47using DtVreBaseCustomReflectedEntityList = makVrv::DT_PROTOCOL_NAMESPACE::DtCustomReflectedEntityList<
48 DtReflectedExtEntityList, DtReflectedExtEntity, DtExtEntityStateRepository>;
49
50//! \brief VREngage-specific implementation of the reflected entity list
51//!
52//! Extends the base custom reflected entity list to provide VREngage-specific functionality,
53//! including parameter database handling and interaction with simulation model sets.
55{
56public:
57 //! \brief Constructor for non-HLA protocols
58 //! \param listener Reference to the entity element processor that will receive entity events
59 DtVreCustomReflectedEntityList(makVrv::DT_PROTOCOL_NAMESPACE::DtEntityElementProcessor& listener)
61 {
62 }
63
64#if defined(DtHLA)
65 //! \brief Constructor for HLA protocol
66 //! \param listener Reference to the entity element processor that will receive entity events
67 //! \param regionsToUse Reference to the DDM regions to use for this entity list
69 makVrv::DT_PROTOCOL_NAMESPACE::DtEntityElementProcessor& listener, const DtDDMRegionSet& regionsToUse)
70 : DtVreBaseCustomReflectedEntityList(listener, regionsToUse)
71 {
72 }
73#endif
74
75 //! \brief Virtual destructor
76 //!
77 //! Removes message handlers registered during initialization
79
80 //! \brief Initializes the reflected entity list
81 //!
82 //! Registers parameter factories for various entity types and sets up
83 //! message handlers for simulation model set handling
84 virtual void initialize();
85
86 //! \brief Handles a newly added entity
87 //! \param ent Pointer to the entity that was added
88 //!
89 //! Registers a callback for entity updates and performs base class handling
90 virtual void entityAdded(DtReflectedEntity* ent) override;
91
92 //! \brief Determines if an entity is ready to be added to the list
93 //! \param obj Pointer to the reflected object to check
94 //! \return True if the entity should be added, false otherwise
95 //!
96 //! Called when an entity has been discovered and needs to be added to the list
97 virtual bool readyToAdd(DtReflectedObject* obj) override;
98
99 //! \brief Static callback function for entity updates
100 //! \param entity Pointer to the entity that was updated
101 //! \param usr User data pointer (points to the DtVreCustomReflectedEntityList instance)
102 static void entityUpdatedCallback(DtReflectedEntity* entity, void* usr);
103
104 //! \brief Handles entity updates
105 //! \param ent Pointer to the entity that was updated
106 //!
107 //! Overridden function to process entity updates
108 virtual void entityUpdated(DtReflectedEntity* ent) override;
109
110 //! \brief Gets the parameter database associated with this entity list
111 //! \return Pointer to the parameter database
112 //!
113 //! Returns the parameter database from the SMS loader
114 DtVrfParameterDb* parameterDatabase();
115
116protected:
117 //! \brief Discovers and initializes an entity with parameter data
118 //! \param obj Pointer to the reflected object to discover
119 //! \param entSR Pointer to the entity state repository
120 //!
121 //! Attempts to find parameter data for the entity in the parameter database
122 virtual void discoverEntity(DtReflectedObject* obj, DtExtEntityStateRepository* entSR);
123
124 //! \brief Handles simulation model set list messages
125 //! \param msg Pointer to the message containing the SMS list
126 //! \return Message result indicating how the message was handled
127 //!
128 //! Ensures the SMS list has been loaded successfully and updates parameters if needed
130
131protected:
132 //! \brief Loader for simulation model sets
133 DtSmsLoader mySmsLoader;
134
135 //! \brief Currently loaded simulation model set filenames
136 std::vector<std::string> mySms;
137
138 //! \brief Type alias for mapping reflected objects to entity types
139 using InitializedTypeMap = std::map<DtReflectedObject*, DtEntityType>;
140
141 //! \brief Map of reflected objects to their entity types
142 //!
143 //! Tracks which entities have been initialized with which entity types
145
146 //! \brief Type alias for the set of missing entity types
147 using MissingTypeSet = std::set<DtEntityType>;
148
149 //! \brief Set of entity types we know aren't in the parameter database
150 //!
151 //! This prevents entities with unknown parameter types from searching
152 //! the parameter database every time there's a network update
154};
155
156//! \brief Creator class for DtVreCustomReflectedEntityList instances
157//!
158//! This class overrides the default entity reflected list creator to produce
159//! VREngage-specific reflected entity lists
160class VRL_DLL DtVreEntityReflectedListCreator : public makVrv::DT_PROTOCOL_NAMESPACE::DtVrvEntityReflectedListCreator
161{
162public:
163 //! \brief Gets or creates the singleton instance for a specific connection
164 //! \param sim Reference to the VR-Link connection to associate with this creator
165 //! \return Reference to the singleton instance
166 static DtVrvEntityReflectedListCreator& instance(makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection& sim);
167
168 //! \brief Creates a new reflected entity list
169 //! \param listener Reference to the entity element processor that will receive entity events
170 //! \return Pointer to the newly created reflected entity list
171 //!
172 //! Creates a DtVreCustomReflectedEntityList instance and initializes it
173 virtual DtReflectedEntityList* create(makVrv::DT_PROTOCOL_NAMESPACE::DtEntityElementProcessor& listener) override;
174
175#if defined(DtHLA)
176 //! \brief Creates a new reflected entity list with DDM regions (HLA-specific)
177 //! \param l Reference to the entity element processor that will receive entity events
178 //! \param r Reference to the DDM regions to use
179 //! \return Pointer to the newly created reflected entity list
180 virtual DtReflectedEntityList* create(makVrv::DT_PROTOCOL_NAMESPACE::DtEntityElementProcessor& l,
181 const DtDDMRegionSet& r) override;
182#endif
183
184protected:
185 //! \brief Constructor
186 //! \param sim Reference to the VR-Link connection to associate with this creator
187 DtVreEntityReflectedListCreator(makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection& sim);
188};
189
190//! \brief Creator class for the DtEntityStateRepository derived from DtExtEntityStateRepository
191//!
192//! This class overrides the default entity state interceptor creator to produce
193//! VREngage-specific entity state repositories
194class VRL_DLL DtVreEntityStateInterceptorCreator : public makVrv::DT_PROTOCOL_NAMESPACE::DtEntityStateInterceptorCreator
195{
196public:
197 //! \brief Gets or creates the singleton instance for a specific connection
198 //! \param sim Reference to the VR-Link connection to associate with this creator
199 //! \return Reference to the singleton instance
200 static DtEntityStateInterceptorCreator& instance(makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection& sim);
201
202 //! \brief Default constructor
204
205 //! \brief Virtual destructor
207
208 //! \brief Creates a new entity state repository
209 //! \param listener Pointer to the entity state listener that will receive entity state events
210 //! \return Pointer to the newly created entity state repository
211 //!
212 //! Creates an entity state interceptor using DtExtEntityStateRepository
213 virtual DtEntityStateRepository* create(makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkEntityStateListener* listener) override;
214};
215
216//! \brief Creator class for aerodrome reflected lists
217//!
218//! This class overrides the default aerodrome reflected list creator to produce
219//! VREngage-specific aerodrome reflected lists based on DtReflectedExtAerodromeList
221 : public makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkReflectedAerodromeListCreator
222{
223public:
224 //! \brief Gets or creates the singleton instance for a specific connection
225 //! \param sim Reference to the VR-Link connection to associate with this creator
226 //! \return Reference to the singleton instance
227 static makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkReflectedAerodromeListCreator& instance(
228 makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection& sim);
229
230 //! \brief Creates a new aerodrome reflected list
231 //! \param l Reference to the aerodrome existence listener
232 //! \return Pointer to the newly created aerodrome reflected list
233 virtual DtReflectedAerodromeList* create(makVrv::DT_PROTOCOL_NAMESPACE::DtAerodromeExistenceListener& l) override;
234#if defined(DtHLA)
235 //! \brief Creates a new aerodrome reflected list with DDM regions (HLA-specific)
236 //! \param l Reference to the aerodrome existence listener
237 //! \param s Pointer to the DDM regions to use
238 //! \return Pointer to the newly created aerodrome reflected list
239 virtual DtReflectedAerodromeList* create(
240 makVrv::DT_PROTOCOL_NAMESPACE::DtAerodromeExistenceListener& l, const DtDDMRegionSet* s) override;
241#endif
242
243protected:
244 //! \brief Constructor
245 //! \param sim Reference to the VR-Link connection to associate with this creator
246 DtVreAerodromeReflectedListCreator(makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection& sim);
247};
248
249} // namespace makVre
virtual DtReflectedAerodromeList * create(makVrv::DT_PROTOCOL_NAMESPACE::DtAerodromeExistenceListener &l, const DtDDMRegionSet *s) override
Creates a new aerodrome reflected list with DDM regions (HLA-specific)
virtual DtReflectedAerodromeList * create(makVrv::DT_PROTOCOL_NAMESPACE::DtAerodromeExistenceListener &l) override
Creates a new aerodrome reflected list.
static makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkReflectedAerodromeListCreator & instance(makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection &sim)
Gets or creates the singleton instance for a specific connection.
DtVreAerodromeReflectedListCreator(makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection &sim)
Constructor.
MissingTypeSet myMissingTypes
Set of entity types we know aren't in the parameter database.
Definition vreVrvExtensions.h:153
std::set< DtEntityType > MissingTypeSet
Type alias for the set of missing entity types.
Definition vreVrvExtensions.h:147
virtual ~DtVreCustomReflectedEntityList() override
Virtual destructor.
virtual void initialize()
Initializes the reflected entity list.
std::vector< std::string > mySms
Currently loaded simulation model set filenames.
Definition vreVrvExtensions.h:136
DtSmsLoader mySmsLoader
Loader for simulation model sets.
Definition vreVrvExtensions.h:133
virtual void discoverEntity(DtReflectedObject *obj, DtExtEntityStateRepository *entSR)
Discovers and initializes an entity with parameter data.
std::map< DtReflectedObject *, DtEntityType > InitializedTypeMap
Type alias for mapping reflected objects to entity types.
Definition vreVrvExtensions.h:139
InitializedTypeMap myInitializedWithType
Map of reflected objects to their entity types.
Definition vreVrvExtensions.h:144
virtual bool readyToAdd(DtReflectedObject *obj) override
Determines if an entity is ready to be added to the list.
DtVreCustomReflectedEntityList(makVrv::DT_PROTOCOL_NAMESPACE::DtEntityElementProcessor &listener)
Constructor for non-HLA protocols.
Definition vreVrvExtensions.h:59
virtual void entityUpdated(DtReflectedEntity *ent) override
Handles entity updates.
DtVrfParameterDb * parameterDatabase()
Gets the parameter database associated with this entity list.
virtual DtVreMessageResult handleSessionSmsList(DtVreMessage *msg)
Handles simulation model set list messages.
static void entityUpdatedCallback(DtReflectedEntity *entity, void *usr)
Static callback function for entity updates.
DtVreCustomReflectedEntityList(makVrv::DT_PROTOCOL_NAMESPACE::DtEntityElementProcessor &listener, const DtDDMRegionSet &regionsToUse)
Constructor for HLA protocol.
Definition vreVrvExtensions.h:68
virtual void entityAdded(DtReflectedEntity *ent) override
Handles a newly added entity.
virtual DtReflectedEntityList * create(makVrv::DT_PROTOCOL_NAMESPACE::DtEntityElementProcessor &l, const DtDDMRegionSet &r) override
Creates a new reflected entity list with DDM regions (HLA-specific)
static DtVrvEntityReflectedListCreator & instance(makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection &sim)
Gets or creates the singleton instance for a specific connection.
DtVreEntityReflectedListCreator(makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection &sim)
Constructor.
virtual DtReflectedEntityList * create(makVrv::DT_PROTOCOL_NAMESPACE::DtEntityElementProcessor &listener) override
Creates a new reflected entity list.
virtual ~DtVreEntityStateInterceptorCreator() override
Virtual destructor.
DtVreEntityStateInterceptorCreator()
Default constructor.
static DtEntityStateInterceptorCreator & instance(makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection &sim)
Gets or creates the singleton instance for a specific connection.
virtual DtEntityStateRepository * create(makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkEntityStateListener *listener) override
Creates a new entity state repository.
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
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
makVrv::DT_PROTOCOL_NAMESPACE::DtCustomReflectedEntityList< DtReflectedExtEntityList, DtReflectedExtEntity, DtExtEntityStateRepository > DtVreBaseCustomReflectedEntityList
Type of derived reflected entity list to create in VR-Vantage's DtVrlinkConnection.
Definition vreVrvExtensions.h:47
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33
Defines the base class for all VREngage messages.