Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

QGCache Class Reference

The QGCache class is an internal class for implementing QCache template classes. More...

#include </home/clem/local/src/opie/qmake/include/qgcache.h>

Inheritance diagram for QGCache:

Inheritance graph
[legend]
Collaboration diagram for QGCache:

Collaboration graph
[legend]
List of all members.

Protected Types

enum  KeyType { StringKey, AsciiKey, IntKey, PtrKey }

Protected Member Functions

 QGCache (int maxCost, uint size, KeyType kt, bool caseSensitive, bool copyKeys)
 QGCache (const QGCache &)
 ~QGCache ()
QGCacheoperator= (const QGCache &)
uint count () const
uint size () const
int maxCost () const
int totalCost () const
void setMaxCost (int maxCost)
void clear ()
bool insert_string (const QString &key, QPtrCollection::Item, int cost, int priority)
bool insert_other (const char *key, QPtrCollection::Item, int cost, int priority)
bool remove_string (const QString &key)
bool remove_other (const char *key)
QPtrCollection::Item take_string (const QString &key)
QPtrCollection::Item take_other (const char *key)
QPtrCollection::Item find_string (const QString &key, bool ref=TRUE) const
QPtrCollection::Item find_other (const char *key, bool ref=TRUE) const
void statistics () const

Private Member Functions

bool makeRoomFor (int cost, int priority=-1)

Private Attributes

KeyType keytype
QCListlruList
QCDictdict
int mCost
int tCost
bool copyk

Friends

class QGCacheIterator

Detailed Description

The QGCache class is an internal class for implementing QCache template classes.

For internal use only.

QGCache is a strictly internal class that acts as a base class for the collection classes QCache and QIntCache.

Definition at line 53 of file qgcache.h.


Member Enumeration Documentation

enum QGCache::KeyType [protected]
 

Enumeration values:
StringKey 
AsciiKey 
IntKey 
PtrKey 

Definition at line 57 of file qgcache.h.


Constructor & Destructor Documentation

QGCache::QGCache int  maxCost,
uint  size,
KeyType  kt,
bool  caseSensitive,
bool  copyKeys
[protected]
 

Constructs a cache. The maximum cost of the cache is given by maxCost and the size by size. The key type is kt which may be StringKey, AsciiKey, IntKey or PtrKey. The case-sensitivity of lookups is set with caseSensitive. Keys are copied if copyKeys is TRUE.

Definition at line 251 of file qgcache.cpp.

References AsciiKey, copyk, dict, FALSE, keytype, lruList, mCost, QCList::setAutoDelete(), tCost, and TRUE.

QGCache::QGCache const QGCache  )  [protected]
 

Cannot copy a cache.

Definition at line 279 of file qgcache.cpp.

References qFatal().

QGCache::~QGCache  )  [protected]
 

Removes all items from the cache and destroys it.

Definition at line 291 of file qgcache.cpp.

References clear(), dict, and lruList.


Member Function Documentation

void QGCache::clear  )  [protected, virtual]
 

Clears the cache.

Implements QPtrCollection.

Reimplemented in QCache< type >, QCache< QPixmap >, QCache< SkinData >, QCache< QImage >, and QCache< QFontStruct >.

Definition at line 505 of file qgcache.cpp.

References AsciiKey, QCacheItem::data, QPtrCollection::deleteItem(), dict, QCList::first(), IntKey, keytype, lruList, PtrKey, QCDict::remove_ascii(), QCDict::remove_int(), QCDict::remove_string(), QCList::removeFirst(), StringKey, and tCost.

Referenced by QCache< QFontStruct >::clear(), and ~QGCache().

uint QGCache::count  )  const [protected, virtual]
 

Returns the number of items in the cache.

Implements QPtrCollection.

Reimplemented in QCache< type >, QCache< QPixmap >, QCache< SkinData >, QCache< QImage >, and QCache< QFontStruct >.

Definition at line 315 of file qgcache.cpp.

