WSF
WsfImplicitWeapon.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 WSFIMPLICITWEAPON_HPP
13#define WSFIMPLICITWEAPON_HPP
14
15#include "wsf_mil_export.h"
16
17#include <map>
18
19#include "WsfEvent.hpp"
20#include "WsfStringId.hpp"
21#include "WsfWeapon.hpp"
22
30class WSF_MIL_EXPORT WsfImplicitWeapon : public WsfWeapon
31{
32public:
33 WsfImplicitWeapon(const WsfScenario& aScenario);
34 ~WsfImplicitWeapon() override;
35
36 WsfWeapon* Clone() const override;
37
38 bool Initialize(double aSimTime) override;
39
40 void Update(double aSimTime) override;
41
42 const char* GetScriptClassName() const override;
43
45
47
49
50 void ClearCurrentEngagement(double aSimTime);
51
52 WsfWeaponEngagement* GetEngagement(int aEngagementId = 0) const; // Default argument provided to maintain backward compatibility.
53
54 void ClearEngagement(double aSimTime,
55 int aEngagementId = 0); // Default argument provided to maintain backward compatibility.
56
57 FireResult Fire(double aSimTime, const FireTarget& aTarget, const FireOptions& aSettings) override;
58
59 void CeaseFire(double aSimTime) override;
60
68 {
69 public:
70 EngagementData() = default;
71 EngagementData(const EngagementData& aSrc);
74
76 size_t mTargetIndex{0};
78 std::unique_ptr<WsfTrack> mTargetTrackPtr{nullptr};
81 bool mTerminateSet{false};
82 };
83
85 {
86 public:
88 TerminateEngagementEvent(double aSimTime,
89 size_t aWeaponPlatformIndex,
90 WsfImplicitWeapon* aImplicitWeaponPtr,
91 EngagementData*& aEngagementDataPtr);
92
93 EventDisposition Execute() override;
94
95 private:
96 size_t mWeaponPlatformIndex{0};
97 WsfImplicitWeapon* mWeaponPtr{nullptr}; // only valid if the firing platform,
98 // retrieved from mWeaponPlatformIndex, is valid.
99 EngagementData* mEngagementDataPtr{nullptr};
100 };
101
102protected:
103 WsfImplicitWeapon(const WsfImplicitWeapon& aSrc);
105
106 void DeleteEngagementData(EngagementData* aEngagementDataPtr);
107
108 bool BeginEngagement(double aSimTime, EngagementData* aEngagementDataPtr);
109
110 void EngagementComplete(double aSimTime, WsfWeaponEngagement* aEngagementPtr) override;
111
113
114private:
115 using EngagementDataMap = std::map<int, EngagementData*>;
116
117 EngagementDataMap mEngagementDataMap; // Map of engagement serial ids to engagement data.
118 EngagementData* mCurrentEngagementDataPtr; // In case only one engagement occurs at a time.
119};
120#endif
UtStringId WsfStringId
WsfStringId – the same thing as UtStringId.
Definition WsfStringId.hpp:23
WsfEvent()=default
EventDisposition
Definition WsfEvent.hpp:37
Definition WsfImplicitWeapon.hpp:68
WsfStringId mTargetOffset
Definition WsfImplicitWeapon.hpp:77
std::unique_ptr< WsfTrack > mTargetTrackPtr
Definition WsfImplicitWeapon.hpp:78
bool mTerminateSet
Definition WsfImplicitWeapon.hpp:81
WsfWeaponEngagement * mEngagementPtr
Definition WsfImplicitWeapon.hpp:79
WsfStringId mTargetName
Definition WsfImplicitWeapon.hpp:75
size_t mTargetIndex
Definition WsfImplicitWeapon.hpp:76
int mEngagementId
Definition WsfImplicitWeapon.hpp:80
EngagementData & operator=(const EngagementData &)=delete
Definition WsfImplicitWeapon.hpp:85
EventDisposition Execute() override
Definition WsfImplicitWeapon.cpp:455
WsfWeaponEngagement * GetCurrentEngagement() const
Definition WsfImplicitWeapon.cpp:341
WsfWeaponEngagement * GetEngagement(int aEngagementId=0) const
Definition WsfImplicitWeapon.cpp:321
void DeleteEngagementData(EngagementData *aEngagementDataPtr)
Definition WsfImplicitWeapon.cpp:440
WsfImplicitWeapon(const WsfScenario &aScenario)
Definition WsfImplicitWeapon.cpp:27
WsfStringId GetTargetName() const
Return the current target name.
Definition WsfImplicitWeapon.cpp:494
void ClearCurrentEngagement(double aSimTime)
Clear the current engagement.
Definition WsfImplicitWeapon.cpp:347
WsfImplicitWeapon & operator=(const WsfImplicitWeapon &)=delete
void ClearEngagement(double aSimTime, int aEngagementId=0)
Clear the current engagement.
Definition WsfImplicitWeapon.cpp:353
WsfStringId GetTargetOffset() const
Return the name id of the target offset, if any.
Definition WsfImplicitWeapon.cpp:505
bool BeginEngagement(double aSimTime, EngagementData *aEngagementDataPtr)
Definition WsfImplicitWeapon.cpp:161
Contains the data required to create a simulation, and acts as the entry point for input file process...
Definition WsfScenario.hpp:111
Definition WsfWeaponEngagement.hpp:43
Weapon firing options.
Definition WsfWeapon.hpp:275
Result of WsfWeapon::Fire().
Definition WsfWeapon.hpp:319
A target for a weapon to fire upon.
Definition WsfWeapon.hpp:243
WsfWeapon(const WsfScenario &aScenario)
Definition WsfWeapon.cpp:48
WsfWeapon * Clone() const override=0
bool Initialize(double aSimTime) override
Definition WsfWeapon.cpp:187
virtual void CeaseFire(double aSimTime)
Definition WsfWeapon.cpp:996
virtual FireResult Fire(double aSimTime, const FireTarget &aTarget, const FireOptions &aSettings)
Definition WsfWeapon.cpp:828
void Update(double aSimTime) override
Update the state of the weapon to the supplied time value.
Definition WsfWeapon.cpp:432
virtual void EngagementComplete(double aSimTime, WsfWeaponEngagement *aEngagementPtr)
Definition WsfWeapon.cpp:1308
const char * GetScriptClassName() const override
Definition WsfWeapon.cpp:164
Copyrights Multiple, All Rights Reserved