From 2c398e382bf015eb4cf7302e5d79ed63f476be3a Mon Sep 17 00:00:00 2001 From: zecke Date: Sun, 22 Sep 2002 16:40:04 +0000 Subject: Ok now it compiles again... heureka I had to create templatebase so orecordlist and opimaccesstemplate do not have circular dependency otherwise just compile fixes to my templaes and i did not make them inline --- (limited to 'libopie2/opiepim/core') diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h index f2a241d..e0708e1 100644 --- a/libopie2/opiepim/core/opimaccesstemplate.h +++ b/libopie2/opiepim/core/opimaccesstemplate.h @@ -7,76 +7,112 @@ #include #include +#include "otemplatebase.h" + template -class OPimAccessTemplate { +class OPimAccessTemplate : public OTemplateBase { public: typedef ORecordList List; typedef OPimAccessBackend BackEnd; - OPimAccessTemplate( BackEnd* end) - : m_backEnd( end ) { - } - ~OPimAccessTemplate() { - delete m_backEnd; - } - virtual void load() { - m_backEnd->load(); - } - virtual void reload() { - m_backEnd->reload(); - } - virtual void save() { - m_backEnd->save(); - } + OPimAccessTemplate( BackEnd* end); + virtual ~OPimAccessTemplate(); + virtual void load(); + virtual void reload(); + virtual void save(); /* *do array to Records conversion * QArray ids */ - virtual List allRecords()const { - QArray ints = m_backEnd->allRecords(); - - List lis( ints, this ); - return lis; - } - virtual List queryByExample( const T& t, int sortOrder ) { - QArray ints = m_backEnd->query( t, sortOrder ); - List lis( ints, this ); - - return lis; - } - /* implement QCache here */ - virtual T find( int uid ) { - T t = m_backEnd->find( uid ); - return t; - } + virtual List allRecords()const; + virtual List queryByExample( const T& t, int sortOrder ); + virtual T find( int uid ); /* invalidate cache here */ - virtual void clear() { - invalidateCache(); - m_backEnd->clear(); - } - virtual bool add( const T& t ) { - return m_backEnd->add( t ); - } + virtual void clear() ; + virtual bool add( const T& t ) ; /* only the uid matters */ - virtual bool remove( const T& t ) { - /* remove from cache */ - return m_backEnd->remove( t.uid() ); - } - virtual bool remove( int uid ) { - /* remove from cache */ - return m_backEnd->remove(uid); - } - virtual bool replace( const T& t) { - return m_backEnd->replace( t ); - } + virtual bool remove( const T& t ); + virtual bool remove( int uid ); + virtual bool replace( const T& t) ; protected: - void invalidateCache() { - - } + void invalidateCache(); + BackEnd* backEnd(); BackEnd* m_backEnd; }; +template +OPimAccessTemplate::OPimAccessTemplate( BackEnd* end ) + : OTemplateBase(), m_backEnd( end ) +{ + +} +template +OPimAccessTemplate::~OPimAccessTemplate() { + qWarning("~OPimAccessTemplate"); + delete m_backEnd; +} +template +void OPimAccessTemplate::load() { + m_backEnd->load(); +} +template +void OPimAccessTemplate::reload() { + m_backEnd->reload(); +} +template +void OPimAccessTemplate::save() { + m_backEnd->save(); +} +template +OPimAccessTemplate::List OPimAccessTemplate::allRecords()const { + QArray ints = m_backEnd->allRecords(); + List lis(ints, this ); + return lis; +} +template +OPimAccessTemplate::List +OPimAccessTemplate::queryByExample( const T& t, int sortOrder ) { + QArray ints = m_backEnd->queryByExample( t, sortOrder ); + + List lis(ints, this ); + return lis; +} +template +T OPimAccessTemplate::find( int uid ) { + T t = m_backEnd->find( uid ); + return t; +} +template +void OPimAccessTemplate::clear() { + invalidateCache(); + m_backEnd->clear(); +} +template +bool OPimAccessTemplate::add( const T& t ) { + return m_backEnd->add( t ); +} +template +bool OPimAccessTemplate::remove( const T& t ) { + return m_backEnd->remove( t.uid() ); +} +template +bool OPimAccessTemplate::remove( int uid ) { + return m_backEnd->remove( uid ); +} +template +bool OPimAccessTemplate::replace( const T& t ) { + return m_backEnd->replace( t ); +} +template +void OPimAccessTemplate::invalidateCache() { + +} +template +OPimAccessTemplate::BackEnd* OPimAccessTemplate::backEnd() { + return m_backEnd; +} + #endif diff --git a/libopie2/opiepim/core/opimrecord.cpp b/libopie2/opiepim/core/opimrecord.cpp index 88b6fde..60cdbf3 100644 --- a/libopie2/opiepim/core/opimrecord.cpp +++ b/libopie2/opiepim/core/opimrecord.cpp @@ -3,6 +3,9 @@ #include "opimrecord.h" +Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); + + OPimRecord::OPimRecord( int uid ) : Qtopia::Record() { @@ -125,3 +128,6 @@ void OPimRecord::setUid( int uid ) { Qtopia::Record::setUid( uid ); }; +Qtopia::UidGen &OPimRecord::uidGen() { + return m_uidGen; +} diff --git a/libopie2/opiepim/core/opimrecord.h b/libopie2/opiepim/core/opimrecord.h index 297ff12..e4d33d6 100644 --- a/libopie2/opiepim/core/opimrecord.h +++ b/libopie2/opiepim/core/opimrecord.h @@ -104,12 +104,14 @@ public: virtual void setUid( int uid ); protected: + Qtopia::UidGen &uidGen(); QString crossToString()const; private: class OPimRecordPrivate; OPimRecordPrivate *d; QMap > m_relations; + static Qtopia::UidGen m_uidGen; }; diff --git a/libopie2/opiepim/core/otemplatebase.h b/libopie2/opiepim/core/otemplatebase.h new file mode 100644 index 0000000..41cc934 --- a/dev/null +++ b/libopie2/opiepim/core/otemplatebase.h @@ -0,0 +1,18 @@ +#ifndef OPIE_TEMPLATE_BASE_H +#define OPIE_TEMPLATE_BASE_H + +#include "opimrecord.h" + +template +class OTemplateBase { +public: + OTemplateBase() { + }; + virtual ~OTemplateBase() { + } + virtual T find( int uid ) = 0; + +}; + + +#endif -- cgit v0.9.0.2