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 'libopie/pim/orecordlist.h') diff --git a/libopie/pim/orecordlist.h b/libopie/pim/orecordlist.h index 65c2169..a3955b0 100644 --- a/libopie/pim/orecordlist.h +++ b/libopie/pim/orecordlist.h @@ -2,42 +2,47 @@ #ifndef OPIE_RECORD_LIST_H #define OPIE_RECORD_LIST_H -#include -#include +#include + +#include "otemplatebase.h" +#include "opimrecord.h" + + +template +class ORecordListIterator { +public: + typedef OTemplateBase Base; + ORecordListIterator( const QArray, const Base* ); + ORecordListIterator(); + ~ORecordListIterator(); + ORecordListIterator( const ORecordListIterator& ); + ORecordListIterator &operator=(const ORecordListIterator& ); + T &operator*(); + ORecordListIterator &operator++(); + ORecordListIterator &operator--(); + + bool operator==( const ORecordListIterator& it ); + bool operator!=( const ORecordListIterator& it ); + +private: + QArray m_uids; + int m_current; + const Base* m_temp; + bool m_end : 1; + T m_record; + + /* d pointer for future versions */ + class IteratorPrivate; + IteratorPrivate *d; +}; template class ORecordList { public: - class Iterator { - friend class ORecordList; - public: - Iterator(); - ~Iterator(); - Iterator(const Iterator& ); - Iterator &operator=(const Iterator& ); - T &operator*(); - Iterator &operator++(); - Iterator &operator--(); - - bool operator==( const Iterator& it ); - bool operator!=( const Iterator& it ); - - private: - Iterator( const QArray, - OPimAccessTemplate* ); - - QArray m_uids; - int m_current; - OPimAccessTemplate* m_temp; - bool m_end : 1; - T m_record; - - /* d pointer for future versions */ - class IteratorPrivate; - IteratorPrivate *d; - }; + typedef OTemplateBase Base; + typedef ORecordListIterator Iterator; ORecordList( const QArray& ids, - OPimAccessTemplate* acc ); + const Base* ); ~ORecordList(); Iterator begin(); Iterator end(); @@ -47,23 +52,23 @@ public: */ private: QArray m_ids; - OPimAccessTemplate* m_acc; + const Base* m_acc; }; /* ok now implement it */ -template -ORecordList::Iterator::Iterator() { +template +ORecordListIterator::ORecordListIterator() { m_current = 0; m_temp = 0l; m_end = true; } -template -ORecordList::Iterator::~Iterator() { +template +ORecordListIterator::~ORecordListIterator() { /* nothing to delete */ } -template -ORecordList::Iterator::Iterator( const ORecordList::Iterator& it) { +template +ORecordListIterator::ORecordListIterator( const ORecordListIterator& it) { m_uids = it.m_uids; m_current = it.m_current; m_temp = it.m_temp; @@ -71,8 +76,8 @@ ORecordList::Iterator::Iterator( const ORecordList::Iterator& it) { m_record = it.m_record; } -template -ORecordList::Iterator &ORecordList::Iterator::operator=( const ORecordList::Iterator& it) { +template +ORecordListIterator &ORecordListIterator::operator=( const ORecordListIterator& it) { m_uids = it.m_uids; m_current = it.m_current; m_temp = it.m_temp; @@ -82,18 +87,18 @@ ORecordList::Iterator &ORecordList::Iterator::operator=( const ORecordList return *this; } -template -T &ORecordList::Iterator::operator*() { +template +T &ORecordListIterator::operator*() { if (!m_end ) m_record = m_temp->find( m_uids[m_current] ); else - m_record = T; + m_record = T(); return m_record; } -template -ORecordList::Iterator &ORecordList::Iterator::operator++() { +template +ORecordListIterator &ORecordListIterator::operator++() { if (m_current < m_uids.count() ) { m_end = false; ++m_current; @@ -102,8 +107,8 @@ ORecordList::Iterator &ORecordList::Iterator::operator++() { return *this; } -template -ORecordList::Iterator &ORecordList::Iterator::operator--() { +template +ORecordListIterator &ORecordListIterator::operator--() { if ( m_current > 0 ) { --m_current; m_end = false; @@ -113,8 +118,8 @@ ORecordList::Iterator &ORecordList::Iterator::operator--() { return *this; } -template -bool ORecordList::Iterator::operator==( const ORecordList::Iterator& it ) { +template +bool ORecordListIterator::operator==( const ORecordListIterator& it ) { /* if both are at we're the same.... */ if ( m_end == it.m_end ) return true; @@ -125,32 +130,33 @@ bool ORecordList::Iterator::operator==( const ORecordList::Iterator& it ) return true; } -template -bool ORecordList::Iterator::operator!=( const ORecordList::Iterator it ) { +template +bool ORecordListIterator::operator!=( const ORecordListIterator& it ) { return !(*this == it ); } -template -ORecordList::Iterator::Iterator( const QArray uids, - OPimAccessTemplate* t ) +template +ORecordListIterator::ORecordListIterator( const QArray uids, + const Base* t ) : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ) { } -template + +template ORecordList::ORecordList( const QArray& ids, - OPimAccessTemplate* acc ) + const Base* acc ) : m_ids( ids ), m_acc( acc ) { } -template +template ORecordList::~ORecordList() { /* nothing to do here */ } -template +template ORecordList::Iterator ORecordList::begin() { Iterator it( m_ids, m_acc ); return it; } -template +template ORecordList::Iterator ORecordList::end() { Iterator it( m_ids, m_acc ); it.m_end = true; -- cgit v0.9.0.2