Eneboo - Documentación para desarrolladores
src/qt/src/tools/qgcache.h
Ir a la documentación de este archivo.
00001 /****************************************************************************
00002 ** $Id: qt/qgcache.h   3.3.8   edited Jan 11 14:38 $
00003 **
00004 ** Definition of QGCache and QGCacheIterator classes
00005 **
00006 ** Created : 950208
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 QGCACHE_H
00039 #define QGCACHE_H
00040 
00041 #ifndef QT_H
00042 #include "qptrcollection.h"
00043 #include "qglist.h"
00044 #include "qgdict.h"
00045 #endif // QT_H
00046 
00047 
00048 class QCList;                                   // internal classes
00049 class QCListIt;
00050 class QCDict;
00051 
00052 
00053 class Q_EXPORT QGCache : public QPtrCollection  // generic LRU cache
00054 {
00055 friend class QGCacheIterator;
00056 protected:
00057     enum KeyType { StringKey, AsciiKey, IntKey, PtrKey };
00058       // identical to QGDict's, but PtrKey is not used at the moment
00059 
00060     QGCache( int maxCost, uint size, KeyType kt, bool caseSensitive,
00061              bool copyKeys );
00062     QGCache( const QGCache & );                 // not allowed, calls fatal()
00063    ~QGCache();
00064     QGCache &operator=( const QGCache & );      // not allowed, calls fatal()
00065 
00066     uint    count()     const;
00067     uint    size()      const;
00068     int     maxCost()   const   { return mCost; }
00069     int     totalCost() const   { return tCost; }
00070     void    setMaxCost( int maxCost );
00071     void    clear();
00072 
00073     bool    insert_string( const QString &key, QPtrCollection::Item,
00074                            int cost, int priority );
00075     bool    insert_other( const char *key, QPtrCollection::Item,
00076                           int cost, int priority );
00077     bool    remove_string( const QString &key );
00078     bool    remove_other( const char *key );
00079     QPtrCollection::Item take_string( const QString &key );
00080     QPtrCollection::Item take_other( const char *key );
00081 
00082     QPtrCollection::Item find_string( const QString &key, bool ref=TRUE ) const;
00083     QPtrCollection::Item find_other( const char *key, bool ref=TRUE ) const;
00084 
00085     void    statistics() const;
00086 
00087 private:
00088     bool    makeRoomFor( int cost, int priority = -1 );
00089     KeyType keytype;
00090     QCList *lruList;
00091     QCDict *dict;
00092     int     mCost;
00093     int     tCost;
00094     bool    copyk;
00095 };
00096 
00097 
00098 class Q_EXPORT QGCacheIterator                  // generic cache iterator
00099 {
00100 protected:
00101     QGCacheIterator( const QGCache & );
00102     QGCacheIterator( const QGCacheIterator & );
00103    ~QGCacheIterator();
00104     QGCacheIterator &operator=( const QGCacheIterator & );
00105 
00106     uint              count()   const;
00107     bool              atFirst() const;
00108     bool              atLast()  const;
00109     QPtrCollection::Item toFirst();
00110     QPtrCollection::Item toLast();
00111 
00112     QPtrCollection::Item get() const;
00113     QString           getKeyString() const;
00114     const char       *getKeyAscii()  const;
00115     long              getKeyInt()    const;
00116 
00117     QPtrCollection::Item operator()();
00118     QPtrCollection::Item operator++();
00119     QPtrCollection::Item operator+=( uint );
00120     QPtrCollection::Item operator--();
00121     QPtrCollection::Item operator-=( uint );
00122 
00123 protected:
00124     QCListIt *it;                               // iterator on cache list
00125 };
00126 
00127 
00128 #endif // QGCACHE_H
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'