kdecore Library API Documentation

KSharedPtr< T > Struct Template Reference

Can be used to control the lifetime of an object that has derived KShared. More...

#include <ksharedptr.h>

List of all members.

Public Methods

 KSharedPtr ()
 Creates a null pointer.

 KSharedPtr (T *t)
 Creates a new pointer.

 KSharedPtr (const KSharedPtr &p)
 Copies a pointer.

 ~KSharedPtr ()
 Unreferences the object that this pointer points to.

T * data ()
 Returns the pointer.

const T * data () const
 Returns the pointer.

int count () const
 Returns the number of references.


Detailed Description

template<class T>
struct 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 perfectly. So just use it like a simple C++ pointer.

KShared and KSharedPtr are preferred over QShared / QSharedPtr since they are more safe.

Author:
Waldo Bastian <bastian@kde.org>
Version:
Id:
ksharedptr.h,v 1.20 2002/09/08 14:55:42 tjansen Exp

Definition at line 96 of file ksharedptr.h.


Constructor & Destructor Documentation

template<class T>
KSharedPtr< T >::KSharedPtr   [inline]
 

Creates a null pointer.

Definition at line 102 of file ksharedptr.h.

template<class T>
KSharedPtr< T >::KSharedPtr T *    t [inline]
 

Creates a new pointer.

Parameters:
the  pointer

Definition at line 108 of file ksharedptr.h.

template<class T>
KSharedPtr< T >::KSharedPtr const KSharedPtr< T > &    p [inline]
 

Copies a pointer.

Parameters:
the  pointer to copy

Definition at line 115 of file ksharedptr.h.

template<class T>
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 122 of file ksharedptr.h.


Member Function Documentation

template<class T>
T* KSharedPtr< T >::data   [inline]
 

Returns the pointer.

Returns:
the pointer

Definition at line 149 of file ksharedptr.h.

template<class T>
const T* KSharedPtr< T >::data   const [inline]
 

Returns the pointer.

Returns:
the pointer

Definition at line 155 of file ksharedptr.h.

template<class T>
int KSharedPtr< T >::count   const [inline]
 

Returns the number of references.

Returns:
the number of references

Definition at line 166 of file ksharedptr.h.


The documentation for this struct was generated from the following file:
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.0.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Oct 8 12:20:46 2003 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2001