WSF
ProxyMerge.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 PROXYMERGE_HPP
13#define PROXYMERGE_HPP
14
15#include <map>
16
17#include "UtMemoryPool.hpp"
18#include "UtSHA.hpp"
19#include "ViExport.hpp"
20#include "WsfPProxyPath.hpp"
21#include "WsfPProxyValue.hpp"
22
23class WsfPProxy;
24
25namespace wizard
26{
28{
29public:
33 // Initialize() Must be called prior to calling FindChild()
34 void Initialize();
35 ProxyHashNode* Add(const WsfPProxyKey& aAddr);
36 struct Entry
37 {
38 bool operator<(const Entry& e) const { return mAddr < e.mAddr; }
39
42 };
43
44 const std::vector<Entry>& Children() { return mEntries; }
45
46private:
47 // Define a std::map with a memory pool allocator. This provides a sorted container with contiguous memory.
48 // typedef UtMemoryPoolAllocator<ProxyHashNode> NodeAllocator;
49 // typedef std::map<WsfPProxyPathEntry, ProxyHashNode, std::less<WsfPProxyPathEntry>, NodeAllocator> NodeMap;
50 // typedef std::unordered_map<WsfPProxyPathEntry, ProxyHashNode*, WsfPProxyPathEntryHash> NodeMap;
51 // NodeMap mChildren;
52 std::vector<Entry> mEntries;
53};
54
56{
57public:
58 explicit ProxyHash(WsfPProxyValue aRootValue);
59
60 ProxyHashNode* Find(const WsfPProxyPath& aPath);
61 ProxyHashNode& Root() { return mRoot; }
63
64protected:
66 const WsfPProxyKey& aValueAddr,
67 WsfPProxyValue aRootValue,
68 bool aIsParentStruct);
72};
73
75{
76public:
77 virtual ~ProxyMergeVisitor() = default;
79 {
80 cNEW, // aNewValue did not exist before, aOldValue is null
81 cCHANGED, // The value has changed. aNewValue contains the new value.
82 cDELETED, // The value has been deleted, aNewValue is null
84 };
85
86 // Accept() is called at every proxy value which has changed, providing the old and new values
87 // return 'true' to continue accepting children of the proxy value
88 // return 'false' to indicate no children need to be processed
89 virtual bool Accept(CompareResult aCompareResult,
90 const WsfPProxyPath& aPath,
91 WsfPProxyValue aOldValue,
92 WsfPProxyValue aNewValue) = 0;
93};
94
96{
97public:
98 ProxyMerge(ProxyHash* aOldHash, ProxyHash* aNewHash, WsfPProxy* aOldProxy, WsfPProxy* aNewProxy);
99
100 void Visit(ProxyMergeVisitor* aVisitor);
101
102 WsfPProxyValue GetOldRoot() const { return mOldHash ? mOldHash->RootValue() : WsfPProxyValue(); }
103 WsfPProxyValue GetNewRoot() const { return mNewHash ? mNewHash->RootValue() : WsfPProxyValue(); }
104 WsfPProxy* GetOldProxy() const { return mOldProxy; }
105 WsfPProxy* GetNewProxy() const { return mNewProxy; }
106
107private:
108 void VisitR(ProxyMergeVisitor* aVisitor,
109 ProxyHashNode* aNewHash,
110 ProxyHashNode* aOldHash,
111 WsfPProxyValue aNewValue,
112 WsfPProxyValue aOldValue,
113 WsfPProxyPath aPath);
114 void VisitBasicChildren(ProxyMergeVisitor* aVisitorPtr,
115 WsfPProxyValue aNewValue,
116 WsfPProxyValue aOldValue,
117 WsfPProxyPath& aPath);
118
119 ProxyHash* mOldHash;
120 ProxyHash* mNewHash;
121 WsfPProxy* mOldProxy;
122 WsfPProxy* mNewProxy;
123};
124} // namespace wizard
125#endif
#define VI_EXPORT
Definition ViExport.hpp:38
@ cMDB_ProxyHash
Definition ViMemoryDebugMarkers.hpp:19
Container for a UtSHA Digest.
Definition UtSHA.hpp:88
Definition WsfPProxyHash.hpp:26
Definition WsfPProxyKey.hpp:24
Represents a path or unique key to a value in the proxy.
Definition WsfPProxyPath.hpp:64
Definition WsfPProxyValue.hpp:33
Definition WsfPProxy.hpp:32
Definition ProxyMerge.hpp:28
void Initialize()
Definition ProxyMerge.cpp:324
ProxyHashNode * Add(const WsfPProxyKey &aAddr)
Definition ProxyMerge.cpp:329
const std::vector< Entry > & Children()
Definition ProxyMerge.hpp:44
ProxyHashNode * FindChild(const WsfPProxyKey &e)
Definition ProxyMerge.cpp:346
UtSHA_Digest mDigest
Definition ProxyMerge.hpp:30
Definition ProxyMerge.hpp:56
WsfPProxyHash RecurseHash(ProxyHashNode *aParentPtr, const WsfPProxyKey &aValueAddr, WsfPProxyValue aRootValue, bool aIsParentStruct)
Definition ProxyMerge.cpp:22
WsfPProxyValue mRootValue
Definition ProxyMerge.hpp:70
WsfPProxyValue RootValue() const
Definition ProxyMerge.hpp:62
ProxyHashNode & Root()
Definition ProxyMerge.hpp:61
UT_MEMORY_DEBUG_MARKER(cMDB_ProxyHash)
ProxyHashNode * Find(const WsfPProxyPath &aPath)
Definition ProxyMerge.cpp:115
ProxyHash(WsfPProxyValue aRootValue)
Definition ProxyMerge.cpp:127
ProxyHashNode mRoot
Definition ProxyMerge.hpp:69
Definition ProxyMerge.hpp:75
CompareResult
Definition ProxyMerge.hpp:79
@ cDELETED
Definition ProxyMerge.hpp:82
@ cNO_CHANGE
Definition ProxyMerge.hpp:83
@ cNEW
Definition ProxyMerge.hpp:80
@ cCHANGED
Definition ProxyMerge.hpp:81
virtual ~ProxyMergeVisitor()=default
virtual bool Accept(CompareResult aCompareResult, const WsfPProxyPath &aPath, WsfPProxyValue aOldValue, WsfPProxyValue aNewValue)=0
void Visit(ProxyMergeVisitor *aVisitor)
Definition ProxyMerge.cpp:317
WsfPProxy * GetOldProxy() const
Definition ProxyMerge.hpp:104
ProxyMerge(ProxyHash *aOldHash, ProxyHash *aNewHash, WsfPProxy *aOldProxy, WsfPProxy *aNewProxy)
Definition ProxyMerge.cpp:134
WsfPProxyValue GetOldRoot() const
Definition ProxyMerge.hpp:102
WsfPProxyValue GetNewRoot() const
Definition ProxyMerge.hpp:103
WsfPProxy * GetNewProxy() const
Definition ProxyMerge.hpp:105
Definition Runner.hpp:22
Definition ProxyMerge.hpp:37
bool operator<(const Entry &e) const
Definition ProxyMerge.hpp:38
WsfPProxyKey mAddr
Definition ProxyMerge.hpp:40
ProxyHashNode * mNode
Definition ProxyMerge.hpp:41
Copyrights Multiple, All Rights Reserved