summaryrefslogtreecommitdiff
path: root/libopie/pim/opimcache.h
Unidiff
Diffstat (limited to 'libopie/pim/opimcache.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/opimcache.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/libopie/pim/opimcache.h b/libopie/pim/opimcache.h
index 73414e5..7f7cff5 100644
--- a/libopie/pim/opimcache.h
+++ b/libopie/pim/opimcache.h
@@ -1,34 +1,39 @@
1#ifndef OPIE_PIM_CACHE_H 1#ifndef OPIE_PIM_CACHE_H
2#define OPIE_PIM_CACHE_H 2#define OPIE_PIM_CACHE_H
3 3
4#include <qintcache.h> 4#include <qintcache.h>
5 5
6#include "opimrecord.h" 6#include "opimrecord.h"
7 7
8class OPimCacheItemPrivate;
9
8template <class T = OPimRecord> 10template <class T = OPimRecord>
9class OPimCacheItem { 11class OPimCacheItem {
10public: 12public:
11 OPimCacheItem( const T& t = T() ); 13 OPimCacheItem( const T& t = T() );
12 OPimCacheItem( const OPimCacheItem& ); 14 OPimCacheItem( const OPimCacheItem& );
13 ~OPimCacheItem(); 15 ~OPimCacheItem();
14 16
15 OPimCacheItem &operator=( const OPimCacheItem& ); 17 OPimCacheItem &operator=( const OPimCacheItem& );
16 18
17 T record()const; 19 T record()const;
18 void setRecord( const T& ); 20 void setRecord( const T& );
19private: 21private:
20 T m_t; 22 T m_t;
23 OPimCacheItemPrivate *d;
21}; 24};
22 25
26
27class OPimCachePrivate;
23/** 28/**
24 * OPimCache for caching the items 29 * OPimCache for caching the items
25 * We support adding, removing 30 * We support adding, removing
26 * and finding 31 * and finding
27 */ 32 */
28template <class T = OPimRecord> 33template <class T = OPimRecord>
29class OPimCache { 34class OPimCache {
30public: 35public:
31 typedef OPimCacheItem<T> Item; 36 typedef OPimCacheItem<T> Item;
32 OPimCache(); 37 OPimCache();
33 OPimCache( const OPimCache& ); 38 OPimCache( const OPimCache& );
34 ~OPimCache(); 39 ~OPimCache();
@@ -37,24 +42,25 @@ public:
37 42
38 bool contains(int uid)const; 43 bool contains(int uid)const;
39 void invalidate(); 44 void invalidate();
40 void setSize( int size ); 45 void setSize( int size );
41 46
42 T find(int uid )const; 47 T find(int uid )const;
43 void add( const T& ); 48 void add( const T& );
44 void remove( int uid ); 49 void remove( int uid );
45 void replace( const T& ); 50 void replace( const T& );
46 51
47private: 52private:
48 QIntCache<Item> m_cache; 53 QIntCache<Item> m_cache;
54 OPimCachePrivate* d;
49}; 55};
50 56
51// Implementation 57// Implementation
52template <class T> 58template <class T>
53OPimCacheItem<T>::OPimCacheItem( const T& t ) 59OPimCacheItem<T>::OPimCacheItem( const T& t )
54 : m_t(t) { 60 : m_t(t) {
55} 61}
56template <class T> 62template <class T>
57OPimCacheItem<T>::~OPimCacheItem() { 63OPimCacheItem<T>::~OPimCacheItem() {
58 64
59} 65}
60template <class T> 66template <class T>