HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UT_WeakPtr.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_WeakPtr.h ( UT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __UT_WeakPtr__
12 #define __UT_WeakPtr__
13 
14 #include "UT_SharedPtr.h"
15 
16 #include <hboost/weak_ptr.hpp>
17 
18 template<class T>
19 class UT_WeakPtr : public hboost::weak_ptr<T>
20 {
21  typedef hboost::weak_ptr<T> base;
22 public:
24  : hboost::weak_ptr<T>()
25  { /**/ }
26 
27  template<class U>
29  : hboost::weak_ptr<T>(static_cast<const hboost::weak_ptr<U> &>(r))
30  { /**/ }
31 
32  template<class U>
34  : hboost::weak_ptr<T>(static_cast<const hboost::shared_ptr<U> &>(r))
35  { /**/ }
36 
37  template<class U>
39  {
40  base::operator =(static_cast<const hboost::weak_ptr<U> &>(r));
41  return *this;
42  }
43 
44  template<class U>
46  {
47  base::operator =(static_cast<const hboost::shared_ptr<U> &>(r));
48  return *this;
49  }
50 
52  {
53  return static_cast<UT_SharedPtr<T> >(base::lock());
54  }
55 
57  {
58  base::swap(static_cast<hboost::weak_ptr<T> &>(r));
59  }
60 
61  using base::use_count;
62  using base::expired;
63  using base::_empty;
64  using base::reset;
65 
66  /// Convenience method to clear the pointer
67  void clear() { this->reset(); }
68 };
69 
70 #endif // __UT_WeakPtr__
void swap(UT::ArraySet< Key, MULTI, MAX_LOAD_FACTOR_256, Clearer, Hash, KeyEqual > &a, UT::ArraySet< Key, MULTI, MAX_LOAD_FACTOR_256, Clearer, Hash, KeyEqual > &b)
Definition: UT_ArraySet.h:1561
UT_SharedPtr< T > lock() const
Definition: UT_WeakPtr.h:51
Wrapper around hboost::shared_ptr.
Definition: UT_SharedPtr.h:27
UT_WeakPtr & operator=(const UT_SharedPtr< U > &r)
Definition: UT_WeakPtr.h:45
UT_WeakPtr & operator=(const UT_WeakPtr< U > &r)
Definition: UT_WeakPtr.h:38
void clear()
Convenience method to clear the pointer.
Definition: UT_WeakPtr.h:67
UT_WeakPtr(const UT_WeakPtr< U > &r)
Definition: UT_WeakPtr.h:28
void swap(UT_WeakPtr< T > &r)
Definition: UT_WeakPtr.h:56
GLboolean r
Definition: glcorearb.h:1221
#define const
Definition: zconf.h:214
UT_WeakPtr(const UT_SharedPtr< U > &r)
Definition: UT_WeakPtr.h:33