Eneboo - Documentación para desarrolladores
src/qt/src/tools/qasciicache.h
Ir a la documentación de este archivo.
00001 /****************************************************************************
00002 ** $Id: qt/qasciicache.h   3.3.8   edited Jan 11 14:38 $
00003 **
00004 ** Definition of QAsciiCache template/macro class
00005 **
00006 ** Created : 950209
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 QASCIICACHE_H
00039 #define QASCIICACHE_H
00040 
00041 #ifndef QT_H
00042 #include "qgcache.h"
00043 #endif // QT_H
00044 
00045 
00046 template<class type> 
00047 class QAsciiCache
00048 #ifdef Q_QDOC
00049         : public QPtrCollection
00050 #else
00051         : public QGCache
00052 #endif
00053 {
00054 public:
00055     QAsciiCache( const QAsciiCache<type> &c ) : QGCache(c) {}
00056     QAsciiCache( int maxCost=100, int size=17, bool caseSensitive=TRUE,
00057                  bool copyKeys=TRUE )
00058         : QGCache( maxCost, size, AsciiKey, caseSensitive, copyKeys ) {}
00059    ~QAsciiCache()                       { clear(); }
00060     QAsciiCache<type> &operator=( const QAsciiCache<type> &c )
00061                         { return (QAsciiCache<type>&)QGCache::operator=(c); }
00062     int   maxCost()   const             { return QGCache::maxCost(); }
00063     int   totalCost() const             { return QGCache::totalCost(); }
00064     void  setMaxCost( int m )           { QGCache::setMaxCost(m); }
00065     uint  count()     const             { return QGCache::count(); }
00066     uint  size()      const             { return QGCache::size(); }
00067     bool  isEmpty()   const             { return QGCache::count() == 0; }
00068     void  clear()                       { QGCache::clear(); }
00069     bool  insert( const char *k, const type *d, int c=1, int p=0 )
00070                         { return QGCache::insert_other(k,(Item)d,c,p);}
00071     bool  remove( const char *k )
00072                         { return QGCache::remove_other(k); }
00073     type *take( const char *k )
00074                         { return (type *)QGCache::take_other(k); }
00075     type *find( const char *k, bool ref=TRUE ) const
00076                         { return (type *)QGCache::find_other(k,ref);}
00077     type *operator[]( const char *k ) const
00078                         { return (type *)QGCache::find_other(k);}
00079     void  statistics() const          { QGCache::statistics(); }
00080 private:
00081     void  deleteItem( Item d );
00082 };
00083 
00084 #if !defined(Q_BROKEN_TEMPLATE_SPECIALIZATION)
00085 template<> inline void QAsciiCache<void>::deleteItem( QPtrCollection::Item )
00086 {
00087 }
00088 #endif
00089 
00090 template<class type> inline void QAsciiCache<type>::deleteItem( QPtrCollection::Item d )
00091 {
00092     if ( del_item ) delete (type *)d;
00093 }
00094 
00095 
00096 template<class type> 
00097 class QAsciiCacheIterator : public QGCacheIterator
00098 {
00099 public:
00100     QAsciiCacheIterator( const QAsciiCache<type> &c ):QGCacheIterator((QGCache &)c) {}
00101     QAsciiCacheIterator( const QAsciiCacheIterator<type> &ci)
00102                                 : QGCacheIterator( (QGCacheIterator &)ci ) {}
00103     QAsciiCacheIterator<type> &operator=(const QAsciiCacheIterator<type>&ci)
00104         { return ( QAsciiCacheIterator<type>&)QGCacheIterator::operator=( ci ); }
00105     uint  count()   const     { return QGCacheIterator::count(); }
00106     bool  isEmpty() const     { return QGCacheIterator::count() == 0; }
00107     bool  atFirst() const     { return QGCacheIterator::atFirst(); }
00108     bool  atLast()  const     { return QGCacheIterator::atLast(); }
00109     type *toFirst()           { return (type *)QGCacheIterator::toFirst(); }
00110     type *toLast()            { return (type *)QGCacheIterator::toLast(); }
00111     operator type *() const   { return (type *)QGCacheIterator::get(); }
00112     type *current()   const   { return (type *)QGCacheIterator::get(); }
00113     const char *currentKey() const { return QGCacheIterator::getKeyAscii(); }
00114     type *operator()()        { return (type *)QGCacheIterator::operator()();}
00115     type *operator++()        { return (type *)QGCacheIterator::operator++(); }
00116     type *operator+=(uint j)  { return (type *)QGCacheIterator::operator+=(j);}
00117     type *operator--()        { return (type *)QGCacheIterator::operator--(); }
00118     type *operator-=(uint j)  { return (type *)QGCacheIterator::operator-=(j);}
00119 };
00120 
00121 
00122 #endif // QASCIICACHE_H
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'