References QGDict::count(), and dict.

Referenced by QCache< QFontStruct >::count(), QCache< QFontStruct >::isEmpty(), and statistics().

QPtrCollection::Item QGCache::find_other const char *  key,
bool  ref = TRUE
const [protected]
 

Finds an item for key in the cache and adds a reference if ref is TRUE.

Definition at line 559 of file qgcache.cpp.

References AsciiKey, dict, QCDict::find_ascii(), QCDict::find_int(), keytype, lruList, and QCList::reference().

QPtrCollection::Item QGCache::find_string const QString key,
bool  ref = TRUE
const [protected]
 

Finds an item for key in the cache and adds a reference if ref is TRUE.

Definition at line 536 of file qgcache.cpp.

References dict, QCDict::find_string(), lruList, and QCList::reference().

Referenced by QCache< QFontStruct >::find(), and QCache< QFontStruct >::operator[]().

bool QGCache::insert_other const char *  key,
QPtrCollection::Item  ,
int  cost,
int  priority
[protected]
 

Definition at line 396 of file qgcache.cpp.

References AsciiKey, copyk, dict, FALSE, QCList::insert(), QCDict::insert_ascii(), QCDict::insert_int(), keytype, lruList, makeRoomFor(), mCost, QPtrCollection::newItem(), Q_ASSERT, qstrdup(), StringKey, tCost, and TRUE.

bool QGCache::insert_string const QString key,
QPtrCollection::Item  data,
int  cost,
int  priority
[protected]
 

Inserts an item with data data into the cache using key key. The item has cost cost and priority priority.

Warning:
If this function returns FALSE, you must delete data yourself. Additionally, be very careful about using data after calling this function, as any other insertions into the cache, from anywhere in the application, or within Qt itself, could cause the data to be discarded from the cache, and the pointer to become invalid.

Definition at line 367 of file qgcache.cpp.

References dict, FALSE, QCList::insert(), QCDict::insert_string(), keytype, lruList, makeRoomFor(), mCost, QPtrCollection::newItem(), Q_ASSERT, StringKey, tCost, and TRUE.

Referenced by QCache< QFontStruct >::insert().

bool QGCache::makeRoomFor int  cost,
int  priority = -1
[private]
 

Allocates cache space for one or more items.

Definition at line 583 of file qgcache.cpp.

References AsciiKey, copyk, QCacheItem::cost, QCacheItem::data, QPtrCollection::deleteItem(), dict, FALSE, IntKey, keytype, QCList::last(), lruList, mCost, QCList::prev(), PtrKey, Q_ASSERT, QCDict::remove_ascii(), QCDict::remove_int(), QCDict::remove_string(), QCList::removeLast(), StringKey, tCost, and TRUE.

Referenced by insert_other(), insert_string(), and setMaxCost().

int QGCache::maxCost  )  const [inline, protected]
 

Returns the maximum cache cost.

Reimplemented in QCache< type >, QCache< QPixmap >, QCache< SkinData >, QCache< QImage >, and QCache< QFontStruct >.

Definition at line 68 of file qgcache.h.

Referenced by QCache< QFontStruct >::maxCost().

QGCache & QGCache::operator= const QGCache  )  [protected]
 

Cannot assign a cache.

Definition at line 302 of file qgcache.cpp.

References qFatal().

Referenced by QCache< QFontStruct >::operator=().

bool QGCache::remove_other const char *  key  )  [protected]
 

Definition at line 444 of file qgcache.cpp.

References d, QPtrCollection::deleteItem(), and take_other().

bool QGCache::remove_string const QString key  )  [protected]
 

Removes the item with key key from the cache. Returns TRUE if the item was removed; otherwise returns FALSE.

Definition at line 436 of file qgcache.cpp.

References d, QPtrCollection::deleteItem(), and take_string().

Referenced by QCache< QFontStruct >::remove().

void QGCache::setMaxCost int  maxCost  )  [protected]
 

Sets the maximum cache cost to maxCost.

