TemplateKStaticDeleter< type > class Reference (kdecore Library)

| # kdecore Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# KStaticDeleter< type > Class Template Reference

Little helper class to clean up static objects that are held as pointer. More...

`#include <kstaticdeleter.h>`

Inheritance diagram for KStaticDeleter< type >:

[legend]
Collaboration diagram for KStaticDeleter< type >:

[legend]
List of all members.

## Public Member Functions
type * | setObject (type *obj, bool isArray=false)
| Sets the object to delete and registers the object to be deleted to KGlobal.
type * | setObject (type *&globalRef, type *obj, bool isArray=false)
| Sets the object to delete and registers the object to be deleted to KGlobal.
virtual void | destructObject ()
| Destructs the object.

## Detailed Description

### 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.

A typical use is

     static KStaticDeleter<MyClass> sd;

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

Definition at line 65 of file kstaticdeleter.h.

## Member Function Documentation

template<class type>
type* KStaticDeleter< type >::setObject | ( | type * | obj,
|  | bool | isArray = false
| ) | `[inline]`

  | Sets the object to delete and registers the object to be deleted to KGlobal. If the given object is 0, the former registration is unregistered. Parameters:
  isArray | tells the destructor to delete an array instead of an object This class or method is obsolete, it is provided for compatibility only. See the other setObject variant.
Definition at line 75 of file kstaticdeleter.h. References KGlobal::registerStaticDeleter(), and KGlobal::unregisterStaticDeleter().

template<class type>
type* KStaticDeleter< type >::setObject | ( | type *& | globalRef,
|  | type * | obj,
|  | bool | isArray = false
| ) | `[inline]`

  | Sets the object to delete and registers the object to be deleted to KGlobal. If the given object is 0, the former registration is unregistered. Parameters:
  globalRef | the static pointer where this object is stored This pointer will be reset to 0 after deletion of the object.
  isArray | tells the destructor to delete an array instead of an object
Definition at line 93 of file kstaticdeleter.h. References KGlobal::registerStaticDeleter(), and KGlobal::unregisterStaticDeleter().

template<class type>
virtual void KStaticDeleter< type >::destructObject | ( |  | ) | `[inline, virtual]`

| Destructs the object. This has the same effect as deleting the KStaticDeleter. Reimplemented from KStaticDeleterBase. Definition at line 109 of file kstaticdeleter.h.

The documentation for this class was generated from the following file:

- kstaticdeleter.h

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 12:51:42 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001