summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core/opimaccesstemplate.h
Side-by-side diff
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 @@
This file is part of the Opie Project
- Copyright (C) The Main Author <main-author@whereever.org>
+ Copyright (C) Holger Freyther <zecke@handhelds.org>
+ Copyright (C) Stefan Eilers <eilers.stefan@epost.de>
=. Copyright (C) The Opie Team <opie-devel@handhelds.org>
@@ -139,2 +140,9 @@ public:
bool add( const OPimRecord& );
+ // Needed for real generic access (eilers)
+ // Info: Take this if you are working with OPimRecord, which is a generic base class, and
+ // you need to add it into any database, you cannot generate a reference to
+ // it and casting may be not approriate, too.
+ // But take care that the accessing database is compatible to the real type of OPimRecord !!
+ bool add( const OPimRecord* );
+
@@ -273,2 +281,3 @@ bool OPimAccessTemplate<T>::add( const T& t ) {
}
+
template <class T>
@@ -276,4 +285,5 @@ bool OPimAccessTemplate<T>::add( const OPimRecord& rec) {
/* same type */
- if ( rec.rtti() == T::rtti() ) {
- const T &t = static_cast<const T&>(rec);
+ T tempInstance;
+ if ( rec.rtti() == tempInstance.rtti() ) {
+ const T& t = static_cast<const T&>(rec);
return add(t);
@@ -282,2 +292,14 @@ bool OPimAccessTemplate<T>::add( const OPimRecord& rec) {
}
+
+template <class T>
+bool OPimAccessTemplate<T>::add( const OPimRecord* rec) {
+ /* same type, but pointer */
+ T tempInstance;
+ if ( rec -> rtti() == tempInstance.rtti() ) {
+ const T* t = static_cast<const T*>(rec);
+ return add( *t );
+ }
+ return false;
+}
+
template <class T>