author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Fri, 16 Apr 2010 11:39:52 +0300 | |
branch | RCL_3 |
changeset 8 | 740e5562c97f |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the Qt3Support module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#ifndef Q3GCACHE_H |
|
43 |
#define Q3GCACHE_H |
|
44 |
||
45 |
#include <Qt3Support/q3ptrcollection.h> |
|
46 |
#include <Qt3Support/q3glist.h> |
|
47 |
#include <Qt3Support/q3gdict.h> |
|
48 |
||
49 |
QT_BEGIN_HEADER |
|
50 |
||
51 |
QT_BEGIN_NAMESPACE |
|
52 |
||
53 |
QT_MODULE(Qt3SupportLight) |
|
54 |
||
55 |
class Q3CList; // internal classes |
|
56 |
class Q3CListIt; |
|
57 |
class Q3CDict; |
|
58 |
||
59 |
class Q_COMPAT_EXPORT Q3GCache : public Q3PtrCollection // generic LRU cache |
|
60 |
{ |
|
61 |
friend class Q3GCacheIterator; |
|
62 |
protected: |
|
63 |
enum KeyType { StringKey, AsciiKey, IntKey, PtrKey }; |
|
64 |
// identical to Q3GDict's, but PtrKey is not used at the moment |
|
65 |
||
66 |
Q3GCache(int maxCost, uint size, KeyType kt, bool caseSensitive, |
|
67 |
bool copyKeys); |
|
68 |
Q3GCache(const Q3GCache &); // not allowed, calls fatal() |
|
69 |
~Q3GCache(); |
|
70 |
Q3GCache &operator=(const Q3GCache &); // not allowed, calls fatal() |
|
71 |
||
72 |
uint count() const; |
|
73 |
uint size() const; |
|
74 |
int maxCost() const { return mCost; } |
|
75 |
int totalCost() const { return tCost; } |
|
76 |
void setMaxCost(int maxCost); |
|
77 |
void clear(); |
|
78 |
||
79 |
bool insert_string(const QString &key, Q3PtrCollection::Item, |
|
80 |
int cost, int priority); |
|
81 |
bool insert_other(const char *key, Q3PtrCollection::Item, |
|
82 |
int cost, int priority); |
|
83 |
bool remove_string(const QString &key); |
|
84 |
bool remove_other(const char *key); |
|
85 |
Q3PtrCollection::Item take_string(const QString &key); |
|
86 |
Q3PtrCollection::Item take_other(const char *key); |
|
87 |
||
88 |
Q3PtrCollection::Item find_string(const QString &key, bool ref=true) const; |
|
89 |
Q3PtrCollection::Item find_other(const char *key, bool ref=true) const; |
|
90 |
||
91 |
void statistics() const; |
|
92 |
||
93 |
private: |
|
94 |
bool makeRoomFor(int cost, int priority = -1); |
|
95 |
KeyType keytype; |
|
96 |
Q3CList *lruList; |
|
97 |
Q3CDict *dict; |
|
98 |
int mCost; |
|
99 |
int tCost; |
|
100 |
bool copyk; |
|
101 |
}; |
|
102 |
||
103 |
||
104 |
class Q_COMPAT_EXPORT Q3GCacheIterator // generic cache iterator |
|
105 |
{ |
|
106 |
protected: |
|
107 |
Q3GCacheIterator(const Q3GCache &); |
|
108 |
Q3GCacheIterator(const Q3GCacheIterator &); |
|
109 |
~Q3GCacheIterator(); |
|
110 |
Q3GCacheIterator &operator=(const Q3GCacheIterator &); |
|
111 |
||
112 |
uint count() const; |
|
113 |
bool atFirst() const; |
|
114 |
bool atLast() const; |
|
115 |
Q3PtrCollection::Item toFirst(); |
|
116 |
Q3PtrCollection::Item toLast(); |
|
117 |
||
118 |
Q3PtrCollection::Item get() const; |
|
119 |
QString getKeyString() const; |
|
120 |
const char *getKeyAscii() const; |
|
121 |
long getKeyInt() const; |
|
122 |
||
123 |
Q3PtrCollection::Item operator()(); |
|
124 |
Q3PtrCollection::Item operator++(); |
|
125 |
Q3PtrCollection::Item operator+=(uint); |
|
126 |
Q3PtrCollection::Item operator--(); |
|
127 |
Q3PtrCollection::Item operator-=(uint); |
|
128 |
||
129 |
protected: |
|
130 |
Q3CListIt *it; // iterator on cache list |
|
131 |
}; |
|
132 |
||
133 |
QT_END_NAMESPACE |
|
134 |
||
135 |
QT_END_HEADER |
|
136 |
||
137 |
#endif // Q3GCACHE_H |