summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/orecordlist.h
authorzecke <zecke>2002-10-10 17:08:58 (UTC)
committer zecke <zecke>2002-10-10 17:08:58 (UTC)
commit1dcc1b1fc9fd35d959255452c8b5be1269ca4f44 (patch) (side-by-side diff)
tree469d239dec74f5751f3aced43c4bae1f0f3a42e3 /libopie2/opiepim/orecordlist.h
parentaa38f642a07810515dcc18ea38bf520e26d7f88e (diff)
downloadopie-1dcc1b1fc9fd35d959255452c8b5be1269ca4f44.zip
opie-1dcc1b1fc9fd35d959255452c8b5be1269ca4f44.tar.gz
opie-1dcc1b1fc9fd35d959255452c8b5be1269ca4f44.tar.bz2
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
Diffstat (limited to 'libopie2/opiepim/orecordlist.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/orecordlist.h20
1 files changed, 13 insertions, 7 deletions
diff --git a/libopie2/opiepim/orecordlist.h b/libopie2/opiepim/orecordlist.h
index b6fa7fa..08f5c85 100644
--- a/libopie2/opiepim/orecordlist.h
+++ b/libopie2/opiepim/orecordlist.h
@@ -59,24 +59,25 @@ public:
/**
* sets the current item
*/
void setCurrent( uint cur );
private:
QArray<int> m_uids;
uint m_current;
const Base* m_temp;
bool m_end : 1;
T m_record;
+ bool m_direction :1;
/* d pointer for future versions */
class IteratorPrivate;
IteratorPrivate *d;
};
/**
* The recordlist used as a return type
* from OPimAccessTemplate
*/
template <class T = OPimRecord >
class ORecordList {
public:
@@ -116,78 +117,81 @@ public:
private:
QArray<int> m_ids;
const Base* m_acc;
};
/* ok now implement it */
template <class T>
ORecordListIterator<T>::ORecordListIterator() {
m_current = 0;
m_temp = 0l;
m_end = true;
m_record = T();
+ /* forward */
+ m_direction = TRUE;
}
template <class T>
ORecordListIterator<T>::~ORecordListIterator() {
/* nothing to delete */
}
template <class T>
ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) {
// qWarning("ORecordListIterator copy c'tor");
m_uids = it.m_uids;
m_current = it.m_current;
m_temp = it.m_temp;
m_end = it.m_end;
m_record = it.m_record;
+ m_direction = it.m_direction;
}
template <class T>
ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) {
m_uids = it.m_uids;
m_current = it.m_current;
m_temp = it.m_temp;
m_end = it.m_end;
m_record = it.m_record;
return *this;
}
template <class T>
T ORecordListIterator<T>::operator*() {
qWarning("operator* %d %d", m_current, m_uids[m_current] );
if (!m_end )
- /* FIXME
- * until the cache is in place
- * we do the uid match uid check
- */
- m_record = m_temp->find( m_uids[m_current] );
+ m_record = m_temp->find( m_uids[m_current], m_uids, m_current,
+ m_direction ? Base::Forward :
+ Base::Reverse );
else
m_record = T();
return m_record;
}
template <class T>
ORecordListIterator<T> &ORecordListIterator<T>::operator++() {
+ m_direction = true;
if (m_current < m_uids.count() ) {
m_end = false;
++m_current;
}else
m_end = true;
return *this;
}
template <class T>
ORecordListIterator<T> &ORecordListIterator<T>::operator--() {
+ m_direction = false;
if ( m_current > 0 ) {
--m_current;
m_end = false;
} else
m_end = true;
return *this;
}
template <class T>
bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) {
@@ -198,25 +202,26 @@ bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) {
if ( m_current != it.m_current ) return false;
if ( m_temp != it.m_temp ) return false;
return true;
}
template <class T>
bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) {
return !(*this == it );
}
template <class T>
ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids,
const Base* t )
- : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false )
+ : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ),
+ m_direction( false )
{
}
template <class T>
uint ORecordListIterator<T>::current()const {
return m_current;
}
template <class T>
void ORecordListIterator<T>::setCurrent( uint cur ) {
if( cur < m_uids.count() ) {
m_end = false;
m_current= cur;
}
@@ -245,15 +250,16 @@ ORecordList<T>::Iterator ORecordList<T>::end() {
Iterator it( m_ids, m_acc );
it.m_end = true;
it.m_current = m_ids.count();
return it;
}
template <class T>
uint ORecordList<T>::count()const {
return m_ids.count();
}
template <class T>
T ORecordList<T>::operator[]( uint i ) {
- return m_acc->find( m_ids[i] );
+ /* forward */
+ return m_acc->find( m_ids[i], m_ids, i );
}
#endif