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