00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Side Effects Software Inc 00008 * 123 Front Street West, Suite 1401 00009 * Toronto, Ontario 00010 * Canada M5J 2M2 00011 * 416-504-9876 00012 * 00013 * NAME: UT_IntrusivePtr.h (UT Library, C++) 00014 * 00015 * COMMENTS: A wrapper around boost::shared_ptr. 00016 * 00017 */ 00018 00019 #ifndef __UT_SHAREDPTR_H_INCLUDED__ 00020 #define __UT_SHAREDPTR_H_INCLUDED__ 00021 00022 #include <boost/shared_ptr.hpp> 00023 00024 /// @brief Wrapper around boost::shared_ptr 00025 /// 00026 /// An shared pointer takes ownership of the object referenced. The reference 00027 /// counting is done outside the object interface, so the size of a 00028 /// UT_SharedPtr is larger than a vanilla pointer. 00029 /// 00030 /// As this is a wrapper around the boost shared pointer template, the type (T) 00031 /// must have a <b>Copy Constructor</b> and a valid <b>Assignment Operator</b> 00032 /// @see UT_IntrusivePtr 00033 template<class T> 00034 class UT_SharedPtr : public boost::shared_ptr<T> 00035 { 00036 public: 00037 UT_SharedPtr(T *p = 0) : boost::shared_ptr<T>(p) { } 00038 00039 /// Convenience method to clear the pointer 00040 void clear() { *this = NULL; } 00041 00042 /// Steal and take ownership of the data passed in. 00043 void steal(T *src) { reset(src); } 00044 }; 00045 00046 #endif // __UT_SHAREDPTR_H_INCLUDED__
1.5.9