VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtProxy.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2024 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
8 
9 #ifndef DtProxy_H_
10 #define DtProxy_H_
11 
12 #include <vrvUtil/vrvUtil.h>
13 #include <vlutil/vlSmartPointers.h>
14 #include <vlutil/vlExceptions.h>
15 
16 #include <map>
17 #include <memory>
18 
19 namespace makVrv
20 {
21  class DtMessage;
22 
40  {
41  public:
42 
44  DtProxy();
45 
47  virtual void makeInvalid();
48 
52  inline bool isValid() const
53  {
54  return myValidFlag;
55  }
56 
61  inline void validate() const
62  {
63  if(!isValid())
64  {
65  DtTHROW_NEW(DtCorruptedState, "Interface is invalid.");
66  }
67  }
68 
69  protected:
70 
72  };
73 
74  typedef std::weak_ptr<DtProxy> DtProxyWP;
75  typedef std::shared_ptr<DtProxy> DtProxySP;
76 
80  template <typename K, typename V>
81  std::shared_ptr<V> DtFindProxyByName(std::map<K, std::weak_ptr<V> >& map, const std::string& name)
82  {
83  typedef std::weak_ptr<V> VWP;
84  typedef std::shared_ptr<V> VSP;
85 
86  typename std::map<K, std::weak_ptr<V> >::iterator iter = map.find(name);
87  if(iter != map.end())
88  {
89  VSP proctor = iter->second.lock();
90  if(proctor)
91  {
92  return proctor;
93  }
94  }
95  return VSP();
96  }
97 
98 }
99 
100 #endif
bool myValidFlag
Definition: DtProxy.h:71
#define DT_DLL_VRVUTIL
Definition: vrvUtil.h:34
std::shared_ptr< V > DtFindProxyByName(std::map< K, std::weak_ptr< V > > &map, const std::string &name)
Utility function to look up a proxy object by name in a map of weak pointers. Typically used in the #...
Definition: DtProxy.h:81
void validate() const
Check to see if the proxy is valid. This function must be called at the beginning of any public funct...
Definition: DtProxy.h:61
bool isValid() const
Return the valid state of the proxy.
Definition: DtProxy.h:52
Contains DLL export macros.
std::weak_ptr< DtProxy > DtProxyWP
Definition: DtProxy.h:74
The Proxy base class. Proxies are objects that let users interact with objects that may or may not ex...
Definition: DtProxy.h:39
std::shared_ptr< DtProxy > DtProxySP
Definition: DtProxy.h:75

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)