VR-Forces 4.8 Class Documentation
 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) 2016 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 //#include <vrvUtil/vrvUtil.h>
13 
14 #include <boost/shared_ptr.hpp>
15 #include <boost/weak_ptr.hpp>
16 
17 namespace makVrv
18 {
19  template <typename T>
21  {
22  public:
23  explicit DtSharedPtrCallbackWrapper(const boost::shared_ptr<T>& obj)
24  : myObj(obj)
25  {
26  assert(obj);
27  }
28 
29  explicit DtSharedPtrCallbackWrapper(T* obj)
30  : myObj(boost::shared_ptr<T>(obj))
31  {
32  assert(obj);
33  }
34 
35  template <typename P1>
36  void operator()(const P1& p1) const
37  {
38  boost::shared_ptr<T> obj = myObj.lock();
39 
40  if (obj)
41  {
42  (*obj)(p1);
43  }
44  }
45 
46  template <typename P1, typename P2>
47  void operator()(const P1& p1, const P2& p2) const
48  {
49  boost::shared_ptr<T> obj = myObj.lock();
50 
51  if (obj)
52  {
53  (*obj)(p1, p2);
54  }
55  }
56 
57  template <typename P1, typename P2, typename P3>
58  void operator()(const P1& p1, const P2& p2, const P3& p3) const
59  {
60  boost::shared_ptr<T> obj = myObj.lock();
61 
62  if (obj)
63  {
64  (*obj)(p1, p2, p3);
65  }
66  }
67 
68  private:
69  const boost::weak_ptr<T> myObj;
70  };
71 }
DtSharedPtrCallbackWrapper(T *obj)
Definition: DtSharedPtrCallbackWrapper.h:29
Definition: DtSharedPtrCallbackWrapper.h:20
DtSharedPtrCallbackWrapper(const boost::shared_ptr< T > &obj)
Definition: DtSharedPtrCallbackWrapper.h:23
void operator()(const P1 &p1) const
Definition: DtSharedPtrCallbackWrapper.h:36
void operator()(const P1 &p1, const P2 &p2) const
Definition: DtSharedPtrCallbackWrapper.h:47
void operator()(const P1 &p1, const P2 &p2, const P3 &p3) const
Definition: DtSharedPtrCallbackWrapper.h:58
const boost::weak_ptr< T > myObj
Definition: DtSharedPtrCallbackWrapper.h:69

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)