summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core/opimaccesstemplate.h
Unidiff
Diffstat (limited to 'libopie2/opiepim/core/opimaccesstemplate.h') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimaccesstemplate.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h
index 6de68b1..8cf81c8 100644
--- a/libopie2/opiepim/core/opimaccesstemplate.h
+++ b/libopie2/opiepim/core/opimaccesstemplate.h
@@ -84,24 +84,25 @@ public:
84 /* invalidate cache here */ 84 /* invalidate cache here */
85 /** 85 /**
86 * clears the backend and invalidates the backend 86 * clears the backend and invalidates the backend
87 */ 87 */
88 virtual void clear() ; 88 virtual void clear() ;
89 89
90 /** 90 /**
91 * add T to the backend 91 * add T to the backend
92 * @param t The item to add. 92 * @param t The item to add.
93 * @return <i>true</i> if added successfully. 93 * @return <i>true</i> if added successfully.
94 */ 94 */
95 virtual bool add( const T& t ) ; 95 virtual bool add( const T& t ) ;
96 bool add( const OPimRecord& );
96 97
97 /* only the uid matters */ 98 /* only the uid matters */
98 /** 99 /**
99 * remove T from the backend 100 * remove T from the backend
100 * @param t The item to remove 101 * @param t The item to remove
101 * @return <i>true</i> if successful. 102 * @return <i>true</i> if successful.
102 */ 103 */
103 virtual bool remove( const T& t ); 104 virtual bool remove( const T& t );
104 105
105 /** 106 /**
106 * remove the OPimRecord with uid 107 * remove the OPimRecord with uid
107 * @param uid The ID of the item to remove 108 * @param uid The ID of the item to remove
@@ -203,24 +204,33 @@ T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar,
203} 204}
204template <class T> 205template <class T>
205void OPimAccessTemplate<T>::clear() { 206void OPimAccessTemplate<T>::clear() {
206 invalidateCache(); 207 invalidateCache();
207 m_backEnd->clear(); 208 m_backEnd->clear();
208} 209}
209template <class T> 210template <class T>
210bool OPimAccessTemplate<T>::add( const T& t ) { 211bool OPimAccessTemplate<T>::add( const T& t ) {
211 cache( t ); 212 cache( t );
212 return m_backEnd->add( t ); 213 return m_backEnd->add( t );
213} 214}
214template <class T> 215template <class T>
216bool OPimAccessTemplate<T>::add( const OPimRecord& rec) {
217 /* same type */
218 if ( rec.rtti() == T::rtti() ) {
219 const T &t = static_cast<const T&>(rec);
220 return add(t);
221 }
222 return false;
223}
224template <class T>
215bool OPimAccessTemplate<T>::remove( const T& t ) { 225bool OPimAccessTemplate<T>::remove( const T& t ) {
216 return remove( t.uid() ); 226 return remove( t.uid() );
217} 227}
218template <class T> 228template <class T>
219bool OPimAccessTemplate<T>::remove( int uid ) { 229bool OPimAccessTemplate<T>::remove( int uid ) {
220 m_cache.remove( uid ); 230 m_cache.remove( uid );
221 return m_backEnd->remove( uid ); 231 return m_backEnd->remove( uid );
222} 232}
223template <class T> 233template <class T>
224bool OPimAccessTemplate<T>::replace( const T& t ) { 234bool OPimAccessTemplate<T>::replace( const T& t ) {
225 m_cache.replace( t ); 235 m_cache.replace( t );
226 return m_backEnd->replace( t ); 236 return m_backEnd->replace( t );