WSF
WsfCyberConstraint.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 2021 Radiance Technologies. 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 WSFCYBERCONSTRAINT_HPP
13#define WSFCYBERCONSTRAINT_HPP
14
15#include "wsf_cyber_export.h"
16
17#include <string>
18
19#include "UtRandom.hpp"
20#include "UtScriptBasicTypes.hpp"
21#include "WsfComponent.hpp"
23#include "WsfCyberRandom.hpp"
24#include "WsfNamed.hpp"
25#include "WsfObject.hpp"
26#include "WsfObjectTypeList.hpp"
27#include "WsfPlatform.hpp"
29
30namespace wsf
31{
32namespace cyber
33{
38class WSF_CYBER_EXPORT Constraint : public WsfPlatformComponent, public WsfObject
39{
40public:
41 Constraint();
42
44
45 WsfStringId GetComponentName() const override { return GetNameId(); }
46 const int* GetComponentRoles() const override;
47 WsfComponent* CloneComponent() const override;
48 void* QueryInterface(int aRole) override;
49 static Constraint* Find(const WsfPlatform& aPlatform);
50 static Constraint* FindOrCreate(WsfPlatform& aPlatform);
52
54
55 bool ProcessInput(UtInput& aInput) override;
56 Constraint* Clone() const override { return new Constraint(*this); }
58
60
61 size_t GetConcurrentAttacks(const std::string& aAttackType) const;
62 void AddConcurrentAttack(const std::string& aAttackType, size_t aEngagementID);
63 void RemoveConcurrentAttack(const std::string& aAttackType, size_t aEngagementID);
64 void AddAttackTime(const std::string& aAttackType, double aSimTime);
65 size_t GetAttackCountAfterTime(const std::string& aAttackType, double aSimTime) const;
67
69
70 double GetCurrentResources() const { return mResources; }
71 double GetTotalResources() const { return mTotalResources; }
72 bool RestoreResources(double aQuantity);
73 bool RemoveResources(double aQuantity);
75
76private:
77 struct AttackInfo
78 {
79 std::vector<size_t> mConcurrentEngagements;
80 // Multiset is used here in order to allow for multiple entries of the same value as well as keeping the data
81 // structure stored in order
82 std::multiset<double> mAttackTimes;
83 };
84
85 std::map<std::string, AttackInfo> mAttackData;
86
87 double mResources{0.0};
88 double mTotalResources{0.0};
89 bool mDefaultDefined{false};
90};
91
93{
94public:
95 ScriptConstraintClass(const std::string& aClassName, UtScriptTypes* aScriptTypesPtr);
96
97 UT_DECLARE_SCRIPT_METHOD(CurrentResources);
98 UT_DECLARE_SCRIPT_METHOD(TotalResources);
99
100 UT_DECLARE_SCRIPT_METHOD(ConcurrentAttacks);
101 UT_DECLARE_SCRIPT_METHOD(AttackCountAfterTime);
102};
103
104} // namespace cyber
105
106} // namespace wsf
107
109
110#endif
#define WSF_DECLARE_COMPONENT_ROLE_TYPE(TYPE, ROLE)
Definition WsfComponentRoles.hpp:44
WsfComponentT< WsfPlatform > WsfPlatformComponent
A convenient typedef for a platform component.
Definition WsfComponent.hpp:171
@ cWSF_COMPONENT_CYBER_CONSTRAINT
Definition WsfCyberComponentRoles.hpp:20
UtStringId WsfStringId
WsfStringId – the same thing as UtStringId.
Definition WsfStringId.hpp:23
Definition WsfComponent.hpp:39
WsfStringId GetNameId() const
Definition WsfObject.hpp:66
WsfObject()
This is the constructor for the WsfObject class.
Definition WsfObject.cpp:88
Platforms represent a entity within the simulation.
Definition WsfPlatform.hpp:115
WsfScriptObjectClass(const std::string &aClassName, UtScriptTypes *aTypesPtr)
Definition WsfScriptObjectClass.cpp:24
Definition WsfCyberConstraint.hpp:39
double GetCurrentResources() const
Definition WsfCyberConstraint.hpp:70
Constraint * Clone() const override
Definition WsfCyberConstraint.hpp:56
WsfStringId GetComponentName() const override
Definition WsfCyberConstraint.hpp:45
Constraint()
Definition WsfCyberConstraint.cpp:26
double GetTotalResources() const
Definition WsfCyberConstraint.hpp:71
UT_DECLARE_SCRIPT_METHOD(ConcurrentAttacks)
UT_DECLARE_SCRIPT_METHOD(TotalResources)
UT_DECLARE_SCRIPT_METHOD(CurrentResources)
UT_DECLARE_SCRIPT_METHOD(AttackCountAfterTime)
ScriptConstraintClass(const std::string &aClassName, UtScriptTypes *aScriptTypesPtr)
Definition WsfCyberConstraint.cpp:187
Definition WsfCyberApplicationExtension.cpp:24
Function definitions for those who need run-time access to the version.
Definition WsfComm.cpp:32
Copyrights Multiple, All Rights Reserved