• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdecore
 

tdecore

Public Member Functions | List of all members
KStaticDeleter< type > Class Template Reference

#include <kstaticdeleter.h>

Inheritance diagram for KStaticDeleter< type >:
KStaticDeleterBase

Public Member Functions

TDE_DEPRECATED type * setObject (type *obj, bool isArray=false)
 
type * setObject (type *&globalRef, type *obj, bool isArray=false)
 
virtual void destructObject ()
 
virtual void destructObject ()
 

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. There are some rules which you should accept in the KStaticDeleter 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 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.

A typical use is

static KStaticDeleter<MyClass> sd;
MyClass &MyClass::self() {
if (!_self) { sd.setObject(_self, new MyClass()); }
return *_self;
}
KStaticDeleter
Little helper class to clean up static objects that are held as pointer.
Definition: kstaticdeleter.h:74
KStaticDeleter::setObject
TDE_DEPRECATED type * setObject(type *obj, bool isArray=false)
Sets the object to delete and registers the object to be deleted to TDEGlobal.
Definition: kstaticdeleter.h:85

Definition at line 74 of file kstaticdeleter.h.

Constructor & Destructor Documentation

◆ KStaticDeleter()

template<class type >
KStaticDeleter< type >::KStaticDeleter ( )
inline

Definition at line 76 of file kstaticdeleter.h.

◆ ~KStaticDeleter()

template<class type >
virtual KStaticDeleter< type >::~KStaticDeleter ( )
inlinevirtual

Definition at line 129 of file kstaticdeleter.h.

Member Function Documentation

◆ destructObject()

template<class type >
virtual void KStaticDeleter< type >::destructObject ( )
inlinevirtual

Destructs the object.

This has the same effect as deleting the KStaticDeleter.

Reimplemented from KStaticDeleterBase.

Definition at line 120 of file kstaticdeleter.h.

◆ setObject() [1/2]

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

If the given object is 0, the former registration is unregistered.

Parameters
globalRefthe static pointer where this object is stored This pointer will be reset to 0 after deletion of the object.
objthe object to delete
isArraytells the destructor to delete an array instead of an object

Definition at line 104 of file kstaticdeleter.h.

◆ setObject() [2/2]

template<class type >
TDE_DEPRECATED type * KStaticDeleter< type >::setObject ( type *  obj,
bool  isArray = false 
)
inline

Sets the object to delete and registers the object to be deleted to TDEGlobal.

If the given object is 0, the former registration is unregistered.

Parameters
objthe object to delete
isArraytells the destructor to delete an array instead of an object
Deprecated:
See the other setObject variant.

Definition at line 85 of file kstaticdeleter.h.


The documentation for this class was generated from the following file:
  • kstaticdeleter.h

tdecore

Skip menu "tdecore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.9.4
This website is maintained by Timothy Pearson.