|
| SmartPtr () |
| creates a null pointer More...
|
|
template<class DerivedT > |
| SmartPtr (DerivedT *ptData, bool bOwn=true) |
| gets pointer, ownership is passed optionally More...
|
|
| SmartPtr (T *ptData, bool bOwn=true) |
| gets pointer, ownership is passed optionally More...
|
|
template<class DerivedT > |
| SmartPtr (const SmartPtrBase< DerivedT, PointerDelOp > &r) |
| reference counting copy constructor More...
|
|
| SmartPtr (const SmartPtrBase< T, PointerDelOp > &r) |
| reference counting copy constructor More...
|
|
| SmartPtrBase () |
| e and c will become NULL More...
|
|
| SmartPtrBase (DerivedT *ptData, bool bOwn=true) |
| ptData is given, reference counter is set to 1 More...
|
|
| SmartPtrBase (const SmartPtrBase< DerivedT, PointerDelOp > &r) |
| Create a copy of given smart pointer with more general type. More...
|
|
| SmartPtrBase (const SmartPtrBase< T, PointerDelOp > &r) |
| Create a copy of given smart pointer. More...
|
|
SmartPtrBase< T, PointerDelOp > & | operator= (const SmartPtrBase< DerivedT, PointerDelOp > &r) |
| sets the pointer to hold another reference More...
|
|
SmartPtrBase< T, PointerDelOp > & | operator= (const SmartPtrBase< T, PointerDelOp > &r) |
| explicit implmentation of the same type assignment operator More...
|
|
SmartPtrBase< T, PointerDelOp > & | operator= (DerivedT *p) |
| allows for direct assignment of pointers to a SmartPtr object More...
|
|
SmartPtrBase< T, PointerDelOp > & | operator= (T *p) |
| allows for direct assignment of pointers to a SmartPtr object More...
|
|
virtual | ~SmartPtrBase () |
| decreases the reference counter (cleanup on demand) More...
|
|
T & | operator * () |
| returns a reference of the currently hold element More...
|
|
const T & | operator * () const |
| returns a reference of the currently hold element (const) More...
|
|
T * | get () |
| returns the pointer to the data More...
|
|
const T * | get () const |
| returns the pointer to the data (const) More...
|
|
T * | operator-> () |
| returns the currently hold element More...
|
|
const T * | operator-> () const |
| returns the currently hold element (const) More...
|
|
| operator bool () const |
| this may be used to check if * or -> operator may be used More...
|
|
int | use_count () const |
| current reference count More...
|
|
void | setNull () |
| sets the smart pointer to null More...
|
|
template<class T>
struct icl::utils::SmartPtr< T >
Specialization of the SmartPtrBase class for Pointers.
If the internal reference counter becomes 0, the contained data pointer is release using delete
Example (Image Convolution)
class MyClass{...};
typedef SmartPtr<MyClass> MyClassPtr;
//create an array of empty auto pointers
MyClassPtr ps[100];
// fill the first element of the array with one reference
// of type MyClass*
ps[0] = new MyClass;
// fill the other elements of the array with the
// SAME reference
std::fill(ps+1,ps+100,ps[0])
// reference counter is 100 now
// delete all except the last one
for(int i=0;i<99;i++){
array[i].setNull();
}
// now the reference counter of array[99] is 1, if it
// is deleted, the hold element is deleted as well
array[99].setNull();