KDECore
KSharedPtr< T > Class Template Reference
Can be used to control the lifetime of an object that has derived KShared. More...
#include <ksharedptr.h>

Public Member Functions | |
| int | count () const |
| const T * | data () const |
| T * | data () |
| KSharedPtr (const KSharedPtr &p) | |
| KSharedPtr (T *t) | |
| KSharedPtr () | |
| operator T * () const | |
| bool | operator! () const |
| bool | operator!= (const T *p) const |
| bool | operator!= (const KSharedPtr< T > &p) const |
| T & | operator* () |
| const T & | operator* () const |
| T * | operator-> () |
| const T * | operator-> () const |
| KSharedPtr< T > & | operator= (T *p) |
| KSharedPtr< T > & | operator= (const KSharedPtr< T > &p) |
| bool | operator== (const T *p) const |
| bool | operator== (const KSharedPtr< T > &p) const |
| ~KSharedPtr () | |
Detailed Description
template<class T>
class KSharedPtr< T >
Can be used to control the lifetime of an object that has derived KShared.
As long a someone holds a KSharedPtr on some KShared object it won't become deleted but is deleted once its reference count is 0. This struct emulates C++ pointers virtually perfectly. So just use it like a simple C++ pointer.
KShared and KSharedPtr are preferred over QShared / QSharedPtr since they are more safe.
WARNING: Please note that this class template provides an implicit conversion to T*. Do *not* change this pointer or the pointee (don't call delete on it, for instance) behind KSharedPtr's back.
Definition at line 100 of file ksharedptr.h.
Constructor & Destructor Documentation
| KSharedPtr< T >::KSharedPtr | ( | ) | [inline] |
| KSharedPtr< T >::KSharedPtr | ( | T * | t | ) | [inline] |
| KSharedPtr< T >::KSharedPtr | ( | const KSharedPtr< T > & | p | ) | [inline] |
| KSharedPtr< T >::~KSharedPtr | ( | ) | [inline] |
Unreferences the object that this pointer points to.
If it was the last reference, the object will be deleted.
Definition at line 126 of file ksharedptr.h.
Member Function Documentation
| int KSharedPtr< T >::count | ( | ) | const [inline] |
Returns the number of references.
- Returns:
- the number of references
Definition at line 170 of file ksharedptr.h.
| const T* KSharedPtr< T >::data | ( | ) | const [inline] |
| T* KSharedPtr< T >::data | ( | ) | [inline] |
| KSharedPtr< T >::operator T * | ( | ) | const [inline] |
Definition at line 147 of file ksharedptr.h.
| bool KSharedPtr< T >::operator! | ( | ) | const [inline] |
Definition at line 146 of file ksharedptr.h.
| bool KSharedPtr< T >::operator!= | ( | const T * | p | ) | const [inline] |
Definition at line 145 of file ksharedptr.h.
| bool KSharedPtr< T >::operator!= | ( | const KSharedPtr< T > & | p | ) | const [inline] |
Definition at line 143 of file ksharedptr.h.
| T& KSharedPtr< T >::operator* | ( | ) | [inline] |
Definition at line 162 of file ksharedptr.h.
| const T& KSharedPtr< T >::operator* | ( | ) | const [inline] |
Definition at line 161 of file ksharedptr.h.
| T* KSharedPtr< T >::operator-> | ( | ) | [inline] |
Definition at line 164 of file ksharedptr.h.
| const T* KSharedPtr< T >::operator-> | ( | ) | const [inline] |
Definition at line 163 of file ksharedptr.h.
| KSharedPtr<T>& KSharedPtr< T >::operator= | ( | T * | p | ) | [inline] |
Definition at line 135 of file ksharedptr.h.
| KSharedPtr<T>& KSharedPtr< T >::operator= | ( | const KSharedPtr< T > & | p | ) | [inline] |
Definition at line 128 of file ksharedptr.h.
| bool KSharedPtr< T >::operator== | ( | const T * | p | ) | const [inline] |
Definition at line 144 of file ksharedptr.h.
| bool KSharedPtr< T >::operator== | ( | const KSharedPtr< T > & | p | ) | const [inline] |
Definition at line 142 of file ksharedptr.h.
The documentation for this class was generated from the following file:
KDE 3.5 API Reference