WSF
WsfPProxyIndex.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 WSFPPROXYINDEX_HPP
16#define WSFPPROXYINDEX_HPP
17
18#include "wsf_parser_export.h"
19
20#include <map>
21#include <memory>
22#include <unordered_map>
23
24#include "UtMemory.hpp"
25#include "UtTextDocument.hpp"
26#include "WsfPProxyPath.hpp"
28
29class WsfParseNode;
31{
33 // If set, this is a parse node containing commands that operate on this proxy value
35};
36
37class WSF_PARSER_EXPORT WsfPProxyIndexNode
38{
39public:
41 : mAddr(e)
42 , mParentPtr(aParentPtr)
43 {
44 }
45
48
50
52 {
53 auto iter = mChildren.find(e);
54 if (iter != mChildren.end())
55 {
56 return iter->second.get();
57 }
58 return nullptr;
59 }
60
62 {
63 auto it = mChildren.find(e);
64 if (it == mChildren.end())
65 {
66 std::tie(it, std::ignore) = mChildren.insert(std::make_pair(e, ut::make_unique<WsfPProxyIndexNode>(this, e)));
67 }
68 return *(it->second);
69 }
70
71 void AddLocation(WsfParseNode* aNodePtr, int aEntryType)
72 {
74 e.mNodePtr = aNodePtr;
75 e.mEntryType = aEntryType;
76 mEntries.push_back(e);
77 }
79 {
80 if (mParentPtr)
81 {
82 mParentPtr->GetPath(aPath);
83 aPath += mAddr;
84 }
85 }
88 std::vector<WsfPProxyIndexEntry> mEntries;
89 using NodeMap = std::unordered_map<WsfPProxyKey, std::unique_ptr<WsfPProxyIndexNode>, WsfPProxyPathEntryHash>;
91
92private:
93};
94
95class WSF_PARSER_EXPORT WsfPProxyIndex
96{
97public:
107 WsfPProxyIndexNode* Find(const WsfPProxyPath& aPath);
108 WsfPProxyIndexNode& Get(const WsfPProxyPath& aPath);
109 WsfPProxyIndexNode& Root() { return mRoot; }
110
111 void SetCurrentProxyPath(const WsfPProxyPath& aPath, WsfParseNode* aNodePtr);
112
113 void BuildReverseIndex();
114
116 {
117 bool operator<(const ReverseIndexEntry& aRhs) const { return mLocation < aRhs.mLocation; }
118 UtTextDocumentLocation mLocation;
122 };
123 const std::vector<ReverseIndexEntry>& GetReverseIndex() const { return mReverseIndex; }
124
125 ReverseIndexEntry* FindByParseNodeIndex(size_t& aParseNodeIndex, size_t& aSubEntry);
126
127 const WsfPProxyPath* FindCurrentPath(WsfParseNode* aNodePtr);
129
130private:
131 void BuildReverseIndexR(WsfPProxyIndexNode& aNode);
132
134 std::vector<ReverseIndexEntry> mReverseIndex;
135 struct NodeIndexMapping
136 {
137 NodeIndexMapping()
138 : mLexicalIndex(0)
139 , mReverseIndex(0)
140 , mEntryIndex(0)
141 {
142 }
143 NodeIndexMapping(size_t aLexicalIndex);
144
145 bool operator<(const NodeIndexMapping& aRhs) const { return mLexicalIndex < aRhs.mLexicalIndex; }
146 bool operator<(size_t aLexicalIndex) const { return mLexicalIndex < aLexicalIndex; }
147
148 size_t mLexicalIndex;
149 size_t mReverseIndex;
150 size_t mEntryIndex;
151 };
153 std::vector<NodeIndexMapping> mNodeIndexMappingList;
154
156 WsfPProxyIndexNode mRoot;
157
158 // WsfPProxyPath mRecordNodeCurrentPath;
159 WsfPProxyPath* mEmptyPath;
160 std::map<size_t, WsfPProxyPath*> mNodeCurrentPaths;
161
162 UT_MEMORY_DEBUG_MARKER(cMDB_PROXY_INDEX);
163};
164
165#endif
@ cMDB_PROXY_INDEX
Definition WsfParseDebugMarkers.hpp:22
Definition WsfPProxyIndex.hpp:38
WsfPProxyIndexNode * FindChild(const WsfPProxyKey &e)
Definition WsfPProxyIndex.hpp:51
WsfPProxyIndexNode & GetChild(const WsfPProxyKey &e)
Definition WsfPProxyIndex.hpp:61
std::vector< WsfPProxyIndexEntry > mEntries
Definition WsfPProxyIndex.hpp:88
WsfPProxyIndexNode(WsfPProxyIndexNode *aParentPtr, const WsfPProxyKey &e)
Definition WsfPProxyIndex.hpp:40
NodeMap mChildren
Definition WsfPProxyIndex.hpp:90
WsfPProxyIndexNode(const WsfPProxyIndexNode &)=delete
void GetPath(WsfPProxyPath &aPath)
Definition WsfPProxyIndex.hpp:78
~WsfPProxyIndexNode()
Definition WsfPProxyIndex.hpp:49
WsfPProxyKey mAddr
Definition WsfPProxyIndex.hpp:86
void AddLocation(WsfParseNode *aNodePtr, int aEntryType)
Definition WsfPProxyIndex.hpp:71
WsfPProxyIndexNode * mParentPtr
Definition WsfPProxyIndex.hpp:87
std::unordered_map< WsfPProxyKey, std::unique_ptr< WsfPProxyIndexNode >, WsfPProxyPathEntryHash > NodeMap
Definition WsfPProxyIndex.hpp:89
WsfPProxyIndexNode & operator=(const WsfPProxyIndexNode &)=delete
Definition WsfPProxyIndex.hpp:96
WsfPProxyIndex()
Definition WsfPProxyIndex.cpp:155
const std::vector< ReverseIndexEntry > & GetReverseIndex() const
Definition WsfPProxyIndex.hpp:123
WsfPProxyIndexNode & Root()
Definition WsfPProxyIndex.hpp:109
EntryType
Definition WsfPProxyIndex.hpp:99
@ cASSIGNED
Definition WsfPProxyIndex.hpp:102
@ cEDITED
Definition WsfPProxyIndex.hpp:101
@ cREMOVED
Definition WsfPProxyIndex.hpp:103
@ cADDED
Definition WsfPProxyIndex.hpp:100
bool mRecordCurrentPath
Definition WsfPProxyIndex.hpp:128
Definition WsfPProxyKey.hpp:24
Represents a path or unique key to a value in the proxy.
Definition WsfPProxyPath.hpp:64
Definition WsfParseNode.hpp:61
Definition WsfPProxyIndex.hpp:31
int mEntryType
Definition WsfPProxyIndex.hpp:32
WsfParseNode * mNodePtr
Definition WsfPProxyIndex.hpp:34
Definition WsfPProxyIndex.hpp:116
size_t mEntryIndex
Definition WsfPProxyIndex.hpp:121
WsfPProxyIndexNode * mNodePtr
Definition WsfPProxyIndex.hpp:119
size_t mLexicalIndex
Definition WsfPProxyIndex.hpp:120
bool operator<(const ReverseIndexEntry &aRhs) const
Definition WsfPProxyIndex.hpp:117
UtTextDocumentLocation mLocation
Definition WsfPProxyIndex.hpp:118
Definition WsfPProxyPath.hpp:38
Copyrights Multiple, All Rights Reserved