WSF
WsfPkTable.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 WSFPKTABLE_HPP
13#define WSFPKTABLE_HPP
14
15#include <ostream>
16#include <vector>
17
18class UtInput;
19#include "UtAzElLookup.hpp"
20#include "UtAzElTable.hpp"
21#include "UtCallbackHolder.hpp"
22#include "UtInput.hpp"
23class UtInputBlock;
24#include "UtUnits.hpp"
25#include "WsfNamed.hpp"
26#include "WsfStringId.hpp"
27
28namespace WsfPk
29{
39
41{
42public:
43 TgtMaxSpdAndTable(double aTgtMaxSpeed, UtAzElTable& aTable);
44 static bool LoadTgtMaxSpdAndTable(UtInput& aInput, TgtMaxSpdAndTable*& aTablePtr);
45 bool ProcessInput(UtInput& aInput);
46 double TgtSpeedLimit() const { return mTgtMaxSpeed; }
47 double MinEl() const { return mTable.mElValues.Get(0); }
48 double MaxEl() const { return mTable.mElValues.Get(mTable.mElValues.GetSize() - 1); }
49 double MinAz() const { return mTable.mAzValues.Get(0); }
50 double MaxAz() const { return mTable.mAzValues.Get(mTable.mAzValues.GetSize() - 1); }
51 size_t NumAzimuths() const { return mTable.mAzValues.GetSize(); }
52 size_t NumElevations() const { return mTable.mElValues.GetSize(); }
53 UtAzElTable* GetTable() { return &mTable; }
54
55private:
56 double mTgtMaxSpeed;
57 UtAzElTable mTable;
58};
59
61{
62public:
63 WpnSpdSet(double aWpnMaxSpeed);
64 bool ProcessInput(UtInput& aInput);
65 static bool LoadWpnSpdSet(UtInput& aInput, WpnSpdSet*& aWpnSpdSetPtr);
66 TgtMaxSpdAndTable& Get(int aIndex) { return mTgtMaxSpdAndTables[aIndex % mTgtMaxSpdAndTables.size()]; }
67 size_t Size() { return mTgtMaxSpdAndTables.size(); }
68 bool Add(const TgtMaxSpdAndTable& aNewTableSet);
69 double WpnSpeedLimit() const { return mWpnMaxSpeed; }
70 void GetTgtSpdSetsFor(double aTargetSpeed, TgtMaxSpdAndTable*& aLowerPtr, TgtMaxSpdAndTable*& aUpperPtr);
71
72private:
73 double mWpnMaxSpeed;
74 std::vector<TgtMaxSpdAndTable> mTgtMaxSpdAndTables;
75};
76
77class Table : public WsfNamed
78{
79public:
80 Table();
81 ~Table() override = default;
82
83 static bool LoadTable(UtInput& aInput, Table*& aTablePtr, Table* aParentTable = nullptr);
84
85 static bool LoadUtAzElTable(UtInput& aInput, UtAzElTable*& aTablePtr);
86
87 virtual bool Add(Table* aTablePtr) { return false; }
88
89 virtual double LookUp(WsfStringId aTargetTypeId, double aAzimuth, double aElevation, double aWeaponSpeed, double aTargetSpeed);
90
91 virtual WsfStringId TargetType() { return mTargetType; }
92
93 bool ProcessInput(UtInput& aInput);
94
95 void SetTargetType(WsfStringId aTargetType) { mTargetType = aTargetType; }
96 WpnSpdSet& Get(int aIndex) { return mWpnSpdSets[aIndex % mWpnSpdSets.size()]; }
97 size_t SpeedsSize() { return mWpnSpdSets.size(); }
98
99 virtual bool CanAdd() const { return true; }
100 virtual bool IsTableSet() const { return false; }
101 virtual size_t TableSetSize() const { return 1; }
102 virtual WsfStringId TargetTypeOfIndex(unsigned int aIndex);
103
104protected:
105 void SetPkValuesP(const std::vector<std::vector<double>>& aValues);
106 bool Add(const WpnSpdSet& aWpnSpdSet);
107 void GetWpnSpdSetsFor(double aWeaponSpeed, WpnSpdSet*& aLowerPtr, WpnSpdSet*& aUpperPtr);
108
109 int Resize();
110 void Increment(int& i, int& j, int& k, int& m, int& total);
111
112 // Prevent use of operator= by declaring, but not defining.
113 Table& operator=(const Table& aRhs) = delete;
114
115 // ========== Class Attributes ====================
117 std::vector<WpnSpdSet> mWpnSpdSets;
118
119}; // end class
120
121class TableSet : public Table
122{
123public:
124 TableSet();
125 ~TableSet() override;
126
127 // virtual bool Initialize();
128 bool Add(Table* aTablePtr) override;
129
130 double LookUp(WsfStringId aTargetType, double aAzimuth, double aElevation, double aWeaponSpeed, double aTargetSpeed) override;
131
132 bool ProcessInput(UtInput& aInput);
133
134 bool IsTableSet() const override { return true; }
135
136 const Table& Get(int aTgtTypeId) const;
137
138 bool CanAdd() const override;
139 WsfStringId TargetTypeOfIndex(unsigned int aIndex) override;
140 size_t TableSetSize() const override { return mTablePtrs.size(); }
141
142protected:
143 // ========== Class Attributes ====================
144 std::vector<Table*> mTablePtrs;
145
146}; // end class
147
149{
150public:
151 TableManager();
153
154 // There are two ways to find a table, either by name, or by key.
155 Table* FindTargetType(WsfStringId aTargetType);
157
158 bool ProcessInput(UtInput& aInput);
159
160private:
161 bool Add(Table* aTablePtr);
162
163 UtCallbackHolder mCallbacks;
164 std::vector<Table*> mTables;
165};
166
167} // end namespace WsfPk
168
169#endif
UtStringId WsfStringId
WsfStringId – the same thing as UtStringId.
Definition WsfStringId.hpp:23
WsfNamed()
Definition WsfNamed.cpp:17
TableManager()
Definition WsfPkTable.cpp:122
Table * FindTargetType(WsfStringId aTargetType)
Definition WsfPkTable.cpp:75
~TableManager()
Definition WsfPkTable.cpp:129
Table * FindTableName(WsfStringId aNameId)
Definition WsfPkTable.cpp:105
bool ProcessInput(UtInput &aInput)
Definition WsfPkTable.cpp:139
size_t TableSetSize() const override
Definition WsfPkTable.hpp:140
WsfStringId TargetTypeOfIndex(unsigned int aIndex) override
Definition WsfPkTable.cpp:564
std::vector< Table * > mTablePtrs
Definition WsfPkTable.hpp:144
bool CanAdd() const override
Definition WsfPkTable.cpp:571
bool Add(Table *aTablePtr) override
Definition WsfPkTable.cpp:617
TableSet()
Definition WsfPkTable.cpp:547
bool ProcessInput(UtInput &aInput)
Definition WsfPkTable.cpp:588
const Table & Get(int aTgtTypeId) const
double LookUp(WsfStringId aTargetType, double aAzimuth, double aElevation, double aWeaponSpeed, double aTargetSpeed) override
Definition WsfPkTable.cpp:640
bool IsTableSet() const override
Definition WsfPkTable.hpp:134
~TableSet() override
Definition WsfPkTable.cpp:554
Definition WsfPkTable.hpp:78
std::vector< WpnSpdSet > mWpnSpdSets
Definition WsfPkTable.hpp:117
virtual size_t TableSetSize() const
Definition WsfPkTable.hpp:101
virtual bool CanAdd() const
Definition WsfPkTable.hpp:99
bool ProcessInput(UtInput &aInput)
Definition WsfPkTable.cpp:209
virtual WsfStringId TargetType()
Definition WsfPkTable.hpp:91
void SetTargetType(WsfStringId aTargetType)
Definition WsfPkTable.hpp:95
Table & operator=(const Table &aRhs)=delete
Table()
Definition WsfPkTable.cpp:194
WpnSpdSet & Get(int aIndex)
Definition WsfPkTable.hpp:96
virtual bool IsTableSet() const
Definition WsfPkTable.hpp:100
virtual double LookUp(WsfStringId aTargetTypeId, double aAzimuth, double aElevation, double aWeaponSpeed, double aTargetSpeed)
Definition WsfPkTable.cpp:399
void SetPkValuesP(const std::vector< std::vector< double > > &aValues)
static bool LoadUtAzElTable(UtInput &aInput, UtAzElTable *&aTablePtr)
Definition WsfPkTable.cpp:329
WsfStringId mTargetType
Definition WsfPkTable.hpp:116
static bool LoadTable(UtInput &aInput, Table *&aTablePtr, Table *aParentTable=nullptr)
Definition WsfPkTable.cpp:281
virtual WsfStringId TargetTypeOfIndex(unsigned int aIndex)
Definition WsfPkTable.cpp:203
virtual bool Add(Table *aTablePtr)
Definition WsfPkTable.hpp:87
void GetWpnSpdSetsFor(double aWeaponSpeed, WpnSpdSet *&aLowerPtr, WpnSpdSet *&aUpperPtr)
Definition WsfPkTable.cpp:526
size_t SpeedsSize()
Definition WsfPkTable.hpp:97
void Increment(int &i, int &j, int &k, int &m, int &total)
~Table() override=default
Definition WsfPkTable.hpp:41
bool ProcessInput(UtInput &aInput)
size_t NumElevations() const
Definition WsfPkTable.hpp:52
UtAzElTable * GetTable()
Definition WsfPkTable.hpp:53
static bool LoadTgtMaxSpdAndTable(UtInput &aInput, TgtMaxSpdAndTable *&aTablePtr)
Definition WsfPkTable.cpp:672
double TgtSpeedLimit() const
Definition WsfPkTable.hpp:46
double MaxEl() const
Definition WsfPkTable.hpp:48
size_t NumAzimuths() const
Definition WsfPkTable.hpp:51
TgtMaxSpdAndTable(double aTgtMaxSpeed, UtAzElTable &aTable)
Definition WsfPkTable.cpp:708
double MinEl() const
Definition WsfPkTable.hpp:47
double MaxAz() const
Definition WsfPkTable.hpp:50
double MinAz() const
Definition WsfPkTable.hpp:49
Definition WsfPkTable.hpp:61
static bool LoadWpnSpdSet(UtInput &aInput, WpnSpdSet *&aWpnSpdSetPtr)
Definition WsfPkTable.cpp:717
size_t Size()
Definition WsfPkTable.hpp:67
TgtMaxSpdAndTable & Get(int aIndex)
Definition WsfPkTable.hpp:66
bool Add(const TgtMaxSpdAndTable &aNewTableSet)
Definition WsfPkTable.cpp:795
void GetTgtSpdSetsFor(double aTargetSpeed, TgtMaxSpdAndTable *&aLowerPtr, TgtMaxSpdAndTable *&aUpperPtr)
Definition WsfPkTable.cpp:775
double WpnSpeedLimit() const
Definition WsfPkTable.hpp:69
bool ProcessInput(UtInput &aInput)
WpnSpdSet(double aWpnMaxSpeed)
Definition WsfPkTable.cpp:768
Definition WsfMil.hpp:58
Copyrights Multiple, All Rights Reserved