HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UT_SharedPtr.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_SharedPtr.h (UT Library, C++)
7  *
8  * COMMENTS: A wrapper around hboost::shared_ptr.
9  *
10  */
11 
12 #ifndef __UT_SHAREDPTR_H_INCLUDED__
13 #define __UT_SHAREDPTR_H_INCLUDED__
14 
15 #include <hboost/shared_ptr.hpp>
16 
17 /// @brief Wrapper around hboost::shared_ptr
18 ///
19 /// An shared pointer takes ownership of the object referenced. The reference
20 /// counting is done outside the object interface, so the size of a
21 /// UT_SharedPtr is larger than a vanilla pointer.
22 ///
23 /// As this is a wrapper around the boost shared pointer template, the type (T)
24 /// must have a <b>Copy Constructor</b> and a valid <b>Assignment Operator</b>
25 /// @see UT_IntrusivePtr
26 template<class T>
27 class UT_SharedPtr : public hboost::shared_ptr<T>
28 {
29 public:
30  UT_SharedPtr() : hboost::shared_ptr<T>() { }
31 
32  // Unlike boost, we define this constructor as non-explicit. It's probably
33  // safer to make it explicit but there's a bunch of code to change.
34  template<class Y>
35  UT_SharedPtr(Y *p) : hboost::shared_ptr<T>(p) { }
36 
37  template<class Y>
38  UT_SharedPtr( UT_SharedPtr<Y> const & r ) : hboost::shared_ptr<T>(r) {}
39 
40  UT_SharedPtr(hboost::shared_ptr<T> const &r) : hboost::shared_ptr<T>(r) { }
41 
42  /// UT_SharedPtr will release p by calling d(p)
43  /// Requirements: D's copy constructor must not throw
44  template<class Y, class D>
45  UT_SharedPtr(Y * p, D d) : hboost::shared_ptr<T>(p, d) {}
46 
47  /// Convenience method to clear the pointer
48  void clear() { this->reset(); }
49 
50  /// Steal and take ownership of the data passed in.
51  void steal(T *src) { this->reset(src); }
52 };
53 
54 #endif // __UT_SHAREDPTR_H_INCLUDED__
UT_SharedPtr(hboost::shared_ptr< T > const &r)
Definition: UT_SharedPtr.h:40
UT_SharedPtr(UT_SharedPtr< Y > const &r)
Definition: UT_SharedPtr.h:38
Wrapper around hboost::shared_ptr.
Definition: UT_SharedPtr.h:27
UT_SharedPtr(Y *p)
Definition: UT_SharedPtr.h:35
void clear()
Convenience method to clear the pointer.
Definition: UT_SharedPtr.h:48
void steal(T *src)
Steal and take ownership of the data passed in.
Definition: UT_SharedPtr.h:51
GLboolean r
Definition: glcorearb.h:1221
UT_SharedPtr(Y *p, D d)
Definition: UT_SharedPtr.h:45
GLenum src
Definition: glcorearb.h:1792