WSF
WsfObjectTypeListBase.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 WSFOBJECTTYPELISTBASE_HPP
13#define WSFOBJECTTYPELISTBASE_HPP
14
15#include <map>
16#include <memory>
17#include <set>
18#include <vector>
19
20class UtInput;
22class WsfObject;
23class WsfPlatform;
24class WsfScenario;
25#include "WsfStringId.hpp"
26#include "WsfTypes.hpp"
27
28template<typename T>
30
32{
33class LoadTypeP_Later;
34}
35
38{
39public:
40 typedef std::vector<WsfStringId> TypeIdList;
41
42 virtual ~WsfObjectTypeListBaseI() = default;
43 virtual void Clear() = 0;
44
45 virtual bool ProcessInput(UtInput& aInput) = 0;
46 virtual void CompleteLoad() {}
47
48 virtual WsfObject* Clone(WsfStringId aId) const = 0;
49 virtual WsfObject* Find(WsfStringId aId) const = 0;
50 virtual const std::string& GetBlockName() const = 0;
51 virtual void GetTypeIds(TypeIdList& aListOfIds) const = 0;
52};
53
56template<typename T>
58{
59public:
61 : mActualTypeListPtr(aActualTypeListPtr)
62 {
63 }
64
66
67 void Clear() override { mActualTypeListPtr->Clear(); }
68
69 bool ProcessInput(UtInput& aInput) override { return mActualTypeListPtr->ProcessInput(aInput); }
70
71 void CompleteLoad() override { return mActualTypeListPtr->CompleteLoad(); }
72
73 T* Clone(WsfStringId aId) const override { return (T*)mActualTypeListPtr->Clone(aId); }
74
75 T* Find(WsfStringId aId) const override { return (T*)mActualTypeListPtr->Find(aId); }
76
77 const std::string& GetBlockName() const override { return mActualTypeListPtr->GetBlockName(); }
78
79 void GetTypeIds(TypeIdList& aListOfIds) const override { return mActualTypeListPtr->GetTypeIds(aListOfIds); }
80
81protected:
83
85};
86
89{
90public:
93
94 friend class WsfObjectTypeListDetail::LoadTypeP_Later;
95
96 enum Flags
97 {
98 // A type may be defined more than once; only the last definition remains.
100 // There is no base type, 'new BaseType' is done for each instance
102 // The base type is found in an object factory
104 // Disable deferred loading. This should be used for types that do not depend on other types
106 // Flags used for signature type lists
108 };
109
110 WsfObjectTypeListBase(unsigned int aFlags,
111 const std::string& aBlockName = std::string(),
112 WsfScenario* aScenarioPtr = nullptr);
113
114 ~WsfObjectTypeListBase() override;
115
117 void Clear() override;
118
120 void GetTypeIds(TypeIdList& aListOfIds) const override;
121
122 bool ProcessInput(UtInput& aInput) override;
123
125 int Size() const { return (int)mTypeMap.size(); }
126
127 WsfObject* Clone(WsfStringId aId) const override = 0;
128 WsfObject* Find(WsfStringId aId) const override = 0;
129
130 const std::string& GetBlockName() const override { return mBlockName; }
131
133
134protected:
135 WsfDeferredInput& GetDeferredInput() const;
136
137 bool CanDelayLoad() const { return (mFlags & cNO_DELAY_LOAD) == 0; }
138
139 bool AddP(WsfStringId aId, std::unique_ptr<WsfObject> aDefinitionPtr);
140
141 WsfObject* CloneP(WsfStringId aId) const;
142
143 virtual WsfObject* FindP(WsfStringId aId) const;
144
145 virtual bool InitializeTypeP(WsfObject* aObjectPtr) = 0;
146
147 bool LoadTypeP(UtInput& aInput, WsfObject*& aLoadedObjectPtr);
148
149 virtual bool DeferredLoadTypeP(UtInput& aInput, WsfObject*& aLoadedObjectPtr);
150
151 bool DeleteComponentP(UtInput& aInput, WsfPlatform& aPlatform, int aRole, bool aIsNamed);
152
153 bool LoadComponentP(UtInput& aInput, WsfPlatform& aPlatform, bool aIsAdding, int aRole, bool aIsNamed, bool aIsEditable);
154
155 typedef std::map<WsfStringId, std::unique_ptr<WsfObject>> TypeMap;
157
159 std::vector<std::unique_ptr<WsfObject>> mRedefinedTypes;
160
161 std::set<WsfStringId> mCoreTypes;
162
163 unsigned int mFlags;
164
165 const std::string mBlockName;
166
167 WsfObject* (*mCreateSingularTypeFunction)();
168 WsfObject* (*mFactoryCreateFunction)(void* aListPtr, const std::string& aTypeName);
169 WsfObject* (*mFactoryCreateDefault)();
172};
173
174#endif
UtStringId WsfStringId
WsfStringId – the same thing as UtStringId.
Definition WsfStringId.hpp:23
#define WSF_EXPORT
Definition WsfXIO_Export.hpp:35
Definition WsfDeferredInput.hpp:42
The interface an object type list must support.
Definition WsfObjectTypeListBase.hpp:38
virtual ~WsfObjectTypeListBaseI()=default
std::vector< WsfStringId > TypeIdList
Definition WsfObjectTypeListBase.hpp:40
virtual void CompleteLoad()
Definition WsfObjectTypeListBase.hpp:46
virtual void Clear()=0
virtual bool ProcessInput(UtInput &aInput)=0
virtual WsfObject * Find(WsfStringId aId) const =0
virtual void GetTypeIds(TypeIdList &aListOfIds) const =0
virtual WsfObject * Clone(WsfStringId aId) const =0
virtual const std::string & GetBlockName() const =0
Base class for WsfObjectTypeList. Provides most of the implementation.
Definition WsfObjectTypeListBase.hpp:89
TypeMap mTypeMap
Definition WsfObjectTypeListBase.hpp:156
WsfScenario * GetScenario() const
Definition WsfObjectTypeListBase.hpp:132
WsfObject * Clone(WsfStringId aId) const override=0
bool DeleteComponentP(UtInput &aInput, WsfPlatform &aPlatform, int aRole, bool aIsNamed)
Definition WsfObjectTypeList.cpp:304
bool CanDelayLoad() const
Definition WsfObjectTypeListBase.hpp:137
unsigned int mFlags
Definition WsfObjectTypeListBase.hpp:163
virtual bool InitializeTypeP(WsfObject *aObjectPtr)=0
const std::string & GetBlockName() const override
Definition WsfObjectTypeListBase.hpp:130
std::map< WsfStringId, std::unique_ptr< WsfObject > > TypeMap
Definition WsfObjectTypeListBase.hpp:155
bool LoadTypeP(UtInput &aInput, WsfObject *&aLoadedObjectPtr)
Definition WsfObjectTypeList.cpp:164
int Size() const
Return the current number of types being maintained by the list.
Definition WsfObjectTypeListBase.hpp:125
const std::string mBlockName
Definition WsfObjectTypeListBase.hpp:165
std::set< WsfStringId > mCoreTypes
Definition WsfObjectTypeListBase.hpp:161
WsfScenario * mScenarioPtr
Definition WsfObjectTypeListBase.hpp:171
std::vector< std::unique_ptr< WsfObject > > mRedefinedTypes
A list of type objects that have been redefined.
Definition WsfObjectTypeListBase.hpp:159
WsfObject * Find(WsfStringId aId) const override=0
Flags
Definition WsfObjectTypeListBase.hpp:97
@ cSIGNATURE_FLAGS
Definition WsfObjectTypeListBase.hpp:107
@ cREDEFINITION_ALLOWED
Definition WsfObjectTypeListBase.hpp:99
@ cOBJECT_FACTORY_BASE
Definition WsfObjectTypeListBase.hpp:103
@ cSINGULAR_BASE_TYPE
Definition WsfObjectTypeListBase.hpp:101
@ cNO_DELAY_LOAD
Definition WsfObjectTypeListBase.hpp:105
void * mFactoryPtr
Definition WsfObjectTypeListBase.hpp:170
bool LoadComponentP(UtInput &aInput, WsfPlatform &aPlatform, bool aIsAdding, int aRole, bool aIsNamed, bool aIsEditable)
Definition WsfObjectTypeList.cpp:350
virtual bool DeferredLoadTypeP(UtInput &aInput, WsfObject *&aLoadedObjectPtr)
Definition WsfObjectTypeList.cpp:281
WsfObjectTypeListBase(const WsfObjectTypeListBase &)=delete
WsfObjectTypeListBase & operator=(const WsfObjectTypeListBase &)=delete
void Clear() override
Definition WsfObjectTypeListBase.hpp:67
bool ProcessInput(UtInput &aInput) override
Definition WsfObjectTypeListBase.hpp:69
~WsfObjectTypeListFwd() override
Definition WsfObjectTypeListBase.hpp:65
void CompleteLoad() override
Definition WsfObjectTypeListBase.hpp:71
T * Clone(WsfStringId aId) const override
Definition WsfObjectTypeListBase.hpp:73
WsfObjectTypeListBaseI * mActualTypeListPtr
Definition WsfObjectTypeListBase.hpp:84
void GetTypeIds(TypeIdList &aListOfIds) const override
Definition WsfObjectTypeListBase.hpp:79
WsfObjectTypeList< T > * TypeList()
Definition WsfObjectTypeListBase.hpp:82
const std::string & GetBlockName() const override
Definition WsfObjectTypeListBase.hpp:77
T * Find(WsfStringId aId) const override
Definition WsfObjectTypeListBase.hpp:75
WsfObjectTypeListFwd(WsfObjectTypeListBaseI *aActualTypeListPtr)
Definition WsfObjectTypeListBase.hpp:60
Definition WsfObjectTypeList.hpp:42
Definition WsfObject.hpp:40
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
Definition WsfObjectTypeList.cpp:149
Copyrights Multiple, All Rights Reserved