VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtSharedPtrCallbackWrapper.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2024 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 //#include <vrvUtil/vrvUtil.h>
13 #include <memory>
14 #include <cassert>
15 
16 namespace makVrv
17 {
18  template <typename T>
20  {
21  public:
22  explicit DtSharedPtrCallbackWrapper(const std::shared_ptr<T>& obj)
23  : myObj(obj)
24  {
25  assert(obj);
26  }
27 
28  explicit DtSharedPtrCallbackWrapper(T* obj)
29  : myObj(std::shared_ptr<T>(obj))
30  {
31  assert(obj);
32  }
33 
34  template <typename P1>
35  void operator()(const P1& p1) const
36  {
37  std::shared_ptr<T> obj = myObj.lock();
38 
39  if (obj)
40  {
41  (*obj)(p1);
42  }
43  }
44 
45  template <typename P1, typename P2>
46  void operator()(const P1& p1, const P2& p2) const
47  {
48  std::shared_ptr<T> obj = myObj.lock();
49 
50  if (obj)
51  {
52  (*obj)(p1, p2);
53  }
54  }
55 
56  template <typename P1, typename P2, typename P3>
57  void operator()(const P1& p1, const P2& p2, const P3& p3) const
58  {
59  std::shared_ptr<T> obj = myObj.lock();
60 
61  if (obj)
62  {
63  (*obj)(p1, p2, p3);
64  }
65  }
66 
67  private:
68  const std::weak_ptr<T> myObj;
69  };
70 }
const std::weak_ptr< T > myObj
Definition: DtSharedPtrCallbackWrapper.h:68
DtSharedPtrCallbackWrapper(T *obj)
Definition: DtSharedPtrCallbackWrapper.h:28
Definition: DtSharedPtrCallbackWrapper.h:19
DtSharedPtrCallbackWrapper(const std::shared_ptr< T > &obj)
Definition: DtSharedPtrCallbackWrapper.h:22
void operator()(const P1 &p1) const
Definition: DtSharedPtrCallbackWrapper.h:35
void operator()(const P1 &p1, const P2 &p2) const
Definition: DtSharedPtrCallbackWrapper.h:46
void operator()(const P1 &p1, const P2 &p2, const P3 &p3) const
Definition: DtSharedPtrCallbackWrapper.h:57

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)