VR-Engage  2.2
Loading...
Searching...
No Matches
vreEmbeddedEntitiesController.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file vreEmbeddedEntitiesController.h
7//! \ingroup vreVrfmodel
8//! \brief Controller for managing embedded entities
9//!
10//! This file defines the DtVreEmbeddedEntitiesController class which handles all
11//! operations related to embedded entities, including state transitions, name resolution,
12//! task forwarding, recovery, deployment, and other management functions.
13
14#pragma once
15
16#include "vreVrfmodel/export.h"
18
19#include <vrfmodel/embeddedEntitiesController.h>
20
21namespace makVre
22{
23//! \brief Type identifier for the VRE embedded entities controller component
24const char DtVreEmbeddedEntitiesControllerType[] = "vre-embedded-entities-controller";
25
26//! \brief Controller for managing embedded entities and their operations
27//!
28//! DtVreEmbeddedEntitiesController handles all tasking and name resolution of embedded entities.
29//! It manages state transitions, name resolution, task/set forwarding to embedded entities,
30//! recovery, deployment, and other related operations. This VRE extension includes fixes for
31//! handling static embedded entities and preventing crashes during deployment.
32class VREVRFMODEL_DLL DtVreEmbeddedEntitiesController : public DtVreSimComponent<DtEmbeddedEntitiesController>
33{
34public:
35 //! \brief Constructor
36 //! \param name The name of this component
37 //! \param owner The local object that owns this component
38 //! \param simManager The simulation services manager
39 //! \param desc Component descriptor with configuration parameters
40 //! \param parentRegistry Optional parent registry for reader/writer functionality
41 //!
42 //! Creates a new embedded entities controller component with the specified parameters.
43 DtVreEmbeddedEntitiesController(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
44 DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0);
45
46 //! \brief Virtual destructor
47 //!
48 //! Cleans up resources used by the embedded entities controller component.
50
51 //! \brief Gets the type identifier for this component
52 //! \return String identifying the component type (DtVreEmbeddedEntitiesControllerType)
53 //!
54 //! Implements the DtSimComponent::type() method to return the
55 //! type identifier for this component.
56 virtual const char* type() const override;
57
58 //! \brief Factory method to create a new instance of this component
59 //! \param name The name for the new component
60 //! \param owner The local object that will own this component
61 //! \param simManager The simulation services manager
62 //! \param desc Optional component descriptor
63 //! \param parentRegistry Optional parent registry for reader/writer functionality
64 //! \return Pointer to the newly created component
65 //!
66 //! Static factory method used by the component creation system to instantiate
67 //! new instances of this component type.
68 static DtSimComponent* creator(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
69 DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0);
70
71protected:
72 //! \brief Recovers embedded entities
73 //! \return True if the recovery operation was successful, false otherwise
74 //!
75 //! Overridden to properly handle static embedded entities, such as tripod-mounted
76 //! launchers. This method implements the recovery process for embedded entities,
77 //! bringing them back to their parent entity when required.
78 virtual bool performRecovery() override;
79
80 //! \brief Deploys embedded entities
81 //! \return True if the deployment operation was successful, false otherwise
82 //!
83 //! Overridden to fix a crash that occurs when the embedded entity cannot be
84 //! created during deployment. This method safely handles deployment failures
85 //! and prevents simulation crashes.
86 virtual bool performDeployment() override;
87
88 //! \brief Commands an embedded entity to return to its parent
89 //! \param entityName The name of the embedded entity to return
90 //! \return True if the command was successfully issued, false otherwise
91 //!
92 //! Overridden to properly handle static embedded entities when commanding
93 //! them to return to their parent entity. This ensures proper behavior for
94 //! entities that don't normally move or navigate.
95 virtual bool commandEeToReturn(const DtString& entityName) override;
96
97 //! \brief Restores an embedded entity to its parent
98 //! \param eeStatus Pointer to the embedded entity status to restore
99 //!
100 //! Overridden to reset resources on deployed embedded entities during
101 //! the restoration process. This ensures proper resource management
102 //! when embedded entities are returned to their parent entity.
103 virtual void restoreEmbedded(DtRwEmbeddedEntityStatus* const eeStatus) override;
104
105 //! \brief Updates the controller state each simulation frame
106 //!
107 //! Adds embedded entity status information into extended data during
108 //! each simulation frame. This allows other components and systems to
109 //! access current information about embedded entities.
110 virtual void tick() override;
111
112 //! \brief Calculates the spawn position for an embedded entity
113 //! \return Vector containing the calculated spawn position coordinates
114 //!
115 //! Overridden to adjust the spawn point if the host entity is embarked in another entity.
116 //! Increases the release altitude by the embarkation parent entity's altitude, ensuring
117 //! that embedded entities are spawned at the correct position relative to both the
118 //! immediate parent and any carrier entity.
119 virtual DtVector calculateSpawnPosOfTarget() override;
120};
121
122} // namespace makVre
static DtSimComponent * creator(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Factory method to create a new instance of this component.
virtual bool commandEeToReturn(const DtString &entityName) override
Commands an embedded entity to return to its parent.
virtual void tick() override
Updates the controller state each simulation frame.
virtual DtVector calculateSpawnPosOfTarget() override
Calculates the spawn position for an embedded entity.
DtVreEmbeddedEntitiesController(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Constructor.
virtual const char * type() const override
Gets the type identifier for this component.
virtual bool performRecovery() override
Recovers embedded entities.
virtual void restoreEmbedded(DtRwEmbeddedEntityStatus *const eeStatus) override
Restores an embedded entity to its parent.
virtual bool performDeployment() override
Deploys embedded entities.
virtual ~DtVreEmbeddedEntitiesController() override
Virtual destructor.
DtVreSimComponent(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Definition vreSimComponent.h:54
Defines export macros for the vreVrfmodel library.
#define VREVRFMODEL_DLL
Definition export.h:22
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
const char DtVreEmbeddedEntitiesControllerType[]
Type identifier for the VRE embedded entities controller component.
Definition vreEmbeddedEntitiesController.h:24
Base template class for VR-Engage simulation components.