VR-Engage  2.2
Loading...
Searching...
No Matches
vortexConfiguration.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2024 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file vortexConfiguration.h
7//! \brief Provides configuration management for Vortex physics parameters
8//! \ingroup vreVrfVortex
9
10#pragma once
11
12#include <vreVrfVortex/export.h>
13
15
16#include <VxSim/VxSmartInterface.h>
17#include <VxSim/VxVHLInterface.h>
18
19#include <vector>
20
21class DtVrfObjectStateRepository;
22
23namespace VxData
24{
25class FieldBase;
26}
27
28namespace VxSim
29{
30class VxExtension;
31class VxPluginExtension;
32class VxVHLInterface;
33class VxSimulationState;
34} // namespace VxSim
35
36namespace makVre
37{
38//! \brief Base class for Vortex configuration elements
39//!
40//! Provides common functionality for storing and managing Vortex
41//! configuration parameters regardless of their data type.
43{
44public:
45 //! \brief Constructor with field initialization
46 //!
47 //! Creates a configuration element associated with the specified Vortex field.
48 //!
49 //! \param field Pointer to the Vortex field to be configured
50 explicit DtVortexConfigurationBaseElement(VxData::FieldBase* field);
51
52 //! \brief Virtual destructor
53 //!
54 //! Allows for proper cleanup of derived classes.
56
57 //! \brief Gets the associated Vortex field
58 //!
59 //! \return Pointer to the Vortex field being configured
60 virtual VxData::FieldBase* getField();
61
62 //! \brief Sets the associated Vortex field
63 //!
64 //! \param fb Pointer to the Vortex field to be configured
65 virtual void setField(VxData::FieldBase* fb);
66
67 //! \brief Gets the Vortex identifier
68 //!
69 //! \return The Vortex ID of the configured field
70 virtual const Vx::VxID& vxId();
71
72 //! \brief Sets the Vortex identifier
73 //!
74 //! \param vortexId The Vortex ID to associate with this element
75 virtual void setVxId(const Vx::VxID& vortexId);
76
77 //! \brief Updates the configuration value in Vortex
78 //!
79 //! Pure virtual function that must be implemented by derived classes
80 //! to update the Vortex field with the stored value.
81 //!
82 //! \return True if the update succeeded, false otherwise
83 virtual bool updateConfigValue() = 0;
84
85protected:
86 VxData::FieldBase* myVortexField; //!< Pointer to the Vortex field being configured
87 Vx::VxID myVortexId; //!< Vortex ID of the configured field
88};
89
90
91//! \brief Templated class for storing and updating typed configuration values
92//!
93//! Extends the base configuration element with type-specific storage and update logic.
94//! Specializations exist for certain types that require custom handling (e.g., DtVector).
95template <typename T>
97{
98public:
99 //! \brief Constructor with field initialization
100 //!
101 //! Creates a typed configuration element associated with the specified Vortex field.
102 //!
103 //! \param field Pointer to the Vortex field to be configured
104 explicit DtVortexConfigurationElement(VxData::FieldBase* field);
105
106 //! \brief Virtual destructor
107 //!
108 //! Allows for proper cleanup of derived classes.
110
111 //! \brief Updates the Vortex field with the stored value
112 //!
113 //! Implements the pure virtual function from the base class to
114 //! set the value in the Vortex field.
115 //!
116 //! \return True if the update succeeded, false otherwise
117 virtual bool updateConfigValue() override;
118
119 //! \brief Gets the current configuration value
120 //!
121 //! \return The current value stored in this configuration element
122 T value() { return myValue; }
123
124 //! \brief Sets the configuration value
125 //!
126 //! \param val The value to store in this configuration element
127 void setValue(const T& val);
128
129protected:
130 T myValue; //!< The typed value stored in this configuration element
131};
132
133
134//! \brief Type definitions for configuration entries
135//!
136//! ConfigurationEntry pairs a descriptor with its associated path strings.
137//! ConfigurationEntryList is a collection of these entries.
138using ConfigurationEntry = std::pair<DtVortexConfigurationElementDescriptor*, std::vector<std::string>>;
139using ConfigurationEntryList = std::vector<ConfigurationEntry>;
140
141//! \brief Main class for managing Vortex configuration parameters
142//!
143//! Handles parsing of configuration descriptors and updating of Vortex fields
144//! with the specified values. Supports configuration via the VxVHLInterface.
146{
147public:
148 //! \brief Constructor with interface and descriptor
149 //!
150 //! Initializes the configuration manager with the specified Vortex interface
151 //! and configuration descriptor.
152 //!
153 //! \param iface Weak interface to the Vortex VHL interface
154 //! \param desc Descriptor containing the configuration settings to apply
155 DtVortexConfiguration(VxSim::VxWeakInterface<VxSim::VxVHLInterface> iface, DtVortexConfigurationDescriptor desc);
156
157 //! \brief Destructor
158 //!
159 //! Cleans up resources used by the configuration manager.
161
162 //! \brief Parses the configuration descriptor
163 //!
164 //! Iterates through the top-level entries in the descriptor and processes
165 //! each one according to its type. For each entry, it locates the corresponding
166 //! Vortex field and creates a configuration element to store the value.
167 virtual void parseValues();
168
169 //! \brief Updates all configuration values in Vortex
170 //!
171 //! Applies all stored configuration values to their corresponding
172 //! Vortex fields. This method should be called after parseValues()
173 //! to apply the configuration.
174 virtual void updateVehicle();
175
176protected:
177 //! \brief Parses a configuration element using the Vortex interface
178 //!
179 //! Locates the specified parameter in Vortex via the VHL interface
180 //! and creates a configuration element for it.
181 //!
182 //! \param elementDescriptor Descriptor for the element to parse
184
185 //! \brief Parses and adds a configuration element
186 //!
187 //! Creates a typed configuration element based on the descriptor's value
188 //! type and adds it to the collection of elements.
189 //!
190 //! \param field Pointer to the Vortex field to configure
191 //! \param elementDescriptor Descriptor containing the value to apply
192 virtual void parseAndAddElement(VxData::FieldBase* field, DtVortexConfigurationElementDescriptor* elementDescriptor);
193
194protected:
195 VxSim::VxWeakInterface<VxSim::VxVHLInterface> myInterface; //!< Interface to the Vortex VHL system
196
197 DtVortexConfigurationDescriptor myDescriptor; //!< Descriptor containing configuration settings
198 std::vector<std::shared_ptr<DtVortexConfigurationBaseElement>>
199 myParameterElements; //!< Collection of configured elements
200};
201} // namespace makVre
virtual void setVxId(const Vx::VxID &vortexId)
Sets the Vortex identifier.
virtual const Vx::VxID & vxId()
Gets the Vortex identifier.
virtual ~DtVortexConfigurationBaseElement()
Virtual destructor.
DtVortexConfigurationBaseElement(VxData::FieldBase *field)
Constructor with field initialization.
Vx::VxID myVortexId
Vortex ID of the configured field.
Definition vortexConfiguration.h:87
virtual VxData::FieldBase * getField()
Gets the associated Vortex field.
VxData::FieldBase * myVortexField
Pointer to the Vortex field being configured.
Definition vortexConfiguration.h:86
virtual bool updateConfigValue()=0
Updates the configuration value in Vortex.
virtual void setField(VxData::FieldBase *fb)
Sets the associated Vortex field.
Descriptor for Vortex physics engine configurations.
Definition vortexConfigurationDescriptor.h:27
Descriptor for individual Vortex physics configuration parameters.
Definition vortexConfigurationElementDescriptor.h:34
DtVortexConfigurationElement(VxData::FieldBase *field)
Constructor with field initialization.
virtual ~DtVortexConfigurationElement() override
Virtual destructor.
T myValue
The typed value stored in this configuration element.
Definition vortexConfiguration.h:130
T value()
Gets the current configuration value.
Definition vortexConfiguration.h:122
virtual bool updateConfigValue() override
Updates the Vortex field with the stored value.
void setValue(const T &val)
Sets the configuration value.
virtual void parseAndAddElement(VxData::FieldBase *field, DtVortexConfigurationElementDescriptor *elementDescriptor)
Parses and adds a configuration element.
VxSim::VxWeakInterface< VxSim::VxVHLInterface > myInterface
Interface to the Vortex VHL system.
Definition vortexConfiguration.h:195
virtual void parseUsingInterface(DtVortexConfigurationElementDescriptor *elementDescriptor)
Parses a configuration element using the Vortex interface.
virtual ~DtVortexConfiguration()
Destructor.
virtual void parseValues()
Parses the configuration descriptor.
std::vector< std::shared_ptr< DtVortexConfigurationBaseElement > > myParameterElements
Collection of configured elements.
Definition vortexConfiguration.h:199
DtVortexConfiguration(VxSim::VxWeakInterface< VxSim::VxVHLInterface > iface, DtVortexConfigurationDescriptor desc)
Constructor with interface and descriptor.
DtVortexConfigurationDescriptor myDescriptor
Descriptor containing configuration settings.
Definition vortexConfiguration.h:197
virtual void updateVehicle()
Updates all configuration values in Vortex.
Export macros for the VR-Forces Vortex extension library.
#define VREVRFVORTEX_DLL
Export macro for non-Windows platforms.
Definition export.h:30
Definition vortexConfiguration.h:24
Definition vortexConfiguration.h:29
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
std::pair< DtVortexConfigurationElementDescriptor *, std::vector< std::string > > ConfigurationEntry
Type definitions for configuration entries.
Definition vortexConfiguration.h:138
std::vector< ConfigurationEntry > ConfigurationEntryList
Definition vortexConfiguration.h:139
Defines DtVortexConfigurationDescriptor for managing Vortex physics configuration parameters.