VR-Engage  2.2
Loading...
Searching...
No Matches
vortexStateRepository.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file vortexStateRepository.h
7//! \brief State repository for Vortex physics entities
8//! \ingroup vreVrfVortex
9
10#pragma once
11
12#include <vreVrfVortex/export.h>
13
14#include <vlutil/vlMachineTypes.h>
15#include <vrfobjcore/groundVehicleStateRepository.h>
16#include <vrfobjcore/vrfObjectStateRepository.h>
17#include <readerWriter/noArgumentCallbackList.h>
18
19#include <matrix/vlVector.h>
20
21class DtSpaceEntityParameters;
22
23//! \brief Type identifier for the Vortex state repository
24const char DtVortexStateRepositoryType[] = "vortex-state-repository";
25
26//! \brief Function type for location change callbacks
27//!
28//! \param location The new location
29//! \param userData User data pointer passed to the callback
30using DtLocationCallbackFunction = void (*)(const DtVector& location, void* userData);
31
32//! \brief Function type for heading change callbacks
33//!
34//! \param heading The new heading
35//! \param userData User data pointer passed to the callback
36using DtHeadingCallbackFunction = void (*)(DtReal heading, void* userData);
37
38//! \brief Callback list type for location changes
39using DtLocationCallbackList = DtCallbackList<const DtVector&>;
40
41//! \brief Callback list type for heading changes
42using DtHeadingCallbackList = DtCallbackList<DtReal>;
43
44//! \brief State repository for Vortex physics entities
45//!
46//! Extends the ground vehicle state repository to provide specialized
47//! state management for entities using the Vortex physics engine.
48//! Includes support for location and heading change callbacks.
49//!
50//! \note Since version 5.0, this class no longer provides a copy constructor
51//! or assignment operator. Also, the constructor prototype has changed
52//! to remove the object type and parameters.
53class VREVRFVORTEX_DLL DtVortexStateRepository : public DtGroundVehicleStateRepository
54{
55private:
56 //! \brief Copy constructor (private, not implemented)
58
59 //! \brief Assignment operator (private, not implemented)
61
62public:
63 //! \brief Constructor
64 //!
65 //! Creates a new state repository with the specified parameters.
66 //!
67 //! \param vrfObject The VR-Forces object to associate with
68 //! \param name Name for the repository
69 //! \param parentRegistry Optional parent registry
70 DtVortexStateRepository(DtLocalObject* vrfObject, const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
71
72 //! \brief Destructor
73 virtual ~DtVortexStateRepository() override;
74
75 //! \brief Gets the type of this repository
76 //!
77 //! Returns a unique string identifying the type of component,
78 //! used as key in the state repository factory.
79 //!
80 //! \return Type string "vortex-state-repository"
81 virtual DtString type() const override;
82
83 //! \brief Factory method to create new instances
84 //!
85 //! Returns a newly created instance of this class. To be registered
86 //! with the state repository factory.
87 //!
88 //! \param name Name for the repository
89 //! \param vrfObject The VR-Forces object to associate with
90 //! \param parentRegistry Optional parent registry
91 //! \return Pointer to the new repository
92 static DtVrfObjectStateRepository* creator(
93 const DtString& name, DtLocalObject* vrfObject, DtReaderWriterRegistry* parentRegistry);
94
95 //! \brief Safe type-checking conversion
96 //!
97 //! Returns the pointer to the repository if the repository passed
98 //! in is of type DtVortexStateRepository, nullptr if not.
99 //!
100 //! \param repository Repository to cast
101 //! \return Typed pointer or nullptr if wrong type
102 static DtVortexStateRepository* asVortexStateRepository(const DtVrfObjectStateRepository* repository);
103
104 //! \brief Places the entity at a new location and heading
105 //!
106 //! Positions the entity at the specified location and heading, then
107 //! invokes all registered location and heading change callbacks.
108 //!
109 //! \param location The new position vector
110 //! \param heading The new heading in radians
111 //! \param clampToGroundFlag Whether to clamp the entity to ground
112 //! \param dataAvailable Optional pointer to receive data availability status
113 //! \param requireAllData Whether all data must be available
114 virtual void place(const DtVector& location, const DtReal heading, bool clampToGroundFlag /* = true */,
115 bool* dataAvailable /* = 0 */, bool requireAllData /* = false */) override;
116
117 //! \brief Adds a location change callback
118 //!
119 //! Registers a function to be called when the entity's location changes.
120 //! The callback will be invoked whenever the place() method is called.
121 //!
122 //! \param function Callback function to add
123 //! \param userData User data to pass to the callback
124 virtual void addLocationChangedCallback(DtLocationCallbackFunction function, void* userData);
125
126 //! \brief Removes a location change callback
127 //!
128 //! Unregisters a previously added location change callback.
129 //!
130 //! \param function Callback function to remove
131 //! \param userData User data associated with the callback
132 virtual void removeLocationChangedCallback(DtLocationCallbackFunction function, void* userData);
133
134 //! \brief Adds a heading change callback
135 //!
136 //! Registers a function to be called when the entity's heading changes.
137 //! The callback will be invoked whenever the place() method is called.
138 //!
139 //! \param function Callback function to add
140 //! \param userData User data to pass to the callback
141 virtual void addHeadingChangedCallback(DtHeadingCallbackFunction function, void* userData);
142
143 //! \brief Removes a heading change callback
144 //!
145 //! Unregisters a previously added heading change callback.
146 //!
147 //! \param function Callback function to remove
148 //! \param userData User data associated with the callback
149 virtual void removeHeadingChangedCallback(DtHeadingCallbackFunction function, void* userData);
150
151protected:
152 DtLocationCallbackList myLocationCallbackList; //!< List of location change callbacks
153 DtHeadingCallbackList myHeadingCallbackList; //!< List of heading change callbacks
154};
static DtVortexStateRepository * asVortexStateRepository(const DtVrfObjectStateRepository *repository)
Safe type-checking conversion.
DtHeadingCallbackList myHeadingCallbackList
List of heading change callbacks.
Definition vortexStateRepository.h:153
DtVortexStateRepository(DtLocalObject *vrfObject, const DtString &name, DtReaderWriterRegistry *parentRegistry=0)
Constructor.
virtual void addLocationChangedCallback(DtLocationCallbackFunction function, void *userData)
Adds a location change callback.
const DtVortexStateRepository & operator=(const DtVortexStateRepository &orig)
Assignment operator (private, not implemented)
virtual void place(const DtVector &location, const DtReal heading, bool clampToGroundFlag, bool *dataAvailable, bool requireAllData) override
Places the entity at a new location and heading.
virtual void addHeadingChangedCallback(DtHeadingCallbackFunction function, void *userData)
Adds a heading change callback.
static DtVrfObjectStateRepository * creator(const DtString &name, DtLocalObject *vrfObject, DtReaderWriterRegistry *parentRegistry)
Factory method to create new instances.
virtual void removeLocationChangedCallback(DtLocationCallbackFunction function, void *userData)
Removes a location change callback.
DtVortexStateRepository(const DtVortexStateRepository &orig)
Copy constructor (private, not implemented)
virtual ~DtVortexStateRepository() override
Destructor.
virtual void removeHeadingChangedCallback(DtHeadingCallbackFunction function, void *userData)
Removes a heading change callback.
DtLocationCallbackList myLocationCallbackList
List of location change callbacks.
Definition vortexStateRepository.h:152
virtual DtString type() const override
Gets the type of this repository.
Export macros for the VR-Forces Vortex extension library.
#define VREVRFVORTEX_DLL
Export macro for non-Windows platforms.
Definition export.h:30
DtCallbackList< DtReal > DtHeadingCallbackList
Callback list type for heading changes.
Definition vortexStateRepository.h:42
const char DtVortexStateRepositoryType[]
Type identifier for the Vortex state repository.
Definition vortexStateRepository.h:24
void(*)(const DtVector &location, void *userData) DtLocationCallbackFunction
Function type for location change callbacks.
Definition vortexStateRepository.h:30
DtCallbackList< const DtVector & > DtLocationCallbackList
Callback list type for location changes.
Definition vortexStateRepository.h:39
void(*)(DtReal heading, void *userData) DtHeadingCallbackFunction
Function type for heading change callbacks.
Definition vortexStateRepository.h:36