.TH "KStaticDeleter" kde3 "11 Jun 2005" "Version Version 3.4.1" "kdecore Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
KStaticDeleter \- Little helper class to clean up static objects that are held as pointer.  

.PP
.SH SYNOPSIS
.br
.PP
\fC#include <kstaticdeleter.h>\fP
.PP
Inherits \fBKStaticDeleterBase\fP.
.PP
.SS "Public Member Functions"

.in +1c
.ti -1c
.RI "KDE_DEPRECATED type * \fBsetObject\fP (type *obj, bool isArray=false)"
.br
.ti -1c
.RI "type * \fBsetObject\fP (type *&globalRef, type *obj, bool isArray=false)"
.br
.ti -1c
.RI "virtual void \fBdestructObject\fP ()"
.br
.in -1c
.SH "Detailed Description"
.PP 

.SS "template<class type> class KStaticDeleter< type >"
Little helper class to clean up static objects that are held as pointer. 

When the library is unloaded, or the app terminated, all static deleters are destroyed, which in turn destroys those static objects properly. There are some rules which you should accept in the KStaticDeleter managed class: 
.PD 0

.IP "\(bu" 2
Don't rely on the global reference variable in the destructor of the object, it will be '0' at destruction time. 
.IP "\(bu" 2
Don't rely on other KStaticDeleter managed objects in the destructor of the object, because it may be destroyed before your destructor get called. This one can be tricky, because you might not know that you actually use a KStaticDeleter managed class. So try to keep your destructor simple.
.PP
A typical use is 
.PP
.nf
 static KStaticDeleter<MyClass> sd;

 MyClass &MyClass::self() {
   if (!_self) { sd.setObject(_self, new MyClass()); }
   return *_self;
 }

.fi
.PP
 
.PP
Definition at line 74 of file kstaticdeleter.h.
.SH "Member Function Documentation"
.PP 
.SS "template<class type> KDE_DEPRECATED type* \fBKStaticDeleter\fP< type >::setObject (type * obj, bool isArray = \fCfalse\fP)\fC [inline]\fP"
.PP
Sets the object to delete and registers the object to be deleted to \fBKGlobal\fP. 
.PP
If the given object is 0, the former registration is unregistered. 
.PP
\fBParameters:\fP
.RS 4
\fIobj\fP the object to delete 
.br
\fIisArray\fP tells the destructor to delete an array instead of an object 
.RE
.PP
\fBDeprecated\fP
.RS 4
See the other setObject variant. 
.RE
.PP

.PP
Definition at line 85 of file kstaticdeleter.h.
.PP
References KGlobal::registerStaticDeleter(), and KGlobal::unregisterStaticDeleter().
.PP
Referenced by KCmdLineArgs::init(), and KCmdLineArgs::loadAppArgs().
.SS "template<class type> type* \fBKStaticDeleter\fP< type >::setObject (type *& globalRef, type * obj, bool isArray = \fCfalse\fP)\fC [inline]\fP"
.PP
Sets the object to delete and registers the object to be deleted to \fBKGlobal\fP. 
.PP
If the given object is 0, the former registration is unregistered. 
.PP
\fBParameters:\fP
.RS 4
\fIglobalRef\fP the static pointer where this object is stored This pointer will be reset to 0 after deletion of the object. 
.br
\fIobj\fP the object to delete 
.br
\fIisArray\fP tells the destructor to delete an array instead of an object 
.RE
.PP

.PP
Definition at line 104 of file kstaticdeleter.h.
.PP
References KGlobal::registerStaticDeleter(), and KGlobal::unregisterStaticDeleter().
.SS "template<class type> virtual void \fBKStaticDeleter\fP< type >::destructObject ()\fC [inline, virtual]\fP"
.PP
Destructs the object. 
.PP
This has the same effect as deleting the KStaticDeleter. 
.PP
Reimplemented from \fBKStaticDeleterBase\fP.
.PP
Definition at line 120 of file kstaticdeleter.h.

.SH "Author"
.PP 
Generated automatically by Doxygen for kdecore Library from the source code.
