libopie PIM API Documentation

otemplatebase.h

Go to the documentation of this file.
00001 #ifndef OPIE_TEMPLATE_BASE_H
00002 #define OPIE_TEMPLATE_BASE_H
00003 
00004 #include <qarray.h>
00005 
00006 #include <opie/opimrecord.h>
00007 
00008 
00017 class OPimBasePrivate;
00018 struct OPimBase {
00022     virtual int rtti()= 0;
00023     virtual OPimRecord* record()const = 0;
00024     virtual OPimRecord* record(int uid)const = 0;
00025     virtual bool add( const OPimRecord& ) = 0;
00026     virtual bool remove( int uid ) = 0;
00027     virtual bool remove( const OPimRecord& ) = 0;
00028     virtual void clear() = 0;
00029     virtual bool load() = 0;
00030     virtual bool save() = 0;
00031     virtual QArray<int> records()const = 0;
00032     /*
00033      * ADD editing here?
00034      * -zecke
00035      */
00036 private:
00037     OPimBasePrivate* d;     
00038 
00039 };
00044 class OTemplateBasePrivate;
00045 template <class T = OPimRecord>
00046 class OTemplateBase : public OPimBase {
00047 public:
00048     enum CacheDirection { Forward=0, Reverse };
00049     OTemplateBase() {
00050     };
00051     virtual ~OTemplateBase() {
00052     }
00053     virtual T find( int uid )const = 0;
00054 
00058     virtual T find( int uid, const QArray<int>& items,
00059                     uint current, CacheDirection dir = Forward )const = 0;
00060     virtual void cache( const T& )const = 0;
00061     virtual void setSaneCacheSize( int ) = 0;
00062 
00063     /* reimplement of OPimBase */
00064     int rtti();
00065     OPimRecord* record()const;
00066     OPimRecord* record(int uid )const;
00067     static T* rec();
00068     
00069 private:
00070     OTemplateBasePrivate *d;    
00071 };
00072 
00073 /*
00074  * implementation
00075  */
00076 template <class T>
00077 int
00078 OTemplateBase<T>::rtti() {
00079     return T::rtti();
00080 }
00081 template <class T>
00082 OPimRecord* OTemplateBase<T>::record()const {
00083     T* t = new T;
00084     return t;
00085 }
00086 template <class T>
00087 OPimRecord* OTemplateBase<T>::record(int uid )const {
00088     T  t2 = find(uid );
00089     T* t1 = new T(t2);
00090 
00091     return t1;
00092 };
00093 template <class T>
00094 T* OTemplateBase<T>::rec() {
00095     return new T;
00096 }
00097 
00098 #endif
KDE Logo
This file is part of the documentation for OPIE Version 1.1.
Documentation copyright © 1997-2003 the KDE developers. 2003 OPIE developers
Generated on Tue Feb 10 20:25:21 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001