12#ifndef WSFCOMPONENTFACTORYLIST_HPP
13#define WSFCOMPONENTFACTORYLIST_HPP
54template<
typename PARENT_TYPE>
58 typedef std::vector<std::unique_ptr<WsfComponentFactoryBase>>
FactoryList;
66 : mFactoryList(aScenario.GetComponentFactoryList())
69 mSize = mFactoryList.size();
75 if ((mIndex != mSize) && (mParentRole != mFactoryList[mIndex]->GetParentRole()))
94 bool AtEnd()
const {
return mIndex >= mSize; }
101 while ((mIndex < mSize) && (mParentRole != mFactoryList[mIndex]->GetParentRole()))
121 (*iter)->PreInput(aParent);
129 if ((*iter)->ProcessInput(aInput, aParent))
141 if ((*iter)->ProcessAddOrEditCommand(aInput, aParent, aIsAdding))
151 std::string componentType(aInput.GetCommand());
154 if ((*iter)->ProcessDeleteCommand(aInput, aParent))
159 throw UtInput::BadValue(aInput,
"Unknown object type to delete: " + componentType);
167 if (!(*iter)->PreInitialize(aSimTime, aParent))
170 auto out = ut::log::error() <<
"Component factory pre-initialization failed.";
171 out.AddNote() <<
"Component: " << aParent.GetName();
bool ok
Definition WsfScriptWeaponClass.cpp:211
Definition WsfComponentFactoryList.hpp:62
Iterator & operator++()
Definition WsfComponentFactoryList.hpp:87
bool AtEnd() const
Return true if the end-of-list has been reached.
Definition WsfComponentFactoryList.hpp:94
Iterator(const WsfScenario &aScenario)
An iterator for iterating over the factories that apply to the class PARENT_TYPE.
Definition WsfComponentFactoryList.hpp:65
FactoryType * operator*() const
Definition WsfComponentFactoryList.hpp:83
Definition WsfComponentFactoryList.hpp:56
std::vector< std::unique_ptr< WsfComponentFactoryBase > > FactoryList
Definition WsfComponentFactoryList.hpp:58
static void ProcessDeleteCommand(const WsfScenario &aScenario, UtInput &aInput, PARENT_TYPE &aParent)
Definition WsfComponentFactoryList.hpp:149
static bool PreInitialize(const WsfScenario &aScenario, double aSimTime, PARENT_TYPE &aParent)
Definition WsfComponentFactoryList.hpp:162
static bool ProcessInput(const WsfScenario &aScenario, UtInput &aInput, PARENT_TYPE &aParent)
Definition WsfComponentFactoryList.hpp:125
static void PreInput(const WsfScenario &aScenario, PARENT_TYPE &aParent)
Definition WsfComponentFactoryList.hpp:117
WsfComponentFactory< PARENT_TYPE > FactoryType
Definition WsfComponentFactoryList.hpp:59
static bool ProcessAddOrEditCommand(const WsfScenario &aScenario, UtInput &aInput, PARENT_TYPE &aParent, bool aIsAdding)
Definition WsfComponentFactoryList.hpp:137
A template that defines a component factory for a given parent class.
Definition WsfComponentFactory.hpp:54
Contains the data required to create a simulation, and acts as the entry point for input file process...
Definition WsfScenario.hpp:111
Definition WsfComponentRoles.hpp:60