WSF
WsfCoverageGrid.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 WSFCOVERAGEGRID_HPP
13#define WSFCOVERAGEGRID_HPP
14
15#include <utility>
16
17#include "UtCentralBody.hpp"
18#include "UtCloneablePtr.hpp"
19#include "WsfCoverageAsset.hpp"
22#include "WsfObject.hpp"
23#include "WsfScenario.hpp"
24class WsfSimulation;
25
26#include "wsf_coverage_export.h"
27
28
29namespace wsf
30{
31namespace coverage
32{
33
35
37class WSF_COVERAGE_EXPORT Grid : public WsfObject
38{
39public:
40 explicit Grid(const WsfScenario& aScenario);
41 Grid(const Grid& aOther) = default;
42 ~Grid() override = default;
43
44 // WsfObject overrides
45 Grid* Clone() const override = 0;
46 bool ProcessInput(UtInput& aInput) override;
47
48 // Grid Interface
49
58 virtual void PreparePlatforms(WsfSimulation& aSimulation) = 0;
59
68 virtual const Point* GetPoint(PointId aPointId) const = 0;
69
76 virtual std::size_t GetSize() const = 0;
77
85 virtual void Invoke(GridAction& aAction) const = 0;
86
95 virtual GridAsset GetAsset(PointId aPointId) const = 0;
96
106 virtual GridAsset GetAsset(const std::string& aPlatformName) const = 0;
107
116 virtual void HasNullDevice(bool& aAnyNull, bool& aAllNull) const = 0;
117
126 virtual bool CreatesNewPlatforms() const = 0;
127
136 virtual bool IsStructured() const { return false; }
137
145 virtual std::size_t GetNumComponents() const { return 1; }
146
148 virtual std::string GetComponentName(std::size_t aComponentIndex) const { return GetName(); }
149
161 virtual std::pair<std::size_t, std::size_t> GetComponentSizes(std::size_t aComponentIndex) const;
162
174 virtual std::pair<std::size_t, std::size_t> GetPointIndices(PointId aPointId) const;
175
177 virtual void InvokeOnComponent(GridAction& aAction, std::size_t aComponentIndex) const { Invoke(aAction); }
178
179 void SetUsedFlag() { mUsedFlag = true; }
180 bool IsUsed() const { return mUsedFlag; }
181
182 bool Initialize();
183 void CategorizeAssets(const WsfSimulation& aSimulation, const std::string& aCategory) const;
184
186 bool IsInitialized() const { return mInitialized; }
187
189 const ut::CentralBody& GetCentralBody() const { return *mCentralBodyPtr; }
190
191 void SetCentralBody(const ut::CentralBody& aCentralBody);
192
194 const std::string& GetGridDataFileName() const { return mGridDataFileName; }
195
197 bool GetSuppressGridPlatforms() const { return mSuppressGridPlatforms; }
198
200 void SetSuppressGridPlatforms(bool aSuppress) { mSuppressGridPlatforms = aSuppress; }
201
202
203 bool WriteGridDataFile(TextOutputWriter& aWriter) const;
204 bool WriteGridDataFile() const;
205
206protected:
215 virtual bool InitializeP() = 0;
216
218 const WsfScenario& GetScenario() const { return mScenario; }
219
220private:
221 // Private Grid interface
222 virtual void WriteHeaderExtension(TextOutputWriter& aWriter) const {}
223 virtual void WriteLineExtension(TextOutputWriter& aWriter, PointId aPointId) const {}
224
225 const WsfScenario& mScenario;
226 ut::CloneablePtr<ut::CentralBody> mCentralBodyPtr;
227 std::string mGridDataFileName{};
228 PointId mNextPointId{cINVALID_POINT_ID};
229 bool mInitialized{false};
230 bool mSuppressGridPlatforms{true};
231 bool mUsedFlag{false};
232 // NOTE: The base class does not impose a certain structure to the storage
233 // of the grid points. That is up to the derived classes to work out
234 // what is most convenient.
235};
236
237} // namespace coverage
238} // namespace wsf
239
240#endif // WSFCOVERAGEGRID_HPP
const std::string & GetName() const
Definition WsfObject.cpp:235
WsfObject()
This is the constructor for the WsfObject class.
Definition WsfObject.cpp:88
Contains the data required to create a simulation, and acts as the entry point for input file process...
Definition WsfScenario.hpp:111
The main controller for a simulation.
Definition WsfSimulation.hpp:109
An object that can be invoked for each point in a grid.
Definition WsfCoverageGridAction.hpp:30
Definition WsfCoverageAsset.hpp:37
bool GetSuppressGridPlatforms() const
Return if this grid is suppressing grid platforms.
Definition WsfCoverageGrid.hpp:197
virtual void PreparePlatforms(WsfSimulation &aSimulation)=0
virtual GridAsset GetAsset(PointId aPointId) const =0
virtual void HasNullDevice(bool &aAnyNull, bool &aAllNull) const =0
bool ProcessInput(UtInput &aInput) override
Definition WsfCoverageGrid.cpp:37
Grid * Clone() const override=0
PointId GetNextAvailableId()
Definition WsfCoverageGrid.cpp:234
const ut::CentralBody & GetCentralBody() const
Return the central body to which this grid's point locations refer.
Definition WsfCoverageGrid.hpp:189
bool IsUsed() const
Definition WsfCoverageGrid.hpp:180
bool IsInitialized() const
Return if this Grid has been initialized.
Definition WsfCoverageGrid.hpp:186
void SetUsedFlag()
Definition WsfCoverageGrid.hpp:179
virtual GridAsset GetAsset(const std::string &aPlatformName) const =0
virtual const Point * GetPoint(PointId aPointId) const =0
virtual bool CreatesNewPlatforms() const =0
Grid(const WsfScenario &aScenario)
Definition WsfCoverageGrid.cpp:31
const std::string & GetGridDataFileName() const
Return the configured grid data file name.
Definition WsfCoverageGrid.hpp:194
virtual void InvokeOnComponent(GridAction &aAction, std::size_t aComponentIndex) const
Invoke the given aAction on the points of the specified grid component.
Definition WsfCoverageGrid.hpp:177
virtual std::size_t GetNumComponents() const
Definition WsfCoverageGrid.hpp:145
virtual bool InitializeP()=0
Grid(const Grid &aOther)=default
~Grid() override=default
virtual void Invoke(GridAction &aAction) const =0
virtual std::size_t GetSize() const =0
virtual bool IsStructured() const
Definition WsfCoverageGrid.hpp:136
void SetSuppressGridPlatforms(bool aSuppress)
Set if this grid suppresses grid platforms.
Definition WsfCoverageGrid.hpp:200
const WsfScenario & GetScenario() const
Definition WsfCoverageGrid.hpp:218
virtual std::string GetComponentName(std::size_t aComponentIndex) const
Return the name of the specified grid component.
Definition WsfCoverageGrid.hpp:148
A point in a coverage grid.
Definition WsfCoverageGridPoint.hpp:40
Definition WsfCoverageTextOutputWriter.hpp:34
Definition WsfCoverage.cpp:35
std::uint64_t PointId
Definition WsfCoverageGridPoint.hpp:33
constexpr PointId cINVALID_POINT_ID
Zero is used everywhere to indicate an invalid point Id.
Definition WsfCoverageGridPoint.hpp:36
Function definitions for those who need run-time access to the version.
Definition WsfComm.cpp:32
Copyrights Multiple, All Rights Reserved