author | zecke <zecke> | 2002-09-21 15:02:50 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-09-21 15:02:50 (UTC) |
commit | e6c53c4d7317e766235449535b22d0d2fe709214 (patch) (unidiff) | |
tree | c210c639611acd5aa3c1863451fb4e31ac3af29a /libopie/pim/orecordlist.h | |
parent | fe0806def8ec79815832193fe402c75361108622 (diff) | |
download | opie-e6c53c4d7317e766235449535b22d0d2fe709214.zip opie-e6c53c4d7317e766235449535b22d0d2fe709214.tar.gz opie-e6c53c4d7317e766235449535b22d0d2fe709214.tar.bz2 |
Some more implementation
in OPimRecord::setUid
ORecordList implemented never compiled it though
OTodo a new c'tor and some more changes
-rw-r--r-- | libopie/pim/orecordlist.h | 139 |
1 files changed, 127 insertions, 12 deletions
diff --git a/libopie/pim/orecordlist.h b/libopie/pim/orecordlist.h index c17186f..65c2169 100644 --- a/libopie/pim/orecordlist.h +++ b/libopie/pim/orecordlist.h | |||
@@ -11,25 +11,34 @@ public: | |||
11 | class Iterator { | 11 | class Iterator { |
12 | friend class ORecordList; | 12 | friend class ORecordList; |
13 | public: | 13 | public: |
14 | Iterator() {} | 14 | Iterator(); |
15 | ~Iterator() {} | 15 | ~Iterator(); |
16 | Iterator(const Iterator& ) {} | 16 | Iterator(const Iterator& ); |
17 | Iterator &operator=(const Iterator& ); | 17 | Iterator &operator=(const Iterator& ); |
18 | T &operator*() {} | 18 | T &operator*(); |
19 | Iterator &operator++(); | 19 | Iterator &operator++(); |
20 | Iterator &operator--(); | ||
20 | 21 | ||
21 | bool operator==( const Iterator& it ); | 22 | bool operator==( const Iterator& it ); |
22 | bool operator!=( const Iterator& it ); | 23 | bool operator!=( const Iterator& it ); |
23 | 24 | ||
24 | } | 25 | private: |
25 | ORecordList( const QArray<int>& ids, | 26 | Iterator( const QArray<int>, |
26 | OPimAccessTemplate<T>* acc ) | 27 | OPimAccessTemplate<T>* ); |
27 | : m_ids(ids ), m_acc( acc ) { | ||
28 | 28 | ||
29 | } | 29 | QArray<int> m_uids; |
30 | ~ORecordList() { | 30 | int m_current; |
31 | OPimAccessTemplate* m_temp; | ||
32 | bool m_end : 1; | ||
33 | T m_record; | ||
31 | 34 | ||
32 | } | 35 | /* d pointer for future versions */ |
36 | class IteratorPrivate; | ||
37 | IteratorPrivate *d; | ||
38 | }; | ||
39 | ORecordList( const QArray<int>& ids, | ||
40 | OPimAccessTemplate<T>* acc ); | ||
41 | ~ORecordList(); | ||
33 | Iterator begin(); | 42 | Iterator begin(); |
34 | Iterator end(); | 43 | Iterator end(); |
35 | /* | 44 | /* |
@@ -37,8 +46,114 @@ public: | |||
37 | ConstIterator end()const; | 46 | ConstIterator end()const; |
38 | */ | 47 | */ |
39 | private: | 48 | private: |
40 | QArray<int> ids; | 49 | QArray<int> m_ids; |
41 | OPimAccessTemplate<T>* m_acc; | 50 | OPimAccessTemplate<T>* m_acc; |
42 | }; | 51 | }; |
43 | 52 | ||
53 | /* ok now implement it */ | ||
54 | template <class T= OPimRecord> | ||
55 | ORecordList<T>::Iterator::Iterator() { | ||
56 | m_current = 0; | ||
57 | m_temp = 0l; | ||
58 | m_end = true; | ||
59 | } | ||
60 | template <class T= OPimRecord> | ||
61 | ORecordList<T>::Iterator::~Iterator() { | ||
62 | /* nothing to delete */ | ||
63 | } | ||
64 | |||
65 | template <class T = OPimRecord> | ||
66 | ORecordList<T>::Iterator::Iterator( const ORecordList<T>::Iterator& it) { | ||
67 | m_uids = it.m_uids; | ||
68 | m_current = it.m_current; | ||
69 | m_temp = it.m_temp; | ||
70 | m_end = it.m_end; | ||
71 | m_record = it.m_record; | ||
72 | } | ||
73 | |||
74 | template <class T = OPimRecord> | ||
75 | ORecordList<T>::Iterator &ORecordList::Iterator::operator=( const ORecordList<T>::Iterator& it) { | ||
76 | m_uids = it.m_uids; | ||
77 | m_current = it.m_current; | ||
78 | m_temp = it.m_temp; | ||
79 | m_end = it.m_end; | ||
80 | m_record = it.m_record; | ||
81 | |||
82 | return *this; | ||
83 | } | ||
84 | |||
85 | template <class T = OPimRecord> | ||
86 | T &ORecordList<T>::Iterator::operator*() { | ||
87 | if (!m_end ) | ||
88 | m_record = m_temp->find( m_uids[m_current] ); | ||
89 | else | ||
90 | m_record = T; | ||
91 | |||
92 | return m_record; | ||
93 | } | ||
94 | |||
95 | template <class T = OPimRecord> | ||
96 | ORecordList<T>::Iterator &ORecordList<T>::Iterator::operator++() { | ||
97 | if (m_current < m_uids.count() ) { | ||
98 | m_end = false; | ||
99 | ++m_current; | ||
100 | }else | ||
101 | m_end = true; | ||
102 | |||
103 | return *this; | ||
104 | } | ||
105 | template <class T = OPimRecord> | ||
106 | ORecordList<T>::Iterator &ORecordList<T>::Iterator::operator--() { | ||
107 | if ( m_current > 0 ) { | ||
108 | --m_current; | ||
109 | m_end = false; | ||
110 | } else | ||
111 | m_end = true; | ||
112 | |||
113 | return *this; | ||
114 | } | ||
115 | |||
116 | template <class T = OPimRecord> | ||
117 | bool ORecordList<T>::Iterator::operator==( const ORecordList<T>::Iterator& it ) { | ||
118 | |||
119 | /* if both are at we're the same.... */ | ||
120 | if ( m_end == it.m_end ) return true; | ||
121 | |||
122 | if ( m_uids != it.m_uids ) return false; | ||
123 | if ( m_current != it.m_current ) return false; | ||
124 | if ( m_temp != it.m_temp ) return false; | ||
125 | |||
126 | return true; | ||
127 | } | ||
128 | template <class T = ORecordList> | ||
129 | bool ORecordList<T>::Iterator::operator!=( const ORecordList<T>::Iterator it ) { | ||
130 | return !(*this == it ); | ||
131 | } | ||
132 | template <class T = ORecordList> | ||
133 | ORecordList<T>::Iterator::Iterator( const QArray<int> uids, | ||
134 | OPimAccessTemplate<T>* t ) | ||
135 | : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ) | ||
136 | { | ||
137 | } | ||
138 | template <class T = ORecordList> | ||
139 | ORecordList<T>::ORecordList( const QArray<int>& ids, | ||
140 | OPimAccessTemplate<T>* acc ) | ||
141 | : m_ids( ids ), m_acc( acc ) | ||
142 | { | ||
143 | } | ||
144 | template <class T = ORecordList> | ||
145 | ORecordList<T>::~ORecordList() { | ||
146 | /* nothing to do here */ | ||
147 | } | ||
148 | template <class T = ORecordList> | ||
149 | ORecordList<T>::Iterator ORecordList<T>::begin() { | ||
150 | Iterator it( m_ids, m_acc ); | ||
151 | return it; | ||
152 | } | ||
153 | template <class T = ORecordList> | ||
154 | ORecordList<T>::Iterator ORecordList<T>::end() { | ||
155 | Iterator it( m_ids, m_acc ); | ||
156 | it.m_end = true; | ||
157 | it.m_current = m_ids.count(); | ||
158 | } | ||
44 | #endif | 159 | #endif |