\section{KStatic\-Deleter$<$ type $>$ Class Template Reference}
\label{classKStaticDeleter}\index{KStaticDeleter@{KStaticDeleter}}
Little helper class to clean up static objects that are held as pointer.  


{\tt \#include $<$kstaticdeleter.h$>$}

Inheritance diagram for KStatic\-Deleter$<$ type $>$:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=76pt]{classKStaticDeleter__inherit__graph}
\end{center}
\end{figure}
Collaboration diagram for KStatic\-Deleter$<$ type $>$:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=76pt]{classKStaticDeleter__coll__graph}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
KDE\_\-DEPRECATED type $\ast$ {\bf set\-Object} (type $\ast$obj, bool is\-Array=false)
\item 
type $\ast$ {\bf set\-Object} (type $\ast$\&global\-Ref, type $\ast$obj, bool is\-Array=false)
\item 
virtual void {\bf destruct\-Object} ()
\end{CompactItemize}


\subsection{Detailed Description}
\subsubsection*{template$<$class type$>$ class KStatic\-Deleter$<$ 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 KStatic\-Deleter managed class: \begin{itemize}
\item Don't rely on the global reference variable in the destructor of the object, it will be '0' at destruction time. \item Don't rely on other KStatic\-Deleter 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 KStatic\-Deleter managed class. So try to keep your destructor simple.\end{itemize}
A typical use is 

\footnotesize\begin{verbatim} static KStaticDeleter<MyClass> sd;

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



Definition at line 74 of file kstaticdeleter.h.

\subsection{Member Function Documentation}
\index{KStaticDeleter@{KStatic\-Deleter}!setObject@{setObject}}
\index{setObject@{setObject}!KStaticDeleter@{KStatic\-Deleter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}template$<$class type$>$ KDE\_\-DEPRECATED type$\ast$ {\bf KStatic\-Deleter}$<$ type $>$::set\-Object (type $\ast$ {\em obj}, bool {\em is\-Array} = {\tt false})\hspace{0.3cm}{\tt  [inline]}}\label{classKStaticDeleter_a1}


Sets the object to delete and registers the object to be deleted to {\bf KGlobal}{\rm (p.\,\pageref{classKGlobal})}. 

If the given object is 0, the former registration is unregistered. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em obj}]the object to delete \item[{\em is\-Array}]tells the destructor to delete an array instead of an object \end{description}
\end{Desc}
\begin{Desc}
\item[{\bf Deprecated}]See the other set\-Object variant. \end{Desc}


Definition at line 85 of file kstaticdeleter.h.

References KGlobal::register\-Static\-Deleter(), and KGlobal::unregister\-Static\-Deleter().

Referenced by KCmd\-Line\-Args::init(), and KCmd\-Line\-Args::load\-App\-Args().\index{KStaticDeleter@{KStatic\-Deleter}!setObject@{setObject}}
\index{setObject@{setObject}!KStaticDeleter@{KStatic\-Deleter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}template$<$class type$>$ type$\ast$ {\bf KStatic\-Deleter}$<$ type $>$::set\-Object (type $\ast$\& {\em global\-Ref}, type $\ast$ {\em obj}, bool {\em is\-Array} = {\tt false})\hspace{0.3cm}{\tt  [inline]}}\label{classKStaticDeleter_a2}


Sets the object to delete and registers the object to be deleted to {\bf KGlobal}{\rm (p.\,\pageref{classKGlobal})}. 

If the given object is 0, the former registration is unregistered. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em global\-Ref}]the static pointer where this object is stored This pointer will be reset to 0 after deletion of the object. \item[{\em obj}]the object to delete \item[{\em is\-Array}]tells the destructor to delete an array instead of an object \end{description}
\end{Desc}


Definition at line 104 of file kstaticdeleter.h.

References KGlobal::register\-Static\-Deleter(), and KGlobal::unregister\-Static\-Deleter().\index{KStaticDeleter@{KStatic\-Deleter}!destructObject@{destructObject}}
\index{destructObject@{destructObject}!KStaticDeleter@{KStatic\-Deleter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}template$<$class type$>$ virtual void {\bf KStatic\-Deleter}$<$ type $>$::destruct\-Object ()\hspace{0.3cm}{\tt  [inline, virtual]}}\label{classKStaticDeleter_a3}


Destructs the object. 

This has the same effect as deleting the KStatic\-Deleter. 

Reimplemented from {\bf KStatic\-Deleter\-Base} {\rm (p.\,\pageref{classKStaticDeleterBase_a1})}.

Definition at line 120 of file kstaticdeleter.h.

The documentation for this class was generated from the following file:\begin{CompactItemize}
\item 
kstaticdeleter.h\end{CompactItemize}
