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:
32  UT_SharedArray(T *p = 0) : hboost::shared_array<T>(p) { }
33 
34  /// Convenience method to clear the pointer
35  void clear() { *this = NULL; }
36 
37  /// Steal and take ownership of the data passed in.
38  void steal(T *src) { reset(src); }
39 };
40 
41 #endif // __UT_SHAREDARRAY_H_INCLUDED__
UT_SharedPtr< T > UTmakeSharedArrayPtr(size_t len)
Definition: UT_SharedPtr.h:57
void steal(T *src)
Steal and take ownership of the data passed in.
#define SYS_DEPRECATED_REPLACE(__V__, __R__)
GLboolean reset
Definition: glad.h:5138
A shared ptr for encapsulating dynamically allocated arrays.
void clear()
Convenience method to clear the pointer.
GLenum src
Definition: glcorearb.h:1793