WSF
WsfPProxyObjectMap.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// Updated by Infoscitex, a DCS Company.
13// ****************************************************************************
14
15#ifndef WSFPPROXYOBJECTMAP_HPP
16#define WSFPPROXYOBJECTMAP_HPP
17
18#include <cassert>
19#include <map>
20
21#include "UtMemoryDebug.hpp"
22
23// clang-format off
24#include "WsfPProxyValue.hpp"
25#include "WsfPProxyType.hpp"
26// clang-format on
27
28class WSF_PARSER_EXPORT WsfPProxyObjectMapType;
29
30//
31// Proxy object maps are maps from string to a single proxy type.
32//
33
34// The proxy object map instance
35class WSF_PARSER_EXPORT WsfPProxyObjectMap
36{
37public:
39
41 : mTypePtr()
42 , mIsInherited(false)
43 {
44 mFiller[0] = mFiller[1] = mFiller[2] = 0;
45 }
46
48 : mTypePtr(aDataTypePtr)
49 , mIsInherited(false)
50 {
51 }
52
55
56 WsfPProxyType* GetDataType();
57
58 WsfPProxyValue AddNew(const std::string& aName, WsfPProxyValue aValue, bool aOverrideExisting = false);
59
60 WsfPProxyValue GetAt(const std::string& aName);
61
62 WsfPProxyValue* FindAt(const std::string& aName);
63
64 bool Erase(const std::string& aName);
65 bool EraseNoDelete(const std::string& aName);
66
67 bool UserErase(const std::string& aName);
68 bool UserEraseNoDelete(const std::string& aName);
69 bool UserUndelete(const std::string& aName);
70 bool HasUserDeleted(const std::string& aName) const;
71
72 void Clear();
73
74 std::map<std::string, WsfPProxyValue>& GetValues() { return mValues; }
75
76 void SetInherited(bool aIsInherited) { mIsInherited = aIsInherited; }
77
78 size_t MemoryUsage() const;
79
80 std::vector<std::string> GetObjectNames() const
81 {
82 std::vector<std::string> names;
83 for (auto i = mValues.begin(); i != mValues.end(); ++i)
84 {
85 names.push_back(i->first);
86 }
87 return names;
88 }
89
90 using iterator = std::map<std::string, WsfPProxyValue>::iterator;
91
92protected:
93 // The proxy type for this map
95
96 // The values in the map
97 std::map<std::string, WsfPProxyValue> mValues;
98 std::set<std::string> mDeletedValues;
100 char mFiller[3];
101
102private:
103 WsfPProxyObjectMap& operator=(const WsfPProxyObjectMap& aRhs); // no implementation
104
105 UT_MEMORY_DEBUG_MARKER(cMDB_PROXY_MAP);
106};
107
108// The proxy type representing the object map for a particular type
109class WSF_PARSER_EXPORT WsfPProxyObjectMapType : public WsfPProxyType
110{
111public:
113 : WsfPProxyType(WsfProxy::cOBJECT_MAP)
114 , mTypePtr(aDataTypePtr)
115 {
117 }
118
119 void Construct(void* aValuePtr) const override;
120
121 void Destroy(void* aValuePtr) const override;
122 void Copy(void* dest, void* src, int flags) const override;
123 WsfPProxyValue GetAttr(void* aValuePtr, const std::string& aName) const override;
124 bool SwapAttr(void* aPtr, const WsfPProxyKey& aKey, WsfPProxyValue& aValue) const override;
125 bool IsUnset(void* aValuePtr) const override;
126 void SetUnset(void* aValuePtr) const override;
127 bool IsInherited(void* aValuePtr) const override
128 {
129 WsfPProxyObjectMap* ptr = (WsfPProxyObjectMap*)aValuePtr;
130 return ptr->mIsInherited;
131 }
132 void SetInherited(void* aValuePtr, bool aIsInherited) const override
133 {
134 WsfPProxyObjectMap* ptr = (WsfPProxyObjectMap*)aValuePtr;
135 ptr->mIsInherited = aIsInherited;
136 }
137
138 WsfPProxyType* GetDataType() const { return mTypePtr; }
139 WsfPProxyType* GetContainedType(size_t aIndex) const override { return mTypePtr; }
140 // virtual WsfPProxyHash Hash(void* aDataPtr) const;
141 size_t MemoryUsage(void* aDataPtr) const override;
142
143private:
144 // The proxy type stored in the map
145 WsfPProxyType* mTypePtr;
146};
147
148#endif
@ cMDB_PROXY_MAP
Definition WsfParseDebugMarkers.hpp:20
Definition WsfPProxyKey.hpp:24
Definition WsfPProxyObjectMap.hpp:110
bool IsInherited(void *aValuePtr) const override
Definition WsfPProxyObjectMap.hpp:127
WsfPProxyObjectMapType(WsfPProxyType *aDataTypePtr)
Definition WsfPProxyObjectMap.hpp:112
WsfPProxyType * GetDataType() const
Definition WsfPProxyObjectMap.hpp:138
void SetInherited(void *aValuePtr, bool aIsInherited) const override
Definition WsfPProxyObjectMap.hpp:132
WsfPProxyType * GetContainedType(size_t aIndex) const override
Definition WsfPProxyObjectMap.hpp:139
Definition WsfPProxyObjectMap.hpp:36
std::map< std::string, WsfPProxyValue > mValues
Definition WsfPProxyObjectMap.hpp:97
const WsfPProxyObjectMapType * mTypePtr
Definition WsfPProxyObjectMap.hpp:94
WsfPProxyObjectMap()
Definition WsfPProxyObjectMap.hpp:40
std::map< std::string, WsfPProxyValue >::iterator iterator
Definition WsfPProxyObjectMap.hpp:90
std::vector< std::string > GetObjectNames() const
Definition WsfPProxyObjectMap.hpp:80
void SetInherited(bool aIsInherited)
Definition WsfPProxyObjectMap.hpp:76
WsfPProxyObjectMap(const WsfPProxyObjectMapType *aDataTypePtr)
Definition WsfPProxyObjectMap.hpp:47
bool mIsInherited
Definition WsfPProxyObjectMap.hpp:99
friend class WsfPProxyObjectMapType
Definition WsfPProxyObjectMap.hpp:38
char mFiller[3]
Definition WsfPProxyObjectMap.hpp:100
std::set< std::string > mDeletedValues
Definition WsfPProxyObjectMap.hpp:98
std::map< std::string, WsfPProxyValue > & GetValues()
Definition WsfPProxyObjectMap.hpp:74
Definition WsfPProxyType.hpp:37
WsfPProxyType(WsfProxy::ValueKind aKind)
Definition WsfPProxyType.hpp:39
size_t mDataSize
Definition WsfPProxyType.hpp:58
Definition WsfPProxyValue.hpp:33
Definition WsfPProxyBasicValues.hpp:41
Copyrights Multiple, All Rights Reserved