Eneboo - Documentación para desarrolladores
src/qt/src/tools/qptrdict.h
Ir a la documentación de este archivo.
00001 /****************************************************************************
00002 ** $Id: qt/qptrdict.h   3.3.8   edited Jan 11 14:38 $
00003 **
00004 ** Definition of QPtrDict template class
00005 **
00006 ** Created : 970415
00007 **
00008 ** Copyright (C) 1992-2007 Trolltech ASA.  All rights reserved.
00009 **
00010 ** This file is part of the tools module of the Qt GUI Toolkit.
00011 **
00012 ** This file may be distributed under the terms of the Q Public License
00013 ** as defined by Trolltech ASA of Norway and appearing in the file
00014 ** LICENSE.QPL included in the packaging of this file.
00015 **
00016 ** This file may be distributed and/or modified under the terms of the
00017 ** GNU General Public License version 2 as published by the Free Software
00018 ** Foundation and appearing in the file LICENSE.GPL included in the
00019 ** packaging of this file.
00020 **
00021 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
00022 ** licenses may use this file in accordance with the Qt Commercial License
00023 ** Agreement provided with the Software.
00024 **
00025 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00026 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00027 **
00028 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00029 **   information about Qt Commercial License Agreements.
00030 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
00031 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00032 **
00033 ** Contact info@trolltech.com if any conditions of this licensing are
00034 ** not clear to you.
00035 **
00036 **********************************************************************/
00037 
00038 #ifndef QPTRDICT_H
00039 #define QPTRDICT_H
00040 
00041 #ifndef QT_H
00042 #include "qgdict.h"
00043 #endif // QT_H
00044 
00045 template<class type>
00046 class QPtrDict
00047 #ifdef Q_QDOC
00048         : public QPtrCollection
00049 #else
00050         : public QGDict
00051 #endif
00052 {
00053 public:
00054     QPtrDict(int size=17) : QGDict(size,PtrKey,0,0) {}
00055     QPtrDict( const QPtrDict<type> &d ) : QGDict(d) {}
00056    ~QPtrDict()                          { clear(); }
00057     QPtrDict<type> &operator=(const QPtrDict<type> &d)
00058                         { return (QPtrDict<type>&)QGDict::operator=(d); }
00059     uint  count()   const               { return QGDict::count(); }
00060     uint  size()    const               { return QGDict::size(); }
00061     bool  isEmpty() const               { return QGDict::count() == 0; }
00062     void  insert( void *k, const type *d )
00063                                         { QGDict::look_ptr(k,(Item)d,1); }
00064     void  replace( void *k, const type *d )
00065                                         { QGDict::look_ptr(k,(Item)d,2); }
00066     bool  remove( void *k )             { return QGDict::remove_ptr(k); }
00067     type *take( void *k )               { return (type*)QGDict::take_ptr(k); }
00068     type *find( void *k ) const
00069                 { return (type *)((QGDict*)this)->QGDict::look_ptr(k,0,0); }
00070     type *operator[]( void *k ) const
00071                 { return (type *)((QGDict*)this)->QGDict::look_ptr(k,0,0); }
00072     void  clear()                       { QGDict::clear(); }
00073     void  resize( uint n )              { QGDict::resize(n); }
00074     void  statistics() const            { QGDict::statistics(); }
00075 
00076 #ifdef Q_QDOC
00077 protected:
00078     virtual QDataStream& read( QDataStream &, QPtrCollection::Item & );
00079     virtual QDataStream& write( QDataStream &, QPtrCollection::Item ) const;
00080 #endif
00081 
00082 private:
00083     void  deleteItem( Item d );
00084 };
00085 
00086 #if !defined(Q_BROKEN_TEMPLATE_SPECIALIZATION)
00087 template<> inline void QPtrDict<void>::deleteItem( QPtrCollection::Item )
00088 {
00089 }
00090 #endif
00091 
00092 template<class type>
00093 inline void QPtrDict<type>::deleteItem( QPtrCollection::Item d )
00094 {
00095     if ( del_item ) delete (type *)d;
00096 }
00097 
00098 template<class type>
00099 class QPtrDictIterator : public QGDictIterator
00100 {
00101 public:
00102     QPtrDictIterator(const QPtrDict<type> &d) :QGDictIterator((QGDict &)d) {}
00103    ~QPtrDictIterator()        {}
00104     uint  count()   const     { return dict->count(); }
00105     bool  isEmpty() const     { return dict->count() == 0; }
00106     type *toFirst()           { return (type *)QGDictIterator::toFirst(); }
00107     operator type *()  const  { return (type *)QGDictIterator::get(); }
00108     type *current()    const  { return (type *)QGDictIterator::get(); }
00109     void *currentKey() const  { return QGDictIterator::getKeyPtr(); }
00110     type *operator()()        { return (type *)QGDictIterator::operator()(); }
00111     type *operator++()        { return (type *)QGDictIterator::operator++(); }
00112     type *operator+=(uint j)  { return (type *)QGDictIterator::operator+=(j);}
00113 };
00114 
00115 #endif // QPTRDICT_H
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'