summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core/opimaccesstemplate.h
Unidiff
Diffstat (limited to 'libopie2/opiepim/core/opimaccesstemplate.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimaccesstemplate.h53
1 files changed, 29 insertions, 24 deletions
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h
index 36f5a99..31ab516 100644
--- a/libopie2/opiepim/core/opimaccesstemplate.h
+++ b/libopie2/opiepim/core/opimaccesstemplate.h
@@ -11,13 +11,13 @@
11 11
12/** 12/**
13 * Thats the frontend to our OPIE PIM 13 * Thats the frontend to our OPIE PIM
14 * Library. Either you want to use it's 14 * Library. Either you want to use it's
15 * interface or you want to implement 15 * interface or you want to implement
16 * your own Access lib 16 * your own Access lib
17 * Just create a OPimRecord and inherit from 17 * Just create a OPimRecord and inherit from
18 * the plugins 18 * the plugins
19 */ 19 */
20 20
21template <class T = OPimRecord > 21template <class T = OPimRecord >
22class OPimAccessTemplate : public OTemplateBase<T> { 22class OPimAccessTemplate : public OTemplateBase<T> {
23public: 23public:
@@ -33,81 +33,82 @@ public:
33 33
34 /** 34 /**
35 * c'tor BackEnd 35 * c'tor BackEnd
36 */ 36 */
37 OPimAccessTemplate( BackEnd* end); 37 OPimAccessTemplate( BackEnd* end);
38 virtual ~OPimAccessTemplate(); 38 virtual ~OPimAccessTemplate();
39 39
40 /** 40 /**
41 * load from the backend 41 * load from the backend
42 */ 42 */
43 virtual void load(); 43 virtual bool load();
44 44
45 /** 45 /**
46 * reload from the backend 46 * reload from the backend
47 */ 47 */
48 virtual void reload(); 48 virtual bool reload();
49 49
50 /** 50 /**
51 * save to the backend 51 * save to the backend
52 */ 52 */
53 virtual void save(); 53 virtual bool save();
54 54
55 /** 55 /**
56 * if the resource was changed externally 56 * if the resource was changed externally
57 */ 57 */
58 bool wasChangedExternally()const; 58 bool wasChangedExternally()const;
59 59
60 /** 60 /**
61 * return a List of records 61 * return a List of records
62 * you can iterate over them 62 * you can iterate over them
63 */ 63 */
64 virtual List allRecords()const; 64 virtual List allRecords()const;
65 65
66 /** 66 /**
67 * queryByExample 67 * queryByExample
68 */ 68 */
69 virtual List queryByExample( const T& t, int sortOrder ); 69 virtual List queryByExample( const T& t, int sortOrder );
70 70
71 /** 71 /**
72 * find the OPimRecord uid 72 * find the OPimRecord uid
73 */ 73 */
74 virtual T find( int uid ); 74 virtual T find( int uid )const;
75 75
76 /* invalidate cache here */ 76 /* invalidate cache here */
77 /** 77 /**
78 * clears the backend and invalidates the backend 78 * clears the backend and invalidates the backend
79 */ 79 */
80 virtual void clear() ; 80 virtual void clear() ;
81 81
82 /** 82 /**
83 * add T to the backend 83 * add T to the backend
84 */ 84 */
85 virtual bool add( const T& t ) ; 85 virtual bool add( const T& t ) ;
86 86
87 /* only the uid matters */ 87 /* only the uid matters */
88 /** 88 /**
89 * remove T from the backend 89 * remove T from the backend
90 */ 90 */
91 virtual bool remove( const T& t ); 91 virtual bool remove( const T& t );
92 92
93 /** 93 /**
94 * remove the OPimRecord with uid 94 * remove the OPimRecord with uid
95 */ 95 */
96 virtual bool remove( int uid ); 96 virtual bool remove( int uid );
97 97
98 /** 98 /**
99 * replace T from backend 99 * replace T from backend
100 */ 100 */
101 virtual bool replace( const T& t) ; 101 virtual bool replace( const T& t) ;
102protected: 102protected:
103 /** 103 /**
104 * invalidate the cache 104 * invalidate the cache
105 */ 105 */
106 void invalidateCache(); 106 void invalidateCache();
107 107
108 void setBackEnd( BackEnd* end );
108 /** 109 /**
109 * returns the backend 110 * returns the backend
110 */ 111 */
111 BackEnd* backEnd(); 112 BackEnd* backEnd();
112 BackEnd* m_backEnd; 113 BackEnd* m_backEnd;
113 114
@@ -122,22 +123,22 @@ OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end )
122template <class T> 123template <class T>
123OPimAccessTemplate<T>::~OPimAccessTemplate() { 124OPimAccessTemplate<T>::~OPimAccessTemplate() {
124 qWarning("~OPimAccessTemplate<T>"); 125 qWarning("~OPimAccessTemplate<T>");
125 delete m_backEnd; 126 delete m_backEnd;
126} 127}
127template <class T> 128template <class T>
128void OPimAccessTemplate<T>::load() { 129bool OPimAccessTemplate<T>::load() {
129 m_backEnd->load(); 130 return m_backEnd->load();
130} 131}
131template <class T> 132template <class T>
132void OPimAccessTemplate<T>::reload() { 133bool OPimAccessTemplate<T>::reload() {
133 m_backEnd->reload(); 134 return m_backEnd->reload();
134} 135}
135template <class T> 136template <class T>
136void OPimAccessTemplate<T>::save() { 137bool OPimAccessTemplate<T>::save() {
137 m_backEnd->save(); 138 return m_backEnd->save();
138} 139}
139template <class T> 140template <class T>
140OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { 141OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const {
141 QArray<int> ints = m_backEnd->allRecords(); 142 QArray<int> ints = m_backEnd->allRecords();
142 List lis(ints, this ); 143 List lis(ints, this );
143 return lis; 144 return lis;
@@ -148,13 +149,13 @@ OPimAccessTemplate<T>::queryByExample( const T& t, int sortOrder ) {
148 QArray<int> ints = m_backEnd->queryByExample( t, sortOrder ); 149 QArray<int> ints = m_backEnd->queryByExample( t, sortOrder );
149 150
150 List lis(ints, this ); 151 List lis(ints, this );
151 return lis; 152 return lis;
152} 153}
153template <class T> 154template <class T>
154T OPimAccessTemplate<T>::find( int uid ) { 155T OPimAccessTemplate<T>::find( int uid ) const{
155 T t = m_backEnd->find( uid ); 156 T t = m_backEnd->find( uid );
156 return t; 157 return t;
157} 158}
158template <class T> 159template <class T>
159void OPimAccessTemplate<T>::clear() { 160void OPimAccessTemplate<T>::clear() {
160 invalidateCache(); 161 invalidateCache();
@@ -185,7 +186,11 @@ OPimAccessTemplate<T>::BackEnd* OPimAccessTemplate<T>::backEnd() {
185 return m_backEnd; 186 return m_backEnd;
186} 187}
187template <class T> 188template <class T>
188bool OPimAccessTemplate<T>::wasChangedExternally()const { 189bool OPimAccessTemplate<T>::wasChangedExternally()const {
189 return false; 190 return false;
190} 191}
192template <class T>
193void OPimAccessTemplate<T>::setBackEnd( BackEnd* end ) {
194 m_backEnd = end;
195}
191#endif 196#endif