• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDE3Support

k3staticdeleter.h

Go to the documentation of this file.
00001 /*
00002  * This file is part of the KDE Libraries
00003  * Copyright (C) 2000 Stephan Kulow <coolo@kde.org>
00004  *               2001 KDE Team
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Library General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Library General Public License
00017  * along with this library; see the file COPYING.LIB.  If not, write to
00018  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef _KSTATIC_DELETER_H_
00024 #define _KSTATIC_DELETER_H_
00025 
00026 #include <kde3support_export.h>
00027 
00028 class K3StaticDeleterBase;
00029 
00030 namespace K3StaticDeleterHelpers
00031 {
00038     KDE3SUPPORT_EXPORT void registerStaticDeleter(K3StaticDeleterBase *d);
00039 
00046     KDE3SUPPORT_EXPORT void unregisterStaticDeleter(K3StaticDeleterBase *d);
00047 
00054     KDE3SUPPORT_EXPORT void deleteStaticDeleters();
00055 } // namespace K3StaticDeleterHelpers
00056 
00068 class KDE3SUPPORT_EXPORT K3StaticDeleterBase {
00069 public:
00070     virtual ~K3StaticDeleterBase();
00076     virtual void destructObject();
00077 };
00078 
00115 template<class type> class KDE_DEPRECATED K3StaticDeleter : public K3StaticDeleterBase {
00116 public:
00121     K3StaticDeleter() { deleteit = 0; globalReference = 0; array = false; }
00122 
00131     KDE_DEPRECATED type *setObject( type *obj, bool isArray = false) {
00132         deleteit = obj;
00133         globalReference = 0;
00134         array = isArray;
00135         if (obj)
00136             K3StaticDeleterHelpers::registerStaticDeleter(this);
00137         else
00138             K3StaticDeleterHelpers::unregisterStaticDeleter(this);
00139         return obj;
00140     }
00141 
00152     type *setObject( type* & globalRef, type *obj, bool isArray = false) {
00153         globalReference = &globalRef;
00154         deleteit = obj;
00155         array = isArray;
00156         if (obj)
00157             K3StaticDeleterHelpers::registerStaticDeleter(this);
00158         else
00159             K3StaticDeleterHelpers::unregisterStaticDeleter(this);
00160         globalRef = obj;
00161         return obj;
00162     }
00163 
00168     virtual void destructObject() {
00169         if (globalReference)
00170            *globalReference = 0;
00171         if (array)
00172             delete [] deleteit;
00173         else
00174             delete deleteit;
00175         deleteit = 0;
00176     }
00177 
00182     virtual ~K3StaticDeleter() {
00183         K3StaticDeleterHelpers::unregisterStaticDeleter(this);
00184         destructObject();
00185     }
00186 private:
00187     type *deleteit;
00188     type **globalReference;
00189     bool array;
00190 };
00191 
00192 #endif

KDE3Support

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal