• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kdecore
 

kdecore

Public Member Functions | List of all members
KSharedPtr< T > Class Template Reference

#include <ksharedptr.h>

Public Member Functions

 KSharedPtr ()
 
 KSharedPtr (T *t)
 
 KSharedPtr (const KSharedPtr &p)
 
 ~KSharedPtr ()
 
KSharedPtr< T > & operator= (const KSharedPtr< T > &p)
 
KSharedPtr< T > & operator= (T *p)
 
bool operator== (const KSharedPtr< T > &p) const
 
bool operator!= (const KSharedPtr< T > &p) const
 
bool operator== (const T *p) const
 
bool operator!= (const T *p) const
 
bool operator! () const
 
 operator T* () const
 
T * data ()
 
const T * data () const
 
const T & operator* () const
 
T & operator* ()
 
const T * operator-> () const
 
T * operator-> ()
 
int count () const
 

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.

Author
Waldo Bastian basti.nosp@m.an@k.nosp@m.de.or.nosp@m.g

Definition at line 100 of file ksharedptr.h.

Constructor & Destructor Documentation

◆ KSharedPtr() [1/3]

template<class T >
KSharedPtr< T >::KSharedPtr ( )
inline

Creates a null pointer.

Definition at line 106 of file ksharedptr.h.

◆ KSharedPtr() [2/3]

template<class T >
KSharedPtr< T >::KSharedPtr ( T *  t)
inline

Creates a new pointer.

Parameters
tthe pointer

Definition at line 112 of file ksharedptr.h.

◆ KSharedPtr() [3/3]

template<class T >
KSharedPtr< T >::KSharedPtr ( const KSharedPtr< T > &  p)
inline

Copies a pointer.

Parameters
pthe pointer to copy

Definition at line 119 of file ksharedptr.h.

◆ ~KSharedPtr()

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 126 of file ksharedptr.h.

Member Function Documentation

◆ count()

template<class T >
int KSharedPtr< T >::count ( ) const
inline

Returns the number of references.

Returns
the number of references

Definition at line 170 of file ksharedptr.h.

◆ data() [1/2]

template<class T >
T* KSharedPtr< T >::data ( )
inline

Returns the pointer.

Returns
the pointer

Definition at line 153 of file ksharedptr.h.

◆ data() [2/2]

template<class T >
const T* KSharedPtr< T >::data ( ) const
inline

Returns the pointer.

Returns
the pointer

Definition at line 159 of file ksharedptr.h.


The documentation for this class was generated from the following file:
  • ksharedptr.h

kdecore

Skip menu "kdecore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdecore

Skip menu "kdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kdecore by doxygen 1.9.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |