WSF
ComponentNameHelper.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 (C) 2021 Stellar Science; U.S. Government has Unlimited Rights.
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 COMPONENT_NAME_HELPER_HPP
13#define COMPONENT_NAME_HELPER_HPP
14
15#include "wsf_multiresolution_export.h"
16
17#include <algorithm>
18#include <locale>
19#include <string>
20#include <type_traits>
21#include <unordered_map>
22
23// WsfPlatformComponent forward declarations
24namespace wsf
25{
26namespace comm
27{
28class Comm;
29}
30} // namespace wsf
31class WsfProcessor;
32class WsfFuel;
33class WsfMover;
34class WsfSensor;
35
36// WsfSignature forward declarations
41
42namespace wsf
43{
44namespace multiresolution
45{
46constexpr auto cEXTENSION_NAME = "wsf_multiresolution";
47constexpr auto cFEATURE_NAME = "multiresolution";
48
52template<typename DerivedComponent>
54{
55 template<class U>
56 struct DependentFalse : std::false_type
57 {
58 };
59 static_assert(DependentFalse<DerivedComponent>::value, "Type has no associated name.");
60};
61
65{
66 std::string mPlatform;
67 std::string mComponent;
68 std::string mComponentName;
69};
70
73template<typename DerivedComponent>
74std::string CommandName()
75{
76 return std::string("multiresolution_") + ComponentName<DerivedComponent>::cLOWER_CASE_NAME;
77}
78
80template<typename DerivedComponent>
81std::string BaseTypeName()
82{
83 const std::string upperCaseName = []
84 {
86 const std::locale defaultLocale;
87 std::transform(name.begin(),
88 name.end(),
89 name.begin(),
90 [&defaultLocale](const char c) { return std::toupper(c, defaultLocale); });
91 return name;
92 }();
93 return "WSF_MULTIRESOLUTION_" + upperCaseName;
94}
95
96template<typename DerivedComponent>
101
102template<typename DerivedComponent>
103constexpr const char* BaseComponentName()
104{
106}
107
109WSF_MULTIRESOLUTION_EXPORT std::unordered_map<std::string, bool> ComponentTypeRequiresNameMap();
110
112
113template<>
115{
116 static constexpr auto cLOWER_CASE_NAME = "mover";
117 static constexpr bool cREQUIRES_USER_INPUT_NAME = false;
118};
119
120template<>
122{
123 static constexpr auto cLOWER_CASE_NAME = "sensor";
124 static constexpr bool cREQUIRES_USER_INPUT_NAME = true;
125};
126
127template<>
129{
130 static constexpr auto cLOWER_CASE_NAME = "fuel";
131 static constexpr bool cREQUIRES_USER_INPUT_NAME = false;
132};
133
134template<>
136{
137 static constexpr auto cLOWER_CASE_NAME = "comm";
138 static constexpr bool cREQUIRES_USER_INPUT_NAME = true;
139};
140
141template<>
143{
144 static constexpr auto cLOWER_CASE_NAME = "processor";
145 static constexpr bool cREQUIRES_USER_INPUT_NAME = true;
146};
147
148template<>
150{
151 static constexpr auto cLOWER_CASE_NAME = "acoustic_signature";
152 static constexpr bool cREQUIRES_USER_INPUT_NAME = false;
153};
154
155template<>
157{
158 static constexpr auto cLOWER_CASE_NAME = "infrared_signature";
159 static constexpr bool cREQUIRES_USER_INPUT_NAME = false;
160};
161
162template<>
164{
165 static constexpr auto cLOWER_CASE_NAME = "optical_signature";
166 static constexpr bool cREQUIRES_USER_INPUT_NAME = false;
167};
168
169template<>
171{
172 static constexpr auto cLOWER_CASE_NAME = "radar_signature";
173 static constexpr bool cREQUIRES_USER_INPUT_NAME = false;
174};
175
176
177namespace detail
178{
179template<typename Last>
180std::unordered_map<std::string, bool> AppendComponentTypeMap(std::unordered_map<std::string, bool>&& componentTypeMap)
181{
183 return std::move(componentTypeMap);
184}
185
186template<typename First, typename Second, typename... Rest>
187std::unordered_map<std::string, bool> AppendComponentTypeMap(std::unordered_map<std::string, bool>&& componentTypeMap)
188{
189 return AppendComponentTypeMap<Second, Rest...>(AppendComponentTypeMap<First>(std::move(componentTypeMap)));
190}
191} // namespace detail
192} // namespace multiresolution
193} // namespace wsf
194
195#endif
An object that represents the acoustic signature of a platform.
Definition WsfAcousticSignature.hpp:24
Definition WsfFuel.hpp:30
An object that represents the infrared signature of a platform.
Definition WsfInfraredSignature.hpp:25
Definition WsfMover.hpp:37
An object that represents the optical signature of a platform.
Definition WsfOpticalSignature.hpp:27
Definition WsfProcessor.hpp:39
An object that represent the radar signature of a platform.
Definition WsfRadarSignature.hpp:27
Definition WsfSensor.hpp:92
Definition WsfComm.hpp:43
Definition WsfScriptObserver.hpp:233
Definition WsfComm.cpp:34
std::unordered_map< std::string, bool > AppendComponentTypeMap(std::unordered_map< std::string, bool > &&componentTypeMap)
Definition ComponentNameHelper.hpp:180
Definition ComponentNameHelper.cpp:17
constexpr const char * BaseComponentName()
Definition ComponentNameHelper.hpp:103
constexpr auto cEXTENSION_NAME
Definition ComponentNameHelper.hpp:46
std::unordered_map< std::string, bool > ComponentTypeRequiresNameMap()
Generates a map of each supported multiresolution type name to its required user input flag.
Definition ComponentNameHelper.cpp:18
std::string CommandName()
This name, associated with DerivedComponent, is for use in the multiresolution framework....
Definition ComponentNameHelper.hpp:74
constexpr bool RequiresUserInputName()
Definition ComponentNameHelper.hpp:97
constexpr auto cFEATURE_NAME
Definition ComponentNameHelper.hpp:47
std::string BaseTypeName()
This name, associated with DerivedComponent, is used as the base input type for scenario input.
Definition ComponentNameHelper.hpp:81
Function definitions for those who need run-time access to the version.
Definition WsfComm.cpp:32
Definition ComponentNameHelper.hpp:57
static constexpr bool cREQUIRES_USER_INPUT_NAME
Definition ComponentNameHelper.hpp:152
static constexpr auto cLOWER_CASE_NAME
Definition ComponentNameHelper.hpp:151
static constexpr bool cREQUIRES_USER_INPUT_NAME
Definition ComponentNameHelper.hpp:131
static constexpr auto cLOWER_CASE_NAME
Definition ComponentNameHelper.hpp:130
static constexpr bool cREQUIRES_USER_INPUT_NAME
Definition ComponentNameHelper.hpp:159
static constexpr auto cLOWER_CASE_NAME
Definition ComponentNameHelper.hpp:158
static constexpr bool cREQUIRES_USER_INPUT_NAME
Definition ComponentNameHelper.hpp:117
static constexpr auto cLOWER_CASE_NAME
Definition ComponentNameHelper.hpp:116
static constexpr bool cREQUIRES_USER_INPUT_NAME
Definition ComponentNameHelper.hpp:166
static constexpr auto cLOWER_CASE_NAME
Definition ComponentNameHelper.hpp:165
static constexpr auto cLOWER_CASE_NAME
Definition ComponentNameHelper.hpp:144
static constexpr bool cREQUIRES_USER_INPUT_NAME
Definition ComponentNameHelper.hpp:145
static constexpr bool cREQUIRES_USER_INPUT_NAME
Definition ComponentNameHelper.hpp:173
static constexpr auto cLOWER_CASE_NAME
Definition ComponentNameHelper.hpp:172
static constexpr auto cLOWER_CASE_NAME
Definition ComponentNameHelper.hpp:123
static constexpr bool cREQUIRES_USER_INPUT_NAME
Definition ComponentNameHelper.hpp:124
static constexpr auto cLOWER_CASE_NAME
Definition ComponentNameHelper.hpp:137
static constexpr bool cREQUIRES_USER_INPUT_NAME
Definition ComponentNameHelper.hpp:138
Helper struct for assigning names to platform components.
Definition ComponentNameHelper.hpp:54
A wrapper for identifying a platform component within a simulation, which may consist of three names:...
Definition ComponentNameHelper.hpp:65
std::string mComponentName
Definition ComponentNameHelper.hpp:68
std::string mPlatform
Definition ComponentNameHelper.hpp:66
std::string mComponent
Definition ComponentNameHelper.hpp:67
Copyrights Multiple, All Rights Reserved