WSF
ProxyWatcher.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 PROXYWATCHER_HPP
13#define PROXYWATCHER_HPP
14
15#include "ProxyChange.hpp"
16#include "ProxyWatchNode.hpp"
17#include "UtCallback.hpp"
18#include "UtCallbackHolder.hpp"
19#include "ViExport.hpp"
20#include "WsfPProxyPath.hpp"
21
22class WsfPProxyNode;
23
24namespace wizard
25{
26class ProxyMerge;
27class ProxyWatcher_Merger;
28
29// usage:
30// watchProxy(myPath).DirectUpdate.Connect(this, &MyClass::MyFunction);
32{
33public:
34 friend class ProxyWatcher_Merger;
35
36 // Called when the proxy becomes available or unavailable
37 // aProxyPtr is null if not available
38 // ProxyAvailable(WsfPProxy* aProxyPtr);
39 static UtCallbackListN<void(WsfPProxy*)> ProxyAvailable;
40 static WsfPProxy* GetActiveProxy();
41
42 // Called when a proxy node is renamed.
43 // HandleNodeRenamed(const WsfPProxyPath& aOldPath,
44 // const WsfPProxyNode& aRenamedNode);
45 static UtCallbackListN<void(const WsfPProxyPath&, const WsfPProxyPath&)> NodeRenamed;
46
48 ~ProxyWatcher() = default;
49
50 static void Create();
51 static void Destroy();
52 static ProxyWatcher* Instance();
53
54 void EmitOptionChange(const WsfPProxyNode& aNode);
55 void EmitOptionChange(const WsfPProxyPath& aPath);
56
57 ProxyWatchNode& Watch(const WsfPProxyPath& aPath);
58
59 void HandleProxyModified(const WsfPProxyNode& aNode);
60 void HandleProxyAdded(const WsfPProxyNode& aNode);
61 void HandleProxyRemoved(const WsfPProxyNode& aNode);
62 void HandleProxyMoved(const WsfPProxyNode& aOldNode, const WsfPProxyNode& aNewNode);
63
64private:
65 void HandleMerge(ProxyMerge* aMerge);
66 void HandleProxyInvalidate();
67 void NotifyUp(const ProxyChange& aChange);
68 void NotifyDown(const ProxyChange& aChange);
69 ProxyWatchNode* Find(const WsfPProxyPath& aPath, int aMaxDepth = 10000);
70
71 UtCallbackHolder mCallbacks;
72 ProxyWatchNode mRoot;
73 WsfPProxy* mProxyAvailable;
74};
75
77} // namespace wizard
78#endif
#define VI_EXPORT
Definition ViExport.hpp:38
Definition WsfPProxyNode.hpp:60
Represents a path or unique key to a value in the proxy.
Definition WsfPProxyPath.hpp:64
Definition WsfPProxy.hpp:32
Records a change to proxy data.
Definition ProxyChange.hpp:21
Definition ProxyMerge.hpp:96
Definition ProxyWatchNode.hpp:29
static UtCallbackListN< void(WsfPProxy *)> ProxyAvailable
Definition ProxyWatcher.hpp:39
void HandleProxyModified(const WsfPProxyNode &aNode)
Definition ProxyWatcher.cpp:201
void HandleProxyRemoved(const WsfPProxyNode &aNode)
Definition ProxyWatcher.cpp:189
static void Create()
Definition ProxyWatcher.cpp:44
static ProxyWatcher * Instance()
Definition ProxyWatcher.cpp:54
ProxyWatcher()
Definition ProxyWatcher.cpp:35
void EmitOptionChange(const WsfPProxyNode &aNode)
Definition ProxyWatcher.cpp:221
static void Destroy()
Definition ProxyWatcher.cpp:49
static WsfPProxy * GetActiveProxy()
Definition ProxyWatcher.cpp:216
ProxyWatchNode & Watch(const WsfPProxyPath &aPath)
Definition ProxyWatcher.cpp:30
friend class ProxyWatcher_Merger
Definition ProxyWatcher.hpp:34
static UtCallbackListN< void(const WsfPProxyPath &, const WsfPProxyPath &)> NodeRenamed
Definition ProxyWatcher.hpp:45
void HandleProxyMoved(const WsfPProxyNode &aOldNode, const WsfPProxyNode &aNewNode)
Definition ProxyWatcher.cpp:182
void HandleProxyAdded(const WsfPProxyNode &aNode)
Definition ProxyWatcher.cpp:195
Definition Runner.hpp:22
VI_EXPORT ProxyWatchNode & WatchProxy(const WsfPProxyPath &aPath)
Definition ProxyWatcher.cpp:232
Copyrights Multiple, All Rights Reserved