WSF
WsfHEL_Lethality.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 2003-2015 The Boeing 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 WSFHELLETHALITY_HPP
13#define WSFHELLETHALITY_HPP
14
15#include "wsf_mil_export.h"
16
17#include <map>
18
19#include "UtGenericMappedList.hpp"
20#include "UtMatrix.hpp"
22class WsfPlatform;
23class WsfWeapon;
24#include "WsfWeaponEffects.hpp"
25
32class WSF_MIL_EXPORT WsfHEL_Lethality : public WsfWeaponEffects
33{
34 // TODO Cache data at initialization based on weapon type in order to save memory
35 // (currently databases are cloned as needed)
36public:
37 WsfHEL_Lethality(WsfScenario& aScenario);
38 WsfHEL_Lethality(const WsfHEL_Lethality& aLethality);
39 ~WsfHEL_Lethality() override = default;
40
41 WsfWeaponEffects* Clone() const override;
42
43 bool ProcessInput(UtInput& aInput) override;
44
45 bool Initialize(double aSimTime, const WsfWeaponEngagement* aEngagementPtr) override;
46
47protected:
50
51 void ApplyEffectTo(double aSimTime, WsfPlatform* aTargetPtr) override;
52
53 void ApplyEffectIncrement(double aSimTime, WsfPlatform* aOtherPlatformPtr, double aDamageAmount) override;
54
55 void CalcInterceptPk(double aSimTime, WsfPlatform* aTargetPtr) override;
56
57 bool IsVulnerable(WsfPlatform* aOtherPlatformPtr) override;
58
59 class Entry;
60 const Entry* FindMappedEntry(WsfPlatform* aTargetPtr);
61
62
63 class Effect
64 {
65 public:
66 enum Type
67 {
70 cCUSTOM // basically, do something on callback.
71 };
72
73 enum Kind
74 {
79 cPOWER // Deprecated; no longer used
80 };
81
82 Effect() = default;
83
84 Effect(Kind aKind, double aThreshold, double aRadius = 0.0, Type aType = cLETHAL_PLATFORM)
85 : mKind(aKind)
86 , mThreshold(aThreshold)
87 , mPK_TablePtr(nullptr)
88 , mRadius(aRadius)
89 , mType(aType)
90 {
91 }
92
93 Effect(const Effect& aSrc)
94 : mKind(aSrc.mKind)
96 , mPK_TablePtr(nullptr)
97 , mRadius(aSrc.mRadius)
98 , mType(aSrc.mType)
99 {
100 if (aSrc.mPK_TablePtr != nullptr)
101 {
102 mPK_TablePtr = new UtMatrixd(*aSrc.mPK_TablePtr);
103 }
104 }
105
106 Effect& operator=(const Effect& aSrc)
107 {
108 if (this != &aSrc)
109 {
110 mKind = aSrc.mKind;
111 mThreshold = aSrc.mThreshold;
112 delete mPK_TablePtr;
113 mPK_TablePtr = nullptr;
114 if (aSrc.mPK_TablePtr != nullptr)
115 {
116 mPK_TablePtr = new UtMatrixd(*aSrc.mPK_TablePtr);
117 }
118 mRadius = aSrc.mRadius;
119 mType = aSrc.mType;
120 }
121 return *this;
122 }
123 ~Effect() { delete mPK_TablePtr; }
124
125 bool ProcessInput(UtInput& aInput);
126
128 double mThreshold{0.0}; // Power, Energy, or Energy Density
129 UtMatrixd* mPK_TablePtr{nullptr}; // PK-energy
130 double mRadius{0.0}; // zero is not defined
131 Type mType{cLETHAL_PLATFORM}; // Is this effect lethal for the platform
132 };
133
134 class Entry
135 {
136 public:
143
146 , mCategory(nullptr)
147 , mPlatformType(nullptr)
148 , mRegion(nullptr)
149 , mEffects()
150 {
151 }
152
153 bool ProcessInput(UtInput& aInput);
154
155 bool ProcessType(UtInput& aInput);
156
158 {
159 if (mType == cCATEGORY)
160 {
161 return mCategory;
162 }
163 else if (mType == cPLATFORM_TYPE)
164 {
165 return mPlatformType;
166 }
167 else // cPLATFORM_REGION
168 {
169 assert(mType == cPLATFORM_REGION);
170 return mRegion;
171 }
172 }
173
178
179
180 std::vector<Effect> mEffects; // There will always be at least one of these
181
182 bool operator<(const Entry& aRhs) { return GetId() < aRhs.GetId(); }
183 };
184
185private:
186 void ApplyEffectIncrementP(double aSimTime, WsfPlatform* aOtherPlatformPtr, double aDamageAmount);
187
188 bool IsVulnerableP(WsfPlatform* aOtherPlatformPtr);
189
190 static void ReadPK_EnergyTable(UtInput& aInput, UtMatrixd* aTable);
191
192 using EntryMap = UtStdMappedList<Entry, WsfStringId>;
193
194 EntryMap mEntryMap;
195
196 int mSequence; // for multiple effects in a single event
197 bool mManageKills;
198 bool mUnharmedUntilKilled;
199 const Entry* mEntryPtr;
200};
201
202#endif
UtStringId WsfStringId
WsfStringId – the same thing as UtStringId.
Definition WsfStringId.hpp:23
Effect(Kind aKind, double aThreshold, double aRadius=0.0, Type aType=cLETHAL_PLATFORM)
Definition WsfHEL_Lethality.hpp:84
Kind
Definition WsfHEL_Lethality.hpp:74
@ cENERGY_DENSITY
Definition WsfHEL_Lethality.hpp:78
@ cENERGY
Definition WsfHEL_Lethality.hpp:76
@ cPK_ENERGY
Definition WsfHEL_Lethality.hpp:77
@ cUNDEFINED
Definition WsfHEL_Lethality.hpp:75
@ cPOWER
Definition WsfHEL_Lethality.hpp:79
Type mType
Definition WsfHEL_Lethality.hpp:131
double mRadius
Definition WsfHEL_Lethality.hpp:130
~Effect()
Definition WsfHEL_Lethality.hpp:123
Type
Definition WsfHEL_Lethality.hpp:67
@ cCUSTOM
Definition WsfHEL_Lethality.hpp:70
@ cLETHAL_PLATFORM
Definition WsfHEL_Lethality.hpp:68
@ cLETHAL_PLATFORM_PART
Definition WsfHEL_Lethality.hpp:69
Effect(const Effect &aSrc)
Definition WsfHEL_Lethality.hpp:93
double mThreshold
Definition WsfHEL_Lethality.hpp:128
Effect & operator=(const Effect &aSrc)
Definition WsfHEL_Lethality.hpp:106
Kind mKind
Definition WsfHEL_Lethality.hpp:127
UtMatrixd * mPK_TablePtr
Definition WsfHEL_Lethality.hpp:129
Definition WsfHEL_Lethality.hpp:135
bool operator<(const Entry &aRhs)
Definition WsfHEL_Lethality.hpp:182
Type mType
Definition WsfHEL_Lethality.hpp:174
WsfStringId mCategory
Definition WsfHEL_Lethality.hpp:175
std::vector< Effect > mEffects
Definition WsfHEL_Lethality.hpp:180
WsfStringId mRegion
Definition WsfHEL_Lethality.hpp:177
WsfStringId GetId() const
Definition WsfHEL_Lethality.hpp:157
WsfStringId mPlatformType
Definition WsfHEL_Lethality.hpp:176
Entry()
Definition WsfHEL_Lethality.hpp:144
Type
Definition WsfHEL_Lethality.hpp:138
@ cCATEGORY
Definition WsfHEL_Lethality.hpp:139
@ cPLATFORM_REGION
Definition WsfHEL_Lethality.hpp:141
@ cPLATFORM_TYPE
Definition WsfHEL_Lethality.hpp:140
~WsfHEL_Lethality() override=default
bool ProcessInput(UtInput &aInput) override
Definition WsfHEL_Lethality.cpp:187
WsfHEL_Lethality & operator=(const WsfHEL_Lethality &aRhs)=delete
Disable use.
const Entry * FindMappedEntry(WsfPlatform *aTargetPtr)
Definition WsfHEL_Lethality.cpp:322
WsfHEL_Lethality(WsfScenario &aScenario)
Definition WsfHEL_Lethality.cpp:29
Platforms represent a entity within the simulation.
Definition WsfPlatform.hpp:115
Contains the data required to create a simulation, and acts as the entry point for input file process...
Definition WsfScenario.hpp:111
virtual void CalcInterceptPk(double aSimTime, WsfPlatform *aTargetPtr)
Definition WsfWeaponEffects.cpp:640
virtual void ApplyEffectTo(double aSimTime, WsfPlatform *aOtherPlatformPtr)
Definition WsfWeaponEffects.cpp:549
bool ProcessInput(UtInput &aInput) override
Definition WsfWeaponEffects.cpp:178
virtual void ApplyEffectIncrement(double aSimTime, WsfPlatform *aOtherPlatformPtr, double aDamageAmount)
Definition WsfWeaponEffects.cpp:482
virtual bool IsVulnerable(WsfPlatform *aOtherPlatformPtr)
Definition WsfWeaponEffects.cpp:670
virtual bool Initialize(double aSimTime, const WsfWeaponEngagement *aEngagementPtr)
Definition WsfWeaponEffects.cpp:150
WsfWeaponEffects * Clone() const override=0
WsfWeaponEffects(WsfScenario &aScenario)
Definition WsfWeaponEffects.cpp:51
Definition WsfWeaponEngagement.hpp:43
Definition WsfWeapon.hpp:63
Copyrights Multiple, All Rights Reserved