WSF
WsfObject.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 WSFOBJECT_HPP
13#define WSFOBJECT_HPP
14
15#include <memory>
16#include <vector>
17
18class UtInput;
19#include "wsf_export.h"
20
21#include "UtReferenceTracked.hpp"
22#include "UtScriptAccessible.hpp"
23#include "WsfStringId.hpp"
24
25// =================================================================================================
26// PROGRAMMING NOTE: See the source code file for information about thread-safety.
27// DO NOT MODIFY THIS CLASS IF YOU DON'T UNDERSTAND THE INFORMATION.
28// =================================================================================================
29
39class WSF_EXPORT WsfObject : public UtScriptAccessible, public UtReferenceTracked
40{
41public:
43 friend class WsfPluginManager;
44
46 // See comments in code why this is a vector and not a list.
47 typedef std::vector<WsfStringId> TypeList;
48
49 WsfObject();
50 ~WsfObject() override;
51
52 const char* GetScriptClassName() const override;
53
56 virtual WsfObject* Clone() const = 0;
57
58 virtual bool ProcessInput(UtInput& aInput);
59
61
62 const std::string& GetName() const;
63
66 WsfStringId GetNameId() const { return mName; }
67
70 void SetName(WsfStringId aName) { mName = aName; }
72
74
75 const std::string& GetType() const;
76
78 WsfStringId GetTypeId() const { return mTypeDataPtr->mType; }
79
80 void SetType(WsfStringId aType);
81
82 const std::string& GetBaseType() const;
83
86 WsfStringId GetBaseTypeId() const { return mTypeDataPtr->mBaseType; }
87
92 const TypeList& GetTypeList() const { return mTypeDataPtr->mTypeList; }
93
97 bool IsA_TypeOf(WsfStringId aType) const { return mTypeDataPtr->IsA_TypeOf(aType); }
99
100 WsfObject& operator=(const WsfObject& aRhs);
101
103 template<typename T>
104 void Serialize(T& aBuff)
105 {
106 aBuff& mName & mTypeDataPtr->mType & mTypeDataPtr->mBaseType & mTypeDataPtr->mTypeList;
107 }
108
109protected:
110 WsfObject(const WsfObject& aSrc);
111
112private:
113 void SetTypeAndBaseType(WsfStringId aType, WsfStringId aBaseType);
114
116 WsfStringId mName;
117
119 class SharedTypeData
120 {
121 public:
122 void AddToTypeList(WsfStringId aType);
123
124 bool IsA_TypeOf(WsfStringId aType) const;
125
127 WsfStringId mType;
128
134 WsfStringId mBaseType;
135
138 TypeList mTypeList;
139 };
140
141 std::shared_ptr<SharedTypeData> mTypeDataPtr;
142};
143
146{
147public:
149 : WsfObject()
150 {
151 }
152 WsfObject* Clone() const override;
153};
154
155#endif
UtStringId WsfStringId
WsfStringId – the same thing as UtStringId.
Definition WsfStringId.hpp:23
#define WSF_EXPORT
Definition WsfXIO_Export.hpp:35
Definition WsfObject.hpp:40
const std::string & GetName() const
Definition WsfObject.cpp:235
void Serialize(T &aBuff)
For XIO (de)serialization.
Definition WsfObject.hpp:104
WsfStringId GetTypeId() const
Get the string ID of the 'type' of the object.
Definition WsfObject.hpp:78
WsfStringId GetNameId() const
Definition WsfObject.hpp:66
friend class WsfObjectTypeListBase
Definition WsfObject.hpp:42
std::vector< WsfStringId > TypeList
The list of types returned by GetTypeList.
Definition WsfObject.hpp:47
WsfObject()
This is the constructor for the WsfObject class.
Definition WsfObject.cpp:88
void SetName(WsfStringId aName)
Definition WsfObject.hpp:70
friend class WsfPluginManager
Definition WsfObject.hpp:43
bool IsA_TypeOf(WsfStringId aType) const
Definition WsfObject.hpp:97
WsfStringId GetBaseTypeId() const
Definition WsfObject.hpp:86
virtual WsfObject * Clone() const =0
const TypeList & GetTypeList() const
Definition WsfObject.hpp:92
virtual bool ProcessInput(UtInput &aInput)
Definition WsfObject.cpp:140
const char * GetScriptClassName() const override
Definition WsfObject.cpp:115
WsfUncloneableObject()
Definition WsfObject.hpp:148
Copyrights Multiple, All Rights Reserved