KDE3Support
#include <k3staticdeleter.h>
Public Member Functions | |
K3StaticDeleter () | |
virtual | ~K3StaticDeleter () |
virtual void | destructObject () |
type * | setObject (type *obj, bool isArray=false) |
type * | setObject (type *&globalRef, type *obj, bool isArray=false) |
Public Member Functions inherited from K3StaticDeleterBase | |
virtual | ~K3StaticDeleterBase () |
Detailed Description
template<class type>
class K3StaticDeleter< type >
Automatically deletes an object on termination.
Little helper class to clean up static objects that are held as a pointer.
Static deleters are used to manage static resources. They can register themselves with K3StaticDeleterHelpers. K3StaticDeleterHelpers will call destructObject() when K3StaticDeleterHelpers::deleteStaticDeleters() is called or when the process finishes.
When the library is unloaded, or the app is terminated, all static deleters will be destroyed, which in turn destroys those static objects properly. There are some rules that you should accept in the K3StaticDeleter managed class:
- Don't rely on the global reference variable in the destructor of the object, it will be '0' at destruction time.
- Don't rely on other K3StaticDeleter managed objects in the destructor of the object, because they may be destroyed before your destructor get called. This one can be tricky, because you might not know that you are actually using a K3StaticDeleter managed class. So try to keep your destructor simple.
A typical use is
- Warning
- Don't delete an object which is managed by K3StaticDeleter without calling setObject() with a null pointer.
- Deprecated:
- Use K_GLOBAL_STATIC instead of K3StaticDeleter.
Definition at line 115 of file k3staticdeleter.h.
Constructor & Destructor Documentation
|
inline |
Constructor.
Initializes the K3StaticDeleter. Note that the static deleter is not registered by the constructor.
Definition at line 121 of file k3staticdeleter.h.
|
inlinevirtual |
Destructor.
Unregisters the static deleter and destroys the registered object by calling destructObject().
Definition at line 182 of file k3staticdeleter.h.
Member Function Documentation
|
inlinevirtual |
Destructs the registered object.
This has the same effect as deleting the K3StaticDeleter.
Reimplemented from K3StaticDeleterBase.
Definition at line 168 of file k3staticdeleter.h.
|
inline |
Sets the object to delete and registers that object to K3StaticDeleterHelpers.
If the given object is 0, the formerly registered object is unregistered.
- Parameters
-
obj the object to delete isArray tells the destructor to delete an array instead of an object
- Deprecated:
- See the other setObject variant.
Definition at line 131 of file k3staticdeleter.h.
|
inline |
Sets the object to delete and registers the object to be deleted to K3StaticDeleterHelpers.
If the given object is 0, the previously registered object is unregistered.
- Parameters
-
globalRef the static pointer where this object is stored. This pointer will be reset to 0 after deletion of the object. obj the object to delete isArray tells the destructor to delete an array instead of an object
- Returns
- the object to delete,
obj
Definition at line 152 of file k3staticdeleter.h.
The documentation for this class was generated from the following file:
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:51:59 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.