summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend
Side-by-side diff
Diffstat (limited to 'libopie2/opiepim/backend') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/obackendfactory.h20
-rw-r--r--libopie2/opiepim/backend/opimaccessbackend.h40
2 files changed, 53 insertions, 7 deletions
diff --git a/libopie2/opiepim/backend/obackendfactory.h b/libopie2/opiepim/backend/obackendfactory.h
index f11f029..89b8c58 100644
--- a/libopie2/opiepim/backend/obackendfactory.h
+++ b/libopie2/opiepim/backend/obackendfactory.h
@@ -13,37 +13,45 @@
* ToDo: Use plugins
* =====================================================================
* Version: $Id$
* =====================================================================
* History:
* $Log$
+ * Revision 1.3 2002/10/10 17:08:58 zecke
+ * The Cache is finally in place
+ * I tested it with my todolist and it 'works' for 10.000 todos the hits are awesome ;)
+ * The read ahead functionality does not make sense for XMLs backends because most of the stuff is already in memory. While using readahead on SQL makes things a lot faster....
+ * I still have to fully implement read ahead
+ * This change is bic but sc
+ *
* Revision 1.2 2002/10/08 09:27:36 eilers
* Fixed libopie.pro to include the new pim-API.
* The SQL-Stuff is currently deactivated. Otherwise everyone who wants to
* compile itself would need to install libsqlite, libopiesql...
* Therefore, the backend currently uses XML only..
*
* Revision 1.1 2002/10/07 17:35:01 eilers
* added OBackendFactory for advanced backend access
*
*
* =====================================================================
*/
-#ifndef __OPIE_BACKENDFACTORY_H_
-#define __OPIE_BACKENDFACTORY_H_
+#ifndef OPIE_BACKENDFACTORY_H_
+#define OPIE_BACKENDFACTORY_H_
#include <qstring.h>
#include <qasciidict.h>
#include <qpe/config.h>
#include "otodoaccessxml.h"
#include "ocontactaccessbackend_xml.h"
-#ifdef __USE_SQL
+/*#ifdef __USE_SQL
#include "otodoaccesssql.h"
#endif
+*/
template<class T>
class OBackendFactory
{
public:
OBackendFactory() {};
@@ -69,19 +77,19 @@ class OBackendFactory
qWarning ("TODO is: %d", TODO);
qWarning ("CONTACT is: %d", CONTACT);
switch ( *dict.take( backendName ) ){
case TODO:
-#ifdef __USE_SQL
+/*#ifdef __USE_SQL
if ( backend == "sql" )
return (T*) new OTodoAccessBackendSQL("");
-#else
+#else*/
if ( backend == "sql" )
qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!");
-#endif
+//#endif
return (T*) new OTodoAccessXML( appName );
case CONTACT:
if ( backend == "sql" )
qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!");
diff --git a/libopie2/opiepim/backend/opimaccessbackend.h b/libopie2/opiepim/backend/opimaccessbackend.h
index c27acbb..27d3cb8 100644
--- a/libopie2/opiepim/backend/opimaccessbackend.h
+++ b/libopie2/opiepim/backend/opimaccessbackend.h
@@ -1,11 +1,12 @@
#ifndef OPIE_PIM_ACCESS_BACKEND
#define OPIE_PIM_ACCESS_BACKEND
#include <qarray.h>
+#include <opie/otemplatebase.h>
#include <opie/opimrecord.h>
/**
* OPimAccessBackend is the base class
* for all private backends
@@ -14,12 +15,13 @@
* the resource the implementation takes care
* of
*/
template <class T = OPimRecord>
class OPimAccessBackend {
public:
+ typedef OTemplateBase<T> Frontend;
OPimAccessBackend();
virtual ~OPimAccessBackend();
/**
* load the resource
*/
@@ -51,12 +53,14 @@ public:
/**
* find the OPimRecord with uid @param uid
* returns T and T.isEmpty() if nothing was found
*/
virtual T find(int uid )const = 0;
+ virtual T find(int uid, const QArray<int>& items,
+ uint current, Frontend::CacheDirection )const ;
/**
* clear the back end
*/
virtual void clear() = 0;
/**
@@ -71,19 +75,53 @@ public:
/**
* replace a record with T.uid()
*/
virtual bool replace( const T& t ) = 0;
+ /*
+ * setTheFrontEnd!!!
+ */
+ void setFrontend( Frontend* front );
+
+protected:
+ void cache( const T& t )const;
+
+ /**
+ * use a prime number here!
+ */
+ void setSaneCacheSize( int );
+
+private:
+ Frontend* m_front;
};
template <class T>
OPimAccessBackend<T>::OPimAccessBackend() {
-
+ m_front = 0l;
}
template <class T>
OPimAccessBackend<T>::~OPimAccessBackend() {
}
+template <class T>
+void OPimAccessBackend<T>::setFrontend( Frontend* fr ) {
+ m_front = fr;
+}
+template <class T>
+void OPimAccessBackend<T>::cache( const T& t )const {
+ if (m_front )
+ m_front->cache( t );
+}
+template <class T>
+void OPimAccessBackend<T>::setSaneCacheSize( int size) {
+ if (m_front )
+ m_front->setSaneCacheSize( size );
+}
+template <class T>
+T OPimAccessBackend<T>::find( int uid, const QArray<int>&,
+ uint, Frontend::CacheDirection )const {
+ return find( uid );
+}
#endif