summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core/opimaccesstemplate.h
authoreilers <eilers>2004-04-28 09:22:02 (UTC)
committer eilers <eilers>2004-04-28 09:22:02 (UTC)
commit134b7accd6bdc8fbc160a42f7c52c585e73f4add (patch) (unidiff)
tree5e221e990d0c94e38d816e147762f205733b0e72 /libopie2/opiepim/core/opimaccesstemplate.h
parent8ce67859c54234dabd88e17a0bc72369ea8301a3 (diff)
downloadopie-134b7accd6bdc8fbc160a42f7c52c585e73f4add.zip
opie-134b7accd6bdc8fbc160a42f7c52c585e73f4add.tar.gz
opie-134b7accd6bdc8fbc160a42f7c52c585e73f4add.tar.bz2
Some modifications to alow use of generic OPimRecords without need to
cast them manually to the right type
Diffstat (limited to 'libopie2/opiepim/core/opimaccesstemplate.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimaccesstemplate.h28
1 files changed, 25 insertions, 3 deletions
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h
index f1bcc44..d4c5fbb 100644
--- a/libopie2/opiepim/core/opimaccesstemplate.h
+++ b/libopie2/opiepim/core/opimaccesstemplate.h
@@ -2,3 +2,4 @@
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) Holger Freyther <zecke@handhelds.org>
4 Copyright (C) Stefan Eilers <eilers.stefan@epost.de>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 5 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
@@ -139,2 +140,9 @@ public:
139 bool add( const OPimRecord& ); 140 bool add( const OPimRecord& );
141 // Needed for real generic access (eilers)
142 // Info: Take this if you are working with OPimRecord, which is a generic base class, and
143 // you need to add it into any database, you cannot generate a reference to
144 // it and casting may be not approriate, too.
145 // But take care that the accessing database is compatible to the real type of OPimRecord !!
146 bool add( const OPimRecord* );
147
140 148
@@ -273,2 +281,3 @@ bool OPimAccessTemplate<T>::add( const T& t ) {
273} 281}
282
274template <class T> 283template <class T>
@@ -276,4 +285,5 @@ bool OPimAccessTemplate<T>::add( const OPimRecord& rec) {
276 /* same type */ 285 /* same type */
277 if ( rec.rtti() == T::rtti() ) { 286 T tempInstance;
278 const T &t = static_cast<const T&>(rec); 287 if ( rec.rtti() == tempInstance.rtti() ) {
288 const T& t = static_cast<const T&>(rec);
279 return add(t); 289 return add(t);
@@ -282,2 +292,14 @@ bool OPimAccessTemplate<T>::add( const OPimRecord& rec) {
282} 292}
293
294template <class T>
295bool OPimAccessTemplate<T>::add( const OPimRecord* rec) {
296 /* same type, but pointer */
297 T tempInstance;
298 if ( rec -> rtti() == tempInstance.rtti() ) {
299 const T* t = static_cast<const T*>(rec);
300 return add( *t );
301 }
302 return false;
303}
304
283template <class T> 305template <class T>