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 >:

Public Methods | |
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
|
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.
Definition at line 75 of file kstaticdeleter.h. References KGlobal::registerStaticDeleter(), and KGlobal::unregisterStaticDeleter(). Referenced by KCmdLineArgs::init(), KSocks::self(), and KSocks::setConfig(). |
|
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.
Definition at line 93 of file kstaticdeleter.h. References KGlobal::registerStaticDeleter(), and KGlobal::unregisterStaticDeleter(). |
|
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: