WSF
WsfSixDOF_TypeManager.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2020 Infoscitex, a DCS Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11
12#ifndef WSFSIXDOFTYPEMANAGER_HPP
13#define WSFSIXDOFTYPEMANAGER_HPP
14
15#include "wsf_six_dof_export.h"
16
17#include <unordered_map>
18
19class UtInput;
21class WsfSimulation;
24#include "WsfSixDOF_Mover.hpp"
26
27namespace wsf
28{
29namespace six_dof
30{
32{
33public:
34 TypeManager() = default;
35 ~TypeManager() = default;
36
37 // The extension has been added to the scenario. GetScenario() is now callable.
38 // This adds "WSF_RIGID_BODY_SIX_DOF_MOVER" (WsfSixDOF_RigidBodyMover) and
39 // "WSF_POINT_MASS_SIX_DOF_MOVER" (WsfSixDOF_PointMassMover),
40 // "WSF_SIX_DOF_GUIDANCE_COMPUTER" (WsfSixDOF_GuidanceComputer),
41 // "WSF_SIX_DOF_FUEL" (WsfSixDOF_Fuel), and "WSF_SIX_DOF_EXPLICIT_WEAPON"
42 // (WsfSixDOF_ExplicitWeapon). It also registers ScriptTypes for
43 // WsfScriptRigidBodySixDOF_MoverClass (for WsfSixDOF_RigidBodyMover) and
44 // WsfScriptPointMassSixDOF_MoverClass (for WsfSixDOF_PointMassMover).
45 void AddedToScenario() override;
46
47 // This calls WsfSimulation::RegisterExtension() every time a new simulation is
48 // created, giving it a new SixDOF object manager.
49 void SimulationCreated(WsfSimulation& aSimulation) override;
50
51 // This reads "six_dof_object_types" input blocks
52 bool ProcessInput(UtInput& aInput) override;
53
54 // This reads "subobject" input blocks
55 bool ProcessSubObjectInput(UtInput& aInput, std::list<std::unique_ptr<Mover>>& aSubObjectList);
56
57 // This creates a new vehicle instance to push to a subobject list
58 std::unique_ptr<Mover> VehicleFactory(const Mover* aSubObjectType) const;
59
60 // SetIntegrators sets the RigidBodyIntegrator objects
61 void SetIntegrators(const std::string& aFilename);
62
63 // This returns an integrator of the specified type/name or null if
64 // no such integrator exists
65 Integrator* GetIntegratorByName(const std::string& aTypeName) const;
66
67 // This registers a mover. All ObjectType objects call this
68 // when being created. It allows the manager to be aware of all
69 // ObjectType objects. It returns false if it fails.
70 bool RegisterObjectType(std::unique_ptr<Mover> aObjectTypePtr);
71
72 // This de-registers a mover. This should be called prior to
73 // deleting an ObjectType. It allows the manager to be aware
74 // that the de-registered object is no longer available.
75 void UnregisterObjectType(const std::string& aTypeName);
76
77 // This returns a SixDOF Mover based on the type name.
78 // Null is returned if an object type with the desired name does not exist
79 const Mover* GetObjectTypeByName(const std::string& aTypeName) const;
80
81 bool RegisterThrustProducerObjectType(std::unique_ptr<ThrustProducerObject> aObjectType);
82
83 const ThrustProducerObject* GetThrustProducerObjectType(const std::string& aTypeName) const;
84
85 // Returns true if the type of object exists
86 bool ObjectTypeExists(const std::string& aTypeName) const;
87
88 // Returns true if the name is unique
89 bool ObjectTypeNameIsUnique(const std::string& aTypeName) const;
90
91 // Returns the string representing the default integrator name
93 {
94 return cDefaultPointMassSixDOF_IntegratorName;
95 };
96
97 // Returns the string representing the default integrator name
99 {
100 return cDefaultRigidBodySixDOF_IntegratorName;
101 };
102
103 // Returns true if the type of object exists
104 bool ThrustProducerObjectTypeExists(const std::string& aTypeName) const;
105
106 // This provides the number of object types currently in the list
107 size_t GetNumberOfObjectTypesInList() const { return mObjectTypeMap.size(); }
108
109 // This returns the platform type name for the specified SixDOF vehicle type. If no match is
110 // found, an empty string will be returned.
111 std::string GetVehiclePlatformTypeMatch(const std::string& aNameVehicleType) const;
112
113protected:
114 // This adds the specified SixDOF vehicle type and platform type matching to the master list,
115 // as long as the vehicle type name is unique.
116 void AddVehiclePlatformTypeMatch(const std::string& aNameVehicleType, const std::string& aNamePlatformType);
117
118 bool ProcessIntegratorsInput(UtInput& aInput);
119
120private:
121 struct ObjectPlatformMatch
122 {
123 std::string nameVehicleType;
124 std::string namePlatformType;
125 };
126
127 // This provides a list of vehicle to Platform matches
128 std::list<ObjectPlatformMatch> mObjectPlatformMatchList;
129
130 std::unordered_map<std::string, UtCloneablePtr<Mover>> mObjectTypeMap;
131 std::unordered_map<std::string, UtCloneablePtr<ThrustProducerObject>> mThrustProducerTypeMap;
132 std::unordered_map<std::string, UtCloneablePtr<Integrator>> mIntegratorMap;
133
134 const static std::string cDefaultPointMassSixDOF_IntegratorName;
135 const static std::string cDefaultRigidBodySixDOF_IntegratorName;
136};
137} // namespace six_dof
138} // namespace wsf
139
140#endif
WsfScenarioExtension()
Definition WsfScenarioExtension.cpp:21
The main controller for a simulation.
Definition WsfSimulation.hpp:109
Definition WsfSixDOF_Integrator.hpp:31
This is a base class for detailed air movers. This umbrella can cover RB6 or PM6 models.
Definition WsfSixDOF_Mover.hpp:58
Definition WsfSixDOF_ThrustProducerObject.hpp:35
std::unique_ptr< Mover > VehicleFactory(const Mover *aSubObjectType) const
Definition WsfSixDOF_TypeManager.cpp:383
bool RegisterThrustProducerObjectType(std::unique_ptr< ThrustProducerObject > aObjectType)
Definition WsfSixDOF_TypeManager.cpp:541
size_t GetNumberOfObjectTypesInList() const
Definition WsfSixDOF_TypeManager.hpp:107
bool ObjectTypeExists(const std::string &aTypeName) const
Definition WsfSixDOF_TypeManager.cpp:526
bool ProcessSubObjectInput(UtInput &aInput, std::list< std::unique_ptr< Mover > > &aSubObjectList)
Definition WsfSixDOF_TypeManager.cpp:155
std::string GetVehiclePlatformTypeMatch(const std::string &aNameVehicleType) const
Definition WsfSixDOF_TypeManager.cpp:605
const ThrustProducerObject * GetThrustProducerObjectType(const std::string &aTypeName) const
Definition WsfSixDOF_TypeManager.cpp:562
bool RegisterObjectType(std::unique_ptr< Mover > aObjectTypePtr)
Definition WsfSixDOF_TypeManager.cpp:505
const Mover * GetObjectTypeByName(const std::string &aTypeName) const
Definition WsfSixDOF_TypeManager.cpp:552
Integrator * GetIntegratorByName(const std::string &aTypeName) const
Definition WsfSixDOF_TypeManager.cpp:487
bool ObjectTypeNameIsUnique(const std::string &aTypeName) const
Definition WsfSixDOF_TypeManager.cpp:531
bool ThrustProducerObjectTypeExists(const std::string &aTypeName) const
Definition WsfSixDOF_TypeManager.cpp:536
bool ProcessInput(UtInput &aInput) override
Definition WsfSixDOF_TypeManager.cpp:67
void SimulationCreated(WsfSimulation &aSimulation) override
Definition WsfSixDOF_TypeManager.cpp:572
void SetIntegrators(const std::string &aFilename)
Definition WsfSixDOF_TypeManager.cpp:457
void UnregisterObjectType(const std::string &aTypeName)
Definition WsfSixDOF_TypeManager.cpp:517
const std::string GetDefaultRigidBodySixDOF_IntegratorName() const
Definition WsfSixDOF_TypeManager.hpp:98
void AddVehiclePlatformTypeMatch(const std::string &aNameVehicleType, const std::string &aNamePlatformType)
Definition WsfSixDOF_TypeManager.cpp:579
void AddedToScenario() override
Definition WsfSixDOF_TypeManager.cpp:49
const std::string GetDefaultPointMassSixDOF_IntegratorName() const
Definition WsfSixDOF_TypeManager.hpp:92
bool ProcessIntegratorsInput(UtInput &aInput)
Definition WsfSixDOF_TypeManager.cpp:410
Definition WsfSA_Processor.hpp:35
Function definitions for those who need run-time access to the version.
Definition WsfComm.cpp:32
Copyrights Multiple, All Rights Reserved