WSF
WsfCommandChain.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 WSFCOMMANDCHAIN_HPP
13#define WSFCOMMANDCHAIN_HPP
14
15#include "wsf_export.h"
16
17#include <memory>
18#include <string>
19#include <vector>
20
21class UtInput;
22class UtScriptClass;
23class UtScriptTypes;
24class WsfPlatform;
25class WsfScenario;
27#include "WsfStringId.hpp"
28
36{
37public:
38 typedef std::vector<WsfPlatform*> PlatformList;
39 typedef std::vector<WsfPlatform*>::iterator PlatformListIter;
40
41 static void RegisterComponentFactory(WsfScenario& aScenario);
42
43 static std::unique_ptr<UtScriptClass> CreateScriptClass(const std::string& aClassName, UtScriptTypes* aScriptTypesPtr);
44
45 static std::string GetDefaultName();
47
49 WsfCommandChain(WsfStringId aCommandChainName, WsfStringId aCommanderName);
50 ~WsfCommandChain() override = default;
51
53
54 WsfComponent* CloneComponent() const override { return new WsfCommandChain(*this); }
55 void* QueryInterface(int aRole) override { return (aRole == mRoles[0]) ? this : nullptr; }
57 void ComponentParentChanged(WsfPlatform* aPlatformPtr) override { mPlatformPtr = aPlatformPtr; }
59
62 WsfPlatform* GetPlatform() const { return mPlatformPtr; }
63
65
66
68 WsfPlatform* GetCommander() const { return mCommanderPtr; }
69
70 void SetCommander(WsfPlatform* aPlatformPtr);
71
73 std::string GetCommanderName() const;
74
76 WsfStringId GetCommanderNameId() const { return mCommanderName; }
78
80
81
83 PlatformList& GetPeers() { return mPeers; }
84
85 void AddPeer(WsfPlatform* aPlatformPtr);
86 void RemovePeer(WsfPlatform* aPlatformPtr);
88
90
91
93 PlatformList& GetSubordinates() { return mSubordinates; }
94
95 void AddSubordinate(WsfPlatform* aPlatformPtr);
96 void RemoveSubordinate(WsfPlatform* aPlatformPtr);
98
100 //@(
101 bool Initialize(double aSimTime) override;
102
103 static bool LoadInstance(UtInput& aInput, WsfCommandChain*& aInstancePtr);
104
105 void PlatformAdded(WsfPlatform* aPlatformPtr);
106 void PlatformDeleted(WsfPlatform* aPlatformPtr);
108
109protected:
110 WsfCommandChain(const WsfCommandChain& aSrc);
112
113private:
114 std::string PrintHeader() const;
115
116 WsfPlatform* mPlatformPtr;
117
118 // This flag indicates that a commander was not specified for this command chain and it assumed to be SELF
119 // This should only happen for the default command chain due to AFSIM's input restrictions.
120 bool mCommanderIsSelfImplicitly{false};
121 WsfStringId mCommanderName;
122 WsfPlatform* mCommanderPtr;
123 std::vector<WsfPlatform*> mPeers;
124 std::vector<WsfPlatform*> mSubordinates;
125
126 UtScriptClass* mPlatformClassPtr;
127};
128
130
131#endif
@ cWSF_INITIALIZE_ORDER_COMMAND_CHAIN
Command chains aren't dependent on anything, but something may be dependent on them.
Definition WsfComponentRoles.hpp:164
#define WSF_DECLARE_COMPONENT_ROLE_TYPE(TYPE, ROLE)
Definition WsfComponentRoles.hpp:44
@ cWSF_COMPONENT_COMMAND_CHAIN
A 'command_chain' component (WsfCommandChain).
Definition WsfComponentRoles.hpp:109
WsfSimpleComponentT< WsfPlatformComponent > WsfSimplePlatformComponent
Definition WsfSimpleComponent.hpp:126
UtStringId WsfStringId
WsfStringId – the same thing as UtStringId.
Definition WsfStringId.hpp:23
#define WSF_EXPORT
Definition WsfXIO_Export.hpp:35
Definition WsfCommandChain.hpp:36
WsfCommandChain()
Definition WsfCommandChain.cpp:110
WsfPlatform * GetPlatform() const
Definition WsfCommandChain.hpp:62
static void RegisterComponentFactory(WsfScenario &aScenario)
Definition WsfCommandChain.cpp:90
WsfStringId GetCommanderNameId() const
Get the name ID of the commander;.
Definition WsfCommandChain.hpp:76
static WsfStringId GetDefaultNameId()
Get the name (string ID) to be used for the default command chain.
Definition WsfCommandChain.cpp:104
~WsfCommandChain() override=default
WsfPlatform * GetCommander() const
Definition WsfCommandChain.hpp:68
static std::unique_ptr< UtScriptClass > CreateScriptClass(const std::string &aClassName, UtScriptTypes *aScriptTypesPtr)
Definition WsfCommandChain.cpp:551
void ComponentParentChanged(WsfPlatform *aPlatformPtr) override
Definition WsfCommandChain.hpp:57
PlatformList & GetSubordinates()
Definition WsfCommandChain.hpp:93
int GetComponentInitializationOrder() const override
Definition WsfCommandChain.hpp:56
static std::string GetDefaultName()
Get the name to be used for the default command chain.
Definition WsfCommandChain.cpp:97
std::vector< WsfPlatform * >::iterator PlatformListIter
Definition WsfCommandChain.hpp:39
WsfComponent * CloneComponent() const override
Definition WsfCommandChain.hpp:54
PlatformList & GetPeers()
Definition WsfCommandChain.hpp:83
std::vector< WsfPlatform * > PlatformList
Definition WsfCommandChain.hpp:38
void * QueryInterface(int aRole) override
Definition WsfCommandChain.hpp:55
Definition WsfComponent.hpp:39
virtual bool Initialize(double aSimTime)
Definition WsfComponent.cpp:45
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
WsfSimpleComponentT & operator=(const WsfSimpleComponentT &aRhs)
Definition WsfSimpleComponent.hpp:84
int mRoles[2]
Definition WsfSimpleComponent.hpp:116
Copyrights Multiple, All Rights Reserved