Diffstat (limited to 'libopie2/opiepim/core/opimcache.h') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiepim/core/opimcache.h | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/libopie2/opiepim/core/opimcache.h b/libopie2/opiepim/core/opimcache.h index e70a910..a033574 100644 --- a/libopie2/opiepim/core/opimcache.h +++ b/libopie2/opiepim/core/opimcache.h | |||
@@ -1,83 +1,85 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #ifndef OPIE_PIM_CACHE_H | 29 | #ifndef OPIMCACHE_H |
30 | #define OPIE_PIM_CACHE_H | 30 | #define OPIMCACHE_H |
31 | |||
32 | #include <qintcache.h> | ||
33 | 31 | ||
32 | /* OPIE */ | ||
34 | #include <opie2/opimrecord.h> | 33 | #include <opie2/opimrecord.h> |
35 | 34 | ||
35 | /* QT */ | ||
36 | #include <qintcache.h> | ||
37 | |||
36 | namespace Opie { | 38 | namespace Opie { |
37 | class OPimCacheItemPrivate; | 39 | class OPimCacheItemPrivate; |
38 | 40 | ||
39 | template <class T = OPimRecord> | 41 | template <class T = OPimRecord> |
40 | class OPimCacheItem { | 42 | class OPimCacheItem { |
41 | public: | 43 | public: |
42 | OPimCacheItem( const T& t = T() ); | 44 | OPimCacheItem( const T& t = T() ); |
43 | OPimCacheItem( const OPimCacheItem& ); | 45 | OPimCacheItem( const OPimCacheItem& ); |
44 | ~OPimCacheItem(); | 46 | ~OPimCacheItem(); |
45 | 47 | ||
46 | OPimCacheItem &operator=( const OPimCacheItem& ); | 48 | OPimCacheItem &operator=( const OPimCacheItem& ); |
47 | 49 | ||
48 | T record()const; | 50 | T record()const; |
49 | void setRecord( const T& ); | 51 | void setRecord( const T& ); |
50 | private: | 52 | private: |
51 | T m_t; | 53 | T m_t; |
52 | OPimCacheItemPrivate *d; | 54 | OPimCacheItemPrivate *d; |
53 | }; | 55 | }; |
54 | 56 | ||
55 | 57 | ||
56 | class OPimCachePrivate; | 58 | class OPimCachePrivate; |
57 | /** | 59 | /** |
58 | * OPimCache for caching the items | 60 | * OPimCache for caching the items |
59 | * We support adding, removing | 61 | * We support adding, removing |
60 | * and finding | 62 | * and finding |
61 | */ | 63 | */ |
62 | template <class T = OPimRecord> | 64 | template <class T = OPimRecord> |
63 | class OPimCache { | 65 | class OPimCache { |
64 | public: | 66 | public: |
65 | typedef OPimCacheItem<T> Item; | 67 | typedef OPimCacheItem<T> Item; |
66 | OPimCache(); | 68 | OPimCache(); |
67 | OPimCache( const OPimCache& ); | 69 | OPimCache( const OPimCache& ); |
68 | ~OPimCache(); | 70 | ~OPimCache(); |
69 | 71 | ||
70 | OPimCache &operator=( const OPimCache& ); | 72 | OPimCache &operator=( const OPimCache& ); |
71 | 73 | ||
72 | bool contains(int uid)const; | 74 | bool contains(int uid)const; |
73 | void invalidate(); | 75 | void invalidate(); |
74 | void setSize( int size ); | 76 | void setSize( int size ); |
75 | 77 | ||
76 | T find(int uid )const; | 78 | T find(int uid )const; |
77 | void add( const T& ); | 79 | void add( const T& ); |
78 | void remove( int uid ); | 80 | void remove( int uid ); |
79 | void replace( const T& ); | 81 | void replace( const T& ); |
80 | 82 | ||
81 | private: | 83 | private: |
82 | QIntCache<Item> m_cache; | 84 | QIntCache<Item> m_cache; |
83 | OPimCachePrivate* d; | 85 | OPimCachePrivate* d; |