Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Types | Public Member Functions
icl::utils::SmartPtr< T > Struct Template Reference

Specialization of the SmartPtrBase class for Pointers. More...

#include <SmartPtr.h>

Inheritance diagram for icl::utils::SmartPtr< T >:
icl::utils::SmartPtrBase< T, PointerDelOp >

List of all members.

Public Types

typedef SmartPtrBase< T,
PointerDelOp
super

Public Member Functions

 SmartPtr ()
 creates a null pointer
template<class DerivedT >
 SmartPtr (DerivedT *ptData, bool bOwn=true)
 gets pointer, ownership is passed optionally
 SmartPtr (T *ptData, bool bOwn=true)
 gets pointer, ownership is passed optionally
template<class DerivedT >
 SmartPtr (const SmartPtrBase< DerivedT, PointerDelOp > &r)
 reference counting copy constructor
 SmartPtr (const SmartPtrBase< T, PointerDelOp > &r)
 reference counting copy constructor

Detailed Description

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

        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();
        

Member Typedef Documentation

template<class T>
typedef SmartPtrBase<T,PointerDelOp> icl::utils::SmartPtr< T >::super

Constructor & Destructor Documentation

template<class T>
icl::utils::SmartPtr< T >::SmartPtr ( ) [inline]

creates a null pointer

template<class T>
template<class DerivedT >
icl::utils::SmartPtr< T >::SmartPtr ( DerivedT *  ptData,
bool  bOwn = true 
) [inline]

gets pointer, ownership is passed optionally

template<class T>
icl::utils::SmartPtr< T >::SmartPtr ( T *  ptData,
bool  bOwn = true 
) [inline]

gets pointer, ownership is passed optionally

template<class T>
template<class DerivedT >
icl::utils::SmartPtr< T >::SmartPtr ( const SmartPtrBase< DerivedT, PointerDelOp > &  r) [inline]

reference counting copy constructor

template<class T>
icl::utils::SmartPtr< T >::SmartPtr ( const SmartPtrBase< T, PointerDelOp > &  r) [inline]

reference counting copy constructor


The documentation for this struct was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines