From 1dcc1b1fc9fd35d959255452c8b5be1269ca4f44 Mon Sep 17 00:00:00 2001 From: zecke Date: Thu, 10 Oct 2002 17:08:58 +0000 Subject: 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 --- (limited to 'libopie2/opiepim/backend') 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 @@ -16,6 +16,13 @@ * ===================================================================== * 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 @@ -28,8 +35,8 @@ * * ===================================================================== */ -#ifndef __OPIE_BACKENDFACTORY_H_ -#define __OPIE_BACKENDFACTORY_H_ +#ifndef OPIE_BACKENDFACTORY_H_ +#define OPIE_BACKENDFACTORY_H_ #include #include @@ -38,9 +45,10 @@ #include "otodoaccessxml.h" #include "ocontactaccessbackend_xml.h" -#ifdef __USE_SQL +/*#ifdef __USE_SQL #include "otodoaccesssql.h" #endif +*/ template class OBackendFactory @@ -72,13 +80,13 @@ class OBackendFactory 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: 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 @@ -3,6 +3,7 @@ #include +#include #include @@ -17,6 +18,7 @@ template class OPimAccessBackend { public: + typedef OTemplateBase Frontend; OPimAccessBackend(); virtual ~OPimAccessBackend(); @@ -54,6 +56,8 @@ public: */ virtual T find(int uid )const = 0; + virtual T find(int uid, const QArray& items, + uint current, Frontend::CacheDirection )const ; /** * clear the back end */ @@ -74,16 +78,50 @@ public: */ 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 OPimAccessBackend::OPimAccessBackend() { - + m_front = 0l; } template OPimAccessBackend::~OPimAccessBackend() { } +template +void OPimAccessBackend::setFrontend( Frontend* fr ) { + m_front = fr; +} +template +void OPimAccessBackend::cache( const T& t )const { + if (m_front ) + m_front->cache( t ); +} +template +void OPimAccessBackend::setSaneCacheSize( int size) { + if (m_front ) + m_front->setSaneCacheSize( size ); +} +template +T OPimAccessBackend::find( int uid, const QArray&, + uint, Frontend::CacheDirection )const { + return find( uid ); +} #endif -- cgit v0.9.0.2