Reimplemented in QCache< type >, QCache< QPixmap >, QCache< SkinData >, QCache< QImage >, and QCache< QFontStruct >.

Definition at line 345 of file qgcache.cpp.

References makeRoomFor(), mCost, and tCost.

Referenced by QCache< QFontStruct >::setMaxCost().

uint QGCache::size  )  const [protected]
 

Returns the size of the hash array.

Reimplemented in QCache< type >, QCache< QPixmap >, QCache< SkinData >, QCache< QImage >, and QCache< QFontStruct >.

Definition at line 324 of file qgcache.cpp.

References dict, and QGDict::size().

Referenced by QCache< QFontStruct >::size().

void QGCache::statistics  )  const [protected]
 

Outputs debug statistics.

Reimplemented in QCache< type >, QCache< QPixmap >, QCache< SkinData >, QCache< QImage >, and QCache< QFontStruct >.

Definition at line 636 of file qgcache.cpp.

References QString::ascii(), count(), dict, QString::fill(), lruList, mCost, qDebug(), QCDict::statistics(), and tCost.

Referenced by QCache< QFontStruct >::statistics().

QPtrCollection::Item QGCache::take_other const char *  key  )  [protected]
 

Takes the item with key key out of the cache. The item is not deleted. If no item has this key 0 is returned.

Definition at line 479 of file qgcache.cpp.

References AsciiKey, copyk, d, dict, keytype, lruList, QCList::take(), QCDict::take_ascii(), QCDict::take_int(), and tCost.

Referenced by remove_other().

QPtrCollection::Item QGCache::take_string const QString key  )  [protected]
 

Takes the item with key key out of the cache. The item is not deleted. If no item has this key 0 is returned.

Definition at line 458 of file qgcache.cpp.

References d, dict, lruList, QCList::take(), QCDict::take_string(), and tCost.

Referenced by remove_string(), and QCache< QFontStruct >::take().

int QGCache::totalCost  )  const [inline, protected]
 

Returns the total cache cost.

Reimplemented in QCache< type >, QCache< QPixmap >, QCache< SkinData >, QCache< QImage >, and QCache< QFontStruct >.

Definition at line 69 of file qgcache.h.

Referenced by QCache< QFontStruct >::totalCost().


Friends And Related Function Documentation

friend class QGCacheIterator [friend]
 

Definition at line 55 of file qgcache.h.


Member Data Documentation

bool QGCache::copyk [private]
 

Definition at line 94 of file qgcache.h.

Referenced by insert_other(), makeRoomFor(), QGCache(), and take_other().

QCDict* QGCache::dict [private]
 

Definition at line 91 of file qgcache.h.

Referenced by clear(), count(), find_other(), find_string(), insert_other(), insert_string(), makeRoomFor(), QGCache(), size(), statistics(), take_other(), take_string(), and ~QGCache().

KeyType QGCache::keytype [private]
 

Definition at line 89 of file qgcache.h.

Referenced by clear(), find_other(), insert_other(), insert_string(), makeRoomFor(), QGCache(), and take_other().

QCList* QGCache::lruList [private]
 

Definition at line 90 of file qgcache.h.

Referenced by clear(), find_other(), find_string(), insert_other(), insert_string(), makeRoomFor(), QGCache(), QGCacheIterator::QGCacheIterator(), statistics(), take_other(), take_string(), and ~QGCache().

int QGCache::mCost [private]
 

Definition at line 92 of file qgcache.h.

Referenced by insert_other(), insert_string(), makeRoomFor(), QGCache(), setMaxCost(), and statistics().

int QGCache::tCost [private]
 

Definition at line 93 of file qgcache.h.

Referenced by clear(), insert_other(), insert_string(), makeRoomFor(), QGCache(), setMaxCost(), statistics(), take_other(), and take_string().


The documentation for this class was generated from the following files:
Generated on Sat Nov 5 17:47:01 2005 for OPIE by  doxygen 1.4.2