summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/orecordlist.h
authorzecke <zecke>2002-09-22 16:40:04 (UTC)
committer zecke <zecke>2002-09-22 16:40:04 (UTC)
commit2c398e382bf015eb4cf7302e5d79ed63f476be3a (patch) (unidiff)
treeeb446c641471a39d08159e058038cc1eb0d9d5b3 /libopie2/opiepim/orecordlist.h
parentc15b90cb32a27ece63620be60f96959f2ee6f492 (diff)
downloadopie-2c398e382bf015eb4cf7302e5d79ed63f476be3a.zip
opie-2c398e382bf015eb4cf7302e5d79ed63f476be3a.tar.gz
opie-2c398e382bf015eb4cf7302e5d79ed63f476be3a.tar.bz2
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
Diffstat (limited to 'libopie2/opiepim/orecordlist.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/orecordlist.h124
1 files changed, 65 insertions, 59 deletions
diff --git a/libopie2/opiepim/orecordlist.h b/libopie2/opiepim/orecordlist.h
index 65c2169..a3955b0 100644
--- a/libopie2/opiepim/orecordlist.h
+++ b/libopie2/opiepim/orecordlist.h
@@ -2,42 +2,47 @@
2#ifndef OPIE_RECORD_LIST_H 2#ifndef OPIE_RECORD_LIST_H
3#define OPIE_RECORD_LIST_H 3#define OPIE_RECORD_LIST_H
4 4
5#include <opie/opimaccesstemplate.h> 5#include <qarray.h>
6#include <opie/opimrecord.h> 6
7#include "otemplatebase.h"
8#include "opimrecord.h"
9
10
11template <class T = OPimRecord>
12class ORecordListIterator {
13public:
14 typedef OTemplateBase<T> Base;
15 ORecordListIterator( const QArray<int>, const Base* );
16 ORecordListIterator();
17 ~ORecordListIterator();
18 ORecordListIterator( const ORecordListIterator& );
19 ORecordListIterator &operator=(const ORecordListIterator& );
20 T &operator*();
21 ORecordListIterator &operator++();
22 ORecordListIterator &operator--();
23
24 bool operator==( const ORecordListIterator& it );
25 bool operator!=( const ORecordListIterator& it );
26
27private:
28 QArray<int> m_uids;
29 int m_current;
30 const Base* m_temp;
31 bool m_end : 1;
32 T m_record;
33
34 /* d pointer for future versions */
35 class IteratorPrivate;
36 IteratorPrivate *d;
37};
7 38
8template <class T = OPimRecord > 39template <class T = OPimRecord >
9class ORecordList { 40class ORecordList {
10public: 41public:
11 class Iterator { 42 typedef OTemplateBase<T> Base;
12 friend class ORecordList; 43 typedef ORecordListIterator<T> Iterator;
13 public:
14 Iterator();
15 ~Iterator();
16 Iterator(const Iterator& );
17 Iterator &operator=(const Iterator& );
18 T &operator*();
19 Iterator &operator++();
20 Iterator &operator--();
21
22 bool operator==( const Iterator& it );
23 bool operator!=( const Iterator& it );
24
25 private:
26 Iterator( const QArray<int>,
27 OPimAccessTemplate<T>* );
28
29 QArray<int> m_uids;
30 int m_current;
31 OPimAccessTemplate* m_temp;
32 bool m_end : 1;
33 T m_record;
34
35 /* d pointer for future versions */
36 class IteratorPrivate;
37 IteratorPrivate *d;
38 };
39 ORecordList( const QArray<int>& ids, 44 ORecordList( const QArray<int>& ids,
40 OPimAccessTemplate<T>* acc ); 45 const Base* );
41 ~ORecordList(); 46 ~ORecordList();
42 Iterator begin(); 47 Iterator begin();
43 Iterator end(); 48 Iterator end();
@@ -47,23 +52,23 @@ public:
47 */ 52 */
48private: 53private:
49 QArray<int> m_ids; 54 QArray<int> m_ids;
50 OPimAccessTemplate<T>* m_acc; 55 const Base* m_acc;
51}; 56};
52 57
53/* ok now implement it */ 58/* ok now implement it */
54template <class T= OPimRecord> 59template <class T>
55ORecordList<T>::Iterator::Iterator() { 60ORecordListIterator<T>::ORecordListIterator() {
56 m_current = 0; 61 m_current = 0;
57 m_temp = 0l; 62 m_temp = 0l;
58 m_end = true; 63 m_end = true;
59} 64}
60template <class T= OPimRecord> 65template <class T>
61ORecordList<T>::Iterator::~Iterator() { 66ORecordListIterator<T>::~ORecordListIterator() {
62/* nothing to delete */ 67/* nothing to delete */
63} 68}
64 69
65template <class T = OPimRecord> 70template <class T>
66ORecordList<T>::Iterator::Iterator( const ORecordList<T>::Iterator& it) { 71ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) {
67 m_uids = it.m_uids; 72 m_uids = it.m_uids;
68 m_current = it.m_current; 73 m_current = it.m_current;
69 m_temp = it.m_temp; 74 m_temp = it.m_temp;
@@ -71,8 +76,8 @@ ORecordList<T>::Iterator::Iterator( const ORecordList<T>::Iterator& it) {
71 m_record = it.m_record; 76 m_record = it.m_record;
72} 77}
73 78
74template <class T = OPimRecord> 79template <class T>
75ORecordList<T>::Iterator &ORecordList::Iterator::operator=( const ORecordList<T>::Iterator& it) { 80ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) {
76 m_uids = it.m_uids; 81 m_uids = it.m_uids;
77 m_current = it.m_current; 82 m_current = it.m_current;
78 m_temp = it.m_temp; 83 m_temp = it.m_temp;
@@ -82,18 +87,18 @@ ORecordList<T>::Iterator &ORecordList::Iterator::operator=( const ORecordList<T>
82 return *this; 87 return *this;
83} 88}
84 89
85template <class T = OPimRecord> 90template <class T>
86T &ORecordList<T>::Iterator::operator*() { 91T &ORecordListIterator<T>::operator*() {
87 if (!m_end ) 92 if (!m_end )
88 m_record = m_temp->find( m_uids[m_current] ); 93 m_record = m_temp->find( m_uids[m_current] );
89 else 94 else
90 m_record = T; 95 m_record = T();
91 96
92 return m_record; 97 return m_record;
93} 98}
94 99
95template <class T = OPimRecord> 100template <class T>
96ORecordList<T>::Iterator &ORecordList<T>::Iterator::operator++() { 101ORecordListIterator<T> &ORecordListIterator<T>::operator++() {
97 if (m_current < m_uids.count() ) { 102 if (m_current < m_uids.count() ) {
98 m_end = false; 103 m_end = false;
99 ++m_current; 104 ++m_current;
@@ -102,8 +107,8 @@ ORecordList<T>::Iterator &ORecordList<T>::Iterator::operator++() {
102 107
103 return *this; 108 return *this;
104} 109}
105template <class T = OPimRecord> 110template <class T>
106ORecordList<T>::Iterator &ORecordList<T>::Iterator::operator--() { 111ORecordListIterator<T> &ORecordListIterator<T>::operator--() {
107 if ( m_current > 0 ) { 112 if ( m_current > 0 ) {
108 --m_current; 113 --m_current;
109 m_end = false; 114 m_end = false;
@@ -113,8 +118,8 @@ ORecordList<T>::Iterator &ORecordList<T>::Iterator::operator--() {
113 return *this; 118 return *this;
114} 119}
115 120
116template <class T = OPimRecord> 121template <class T>
117bool ORecordList<T>::Iterator::operator==( const ORecordList<T>::Iterator& it ) { 122bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) {
118 123
119 /* if both are at we're the same.... */ 124 /* if both are at we're the same.... */
120 if ( m_end == it.m_end ) return true; 125 if ( m_end == it.m_end ) return true;
@@ -125,32 +130,33 @@ bool ORecordList<T>::Iterator::operator==( const ORecordList<T>::Iterator& it )
125 130
126 return true; 131 return true;
127} 132}
128template <class T = ORecordList> 133template <class T>
129bool ORecordList<T>::Iterator::operator!=( const ORecordList<T>::Iterator it ) { 134bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) {
130 return !(*this == it ); 135 return !(*this == it );
131} 136}
132template <class T = ORecordList> 137template <class T>
133ORecordList<T>::Iterator::Iterator( const QArray<int> uids, 138ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids,
134 OPimAccessTemplate<T>* t ) 139 const Base* t )
135 : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ) 140 : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false )
136{ 141{
137} 142}
138template <class T = ORecordList> 143
144template <class T>
139ORecordList<T>::ORecordList( const QArray<int>& ids, 145ORecordList<T>::ORecordList( const QArray<int>& ids,
140 OPimAccessTemplate<T>* acc ) 146 const Base* acc )
141 : m_ids( ids ), m_acc( acc ) 147 : m_ids( ids ), m_acc( acc )
142{ 148{
143} 149}
144template <class T = ORecordList> 150template <class T>
145ORecordList<T>::~ORecordList() { 151ORecordList<T>::~ORecordList() {
146/* nothing to do here */ 152/* nothing to do here */
147} 153}
148template <class T = ORecordList> 154template <class T>
149ORecordList<T>::Iterator ORecordList<T>::begin() { 155ORecordList<T>::Iterator ORecordList<T>::begin() {
150 Iterator it( m_ids, m_acc ); 156 Iterator it( m_ids, m_acc );
151 return it; 157 return it;
152} 158}
153template <class T = ORecordList> 159template <class T>
154ORecordList<T>::Iterator ORecordList<T>::end() { 160ORecordList<T>::Iterator ORecordList<T>::end() {
155 Iterator it( m_ids, m_acc ); 161 Iterator it( m_ids, m_acc );
156 it.m_end = true; 162 it.m_end = true;