|
| SmartPtrBase () |
| e and c will become NULL More...
|
|
template<class DerivedT > |
| SmartPtrBase (DerivedT *ptData, bool bOwn=true) |
| ptData is given, reference counter is set to 1 More...
|
|
template<class DerivedT > |
| SmartPtrBase (const SmartPtrBase< DerivedT, delOp > &r) |
| Create a copy of given smart pointer with more general type. More...
|
|
| SmartPtrBase (const SmartPtrBase< T, delOp > &r) |
| Create a copy of given smart pointer. More...
|
|
template<class DerivedT > |
SmartPtrBase< T, delOp > & | operator= (const SmartPtrBase< DerivedT, delOp > &r) |
| sets the pointer to hold another reference More...
|
|
SmartPtrBase< T, delOp > & | operator= (const SmartPtrBase< T, delOp > &r) |
| explicit implmentation of the same type assignment operator More...
|
|
template<class DerivedT > |
SmartPtrBase< T, delOp > & | operator= (DerivedT *p) |
| allows for direct assignment of pointers to a SmartPtr object More...
|
|
SmartPtrBase< T, delOp > & | 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, class delOp = ArrayDelOp>
class icl::utils::SmartPtrBase< T, delOp >
Base class for reference counting smart-pointers.
General Information
The icl::SmartPtrBase class defines an abstract interface for managed pointers that use reference counting for save memory management It is not recommended to use the SmartPtrBase class itself. Most of the time, either The icl::SmartPtr or the icl::SmartArray
Important: The data of a SmartPtrBase is released using the second template class parameter delOp::delete_func. Predefined delOps are:
- PointerDelOp (using delete [])
- ArrayDelOp (using delete []) [ default ]
- FreeDelOp (using free) Take care, that shared data, which is given to a specific SmartPtrBase, is allocated using the correct allocation method (new, new[] or malloc). Use the derived classes SmartPtrBase and SmartArray in order to avoid misunderstandings
In contrast with the auto pointers provided by the stdlib an SmartPtrBase has an internal reference counter, which is used to care about the deletion of the managed data segment.
template<class T, class delOp = ArrayDelOp>
template<class DerivedT >
sets the pointer to hold another reference
If the new reference r.e is identical to the current reference, nothing is done at all. Else, the current reference counter is decreased by 1, if it becomes NULL, the hold reference is deleted. Following, the current reference and reference counter is copied from the given r. At the end, the copied reference counter is increased by 1.