author | leseb <leseb> | 2002-07-15 23:22:50 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-07-15 23:22:50 (UTC) |
commit | 72eb74051ed8f1b7696041e241ab99df3af5b08d (patch) (side-by-side diff) | |
tree | bf9beee9469bc4384cb8178fbd6565cf161b4708 /noncore/apps/opie-write/qcleanuphandler.h | |
parent | dcea0e50a00ed9efb988ded5abf5d39de1bea393 (diff) | |
download | opie-72eb74051ed8f1b7696041e241ab99df3af5b08d.zip opie-72eb74051ed8f1b7696041e241ab99df3af5b08d.tar.gz opie-72eb74051ed8f1b7696041e241ab99df3af5b08d.tar.bz2 |
Sync with Qt 3.0.5
Diffstat (limited to 'noncore/apps/opie-write/qcleanuphandler.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-write/qcleanuphandler.h | 12 |
1 files changed, 0 insertions, 12 deletions
diff --git a/noncore/apps/opie-write/qcleanuphandler.h b/noncore/apps/opie-write/qcleanuphandler.h index 5c5bf16..2d6eb7c 100644 --- a/noncore/apps/opie-write/qcleanuphandler.h +++ b/noncore/apps/opie-write/qcleanuphandler.h @@ -20,120 +20,108 @@ ** licenses may use this file in accordance with the Qt Commercial License ** Agreement provided with the Software. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for ** information about Qt Commercial License Agreements. ** See http://www.trolltech.com/qpl/ for QPL licensing information. ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef QCLEANUPHANDLER_H #define QCLEANUPHANDLER_H #ifndef QT_H #include <qlist.h> #endif // QT_H template<class Type> -#ifdef Q_NO_TEMPLATE_EXPORT class QCleanupHandler -#else -class Q_EXPORT QCleanupHandler -#endif { public: QCleanupHandler() : cleanupObjects( 0 ) {} ~QCleanupHandler() { clear(); } Type* add( Type **object ) { if ( !cleanupObjects ) cleanupObjects = new QPtrList<Type*>; cleanupObjects->insert( 0, object ); return *object; } void remove( Type **object ) { if ( !cleanupObjects ) return; if ( cleanupObjects->findRef( object ) >= 0 ) (void) cleanupObjects->take(); } bool isEmpty() const { return cleanupObjects ? cleanupObjects->isEmpty() : TRUE; } void clear() { if ( !cleanupObjects ) return; QPtrListIterator<Type*> it( *cleanupObjects ); Type **object; while ( ( object = it.current() ) ) { delete *object; *object = 0; cleanupObjects->remove( object ); } delete cleanupObjects; cleanupObjects = 0; } private: QPtrList<Type*> *cleanupObjects; }; template<class Type> -#ifdef Q_NO_TEMPLATE_EXPORT class QSingleCleanupHandler -#else -class Q_EXPORT QSingleCleanupHandler -#endif { public: QSingleCleanupHandler() : object( 0 ) {} ~QSingleCleanupHandler() { if ( object ) { delete *object; *object = 0; } } Type* set( Type **o ) { object = o; return *object; } void reset() { object = 0; } private: Type **object; }; template<class Type> -#ifdef Q_NO_TEMPLATE_EXPORT class QSharedCleanupHandler -#else -class Q_EXPORT QSharedCleanupHandler -#endif { public: QSharedCleanupHandler() : object( 0 ) {} ~QSharedCleanupHandler() { if ( object ) { if ( (*object)->deref() ) delete *object; *object = 0; } } Type* set( Type **o ) { object = o; return *object; } void reset() { object = 0; } private: Type **object; }; #endif //QCLEANUPHANDLER_H |