HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_SharedArray.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_SharedArray.h (UT Library, C++)
7  *
8  * COMMENTS: A shared ptr for encapsulating dynamically allocated arrays
9  *
10  */
11 
12 #ifndef __UT_SHAREDARRAY_H_INCLUDED__
13 #define __UT_SHAREDARRAY_H_INCLUDED__
14 
15 #include <hboost/shared_array.hpp>
16 #include <stddef.h>
17 
18 /// @brief A shared ptr for encapsulating dynamically allocated arrays
19 ///
20 /// An shared array takes ownership of the object referenced. The reference
21 /// counting is done outside the object interface, so the size of a
22 /// UT_SharedArray is larger than a vanilla pointer.
23 ///
24 /// As this is a wrapper around the boost hboost::shared_array template, the
25 /// type (T) must have a <b>Copy Constructor</b> and a valid <b>Assignment
26 /// Operator</b> @see UT_IntrusivePtr
27 template<class T>
28 class UT_SharedArray : public hboost::shared_array<T>
29 {
30 public:
31  UT_SharedArray(T *p = 0) : hboost::shared_array<T>(p) { }
32 
33  /// Convenience method to clear the pointer
34  void clear() { *this = NULL; }
35 
36  /// Steal and take ownership of the data passed in.
37  void steal(T *src) { reset(src); }
38 };
39 
40 #endif // __UT_SHAREDARRAY_H_INCLUDED__
void steal(T *src)
Steal and take ownership of the data passed in.
A shared ptr for encapsulating dynamically allocated arrays.
void clear()
Convenience method to clear the pointer.
UT_SharedArray(T *p=0)
GLenum src
Definition: glcorearb.h:1792