xref: /aoo4110/main/autodoc/source/ary/inc/sci_impl.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef ARY_SCI_IMPL_HXX
25 #define ARY_SCI_IMPL_HXX
26 
27 
28 
29 // USED SERVICES
30     // BASE CLASSES
31 #include <ary/stdconstiter.hxx>
32     // COMPONENTS
33     // PARAMETERS
34 
35 
36 namespace ary
37 {
38 
39 
40 //*************************     SCI_Vector      **********************************//
41 
42 template <class ELEM>
43 class SCI_Vector : public StdConstIterator<ELEM>
44 {
45   public:
46     typedef std::vector<ELEM>       source;
47     typedef typename source::const_iterator source_iterator;
48 
49                         SCI_Vector(
50                             const source &      i_rSource  );
51     virtual             ~SCI_Vector();
52 
53   private:
54     // Interface StdConstIterator<>:
55     virtual void        do_Advance();
56     virtual const ELEM *
57                         inq_CurElement() const;
58     virtual bool        inq_IsSorted() const;
59 
60     // DATA
61     source_iterator     itRun;
62     source_iterator     itEnd;
63 };
64 
65 
66 
67 //*************************     SCI_Map      **********************************//
68 
69 template <class KEY, class VALUE>
70 class SCI_Map : public StdConstIterator< typename std::map<KEY,VALUE>::value_type >
71 {
72   public:
73     typedef std::map<KEY,VALUE>     source;
74     typedef typename source::const_iterator source_iterator;
75 
76                         SCI_Map(
77                             const source &      i_rSource  );
78     virtual             ~SCI_Map();
79 
80   private:
81     // Interface StdConstIterator<>:
82     virtual void        do_Advance();
83     virtual const typename std::map<KEY,VALUE>::value_type *
84                         inq_CurElement() const;
85     virtual bool        inq_IsSorted() const;
86 
87     // DATA
88     source_iterator     itRun;
89     source_iterator     itEnd;
90 };
91 
92 
93 //*************************     SCI_MultiMap      **********************************//
94 
95 template <class KEY, class VALUE>
96 class SCI_MultiMap : public StdConstIterator< typename std::multimap<KEY,VALUE>::value_type >
97 {
98   public:
99     typedef std::multimap<KEY,VALUE>    source;
100     typedef typename source::const_iterator      source_iterator;
101 
102                         SCI_MultiMap(
103                             const source &      i_rSource  );
104                         SCI_MultiMap(
105                             source_iterator     i_begin,
106                             source_iterator     i_end );
107     virtual             ~SCI_MultiMap();
108 
109   private:
110     // Interface StdConstIterator<>:
111     virtual void        do_Advance();
112     virtual const typename std::multimap<KEY,VALUE>::value_type *
113                         inq_CurElement() const;
114     virtual bool        inq_IsSorted() const;
115 
116     // DATA
117     source_iterator     itRun;
118     source_iterator     itEnd;
119 };
120 
121 
122 
123 //*************************     SCI_Set     **********************************//
124 
125 
126 template <class TYPES>
127 class SCI_Set : public StdConstIterator<typename TYPES::element_type>
128 {
129   public:
130     typedef typename TYPES::element_type    element;
131     typedef typename TYPES::sort_type       sorter;
132     typedef std::set<element, sorter>       source;
133     typedef typename source::const_iterator source_iterator;
134 
135                         SCI_Set(
136                             const source &      i_rSource  );
137     virtual             ~SCI_Set();
138 
139   private:
140     // Interface StdConstIterator<>:
141     virtual void        do_Advance();
142     virtual const element *
143                         inq_CurElement() const;
144     virtual bool        inq_IsSorted() const;
145 
146     // DATA
147     source_iterator     itRun;
148     source_iterator     itEnd;
149 };
150 
151 //*************************     SCI_DataInMap    **********************************//
152 
153 template <class KEY, class VALUE>
154 class SCI_DataInMap : public StdConstIterator<VALUE>
155 {
156   public:
157     typedef std::map<KEY,VALUE>     source;
158     typedef typename source::const_iterator  source_iterator;
159 
160                         SCI_DataInMap(
161                             const source &      i_rSource  );
162     virtual             ~SCI_DataInMap();
163 
164   private:
165     // Interface StdConstIterator<>:
166     virtual void        do_Advance();
167     virtual const VALUE *
168                         inq_CurElement() const;
169     virtual bool        inq_IsSorted() const;
170 
171     // DATA
172     source_iterator     itRun;
173     source_iterator     itEnd;
174 };
175 
176 
177 
178 
179 
180 //********************************************************************//
181 
182 
183 // IMPLEMENTATION
184 
185 template <class ELEM>
SCI_Vector(const source & i_rSource)186 SCI_Vector<ELEM>::SCI_Vector( const source & i_rSource  )
187     :   itRun(i_rSource.begin()),
188         itEnd(i_rSource.end())
189 {
190 }
191 
192 template <class ELEM>
~SCI_Vector()193 SCI_Vector<ELEM>::~SCI_Vector()
194 {
195 }
196 
197 
198 template <class ELEM>
199 void
do_Advance()200 SCI_Vector<ELEM>::do_Advance()
201 {
202     if (itRun != itEnd)
203         ++itRun;
204 }
205 
206 template <class ELEM>
207 const ELEM *
inq_CurElement() const208 SCI_Vector<ELEM>::inq_CurElement() const
209 {
210     if (itRun != itEnd)
211         return &(*itRun);
212     return 0;
213 }
214 
215 template <class ELEM>
216 bool
inq_IsSorted() const217 SCI_Vector<ELEM>::inq_IsSorted() const
218 {
219     return false;
220 }
221 
222 
223 
224 
225 template <class KEY, class VALUE>
SCI_Map(const source & i_rSource)226 SCI_Map<KEY,VALUE>::SCI_Map( const source & i_rSource  )
227     :   itRun(i_rSource.begin()),
228         itEnd(i_rSource.end())
229 {
230 }
231 
232 template <class KEY, class VALUE>
~SCI_Map()233 SCI_Map<KEY,VALUE>::~SCI_Map()
234 {
235 }
236 
237 template <class KEY, class VALUE>
238 void
do_Advance()239 SCI_Map<KEY,VALUE>::do_Advance()
240 {
241     if (itRun != itEnd)
242         ++itRun;
243 }
244 
245 template <class KEY, class VALUE>
246 const typename std::map<KEY,VALUE>::value_type *
inq_CurElement() const247 SCI_Map<KEY,VALUE>::inq_CurElement() const
248 {
249     if (itRun != itEnd)
250         return &(*itRun);
251     return 0;
252 }
253 
254 
255 template <class KEY, class VALUE>
256 bool
inq_IsSorted() const257 SCI_Map<KEY,VALUE>::inq_IsSorted() const
258 {
259     return true;
260 }
261 
262 
263 
264 
265 
266 
267 
268 template <class KEY, class VALUE>
SCI_MultiMap(const source & i_rSource)269 SCI_MultiMap<KEY,VALUE>::SCI_MultiMap( const source & i_rSource  )
270     :   itRun(i_rSource.begin()),
271         itEnd(i_rSource.end())
272 {
273 }
274 
275 template <class KEY, class VALUE>
SCI_MultiMap(source_iterator i_begin,source_iterator i_end)276 SCI_MultiMap<KEY,VALUE>::SCI_MultiMap( source_iterator i_begin,
277                                        source_iterator i_end )
278     :   itRun(i_begin),
279         itEnd(i_end)
280 {
281 }
282 
283 template <class KEY, class VALUE>
~SCI_MultiMap()284 SCI_MultiMap<KEY,VALUE>::~SCI_MultiMap()
285 {
286 }
287 
288 template <class KEY, class VALUE>
289 void
do_Advance()290 SCI_MultiMap<KEY,VALUE>::do_Advance()
291 {
292     if (itRun != itEnd)
293         ++itRun;
294 }
295 
296 template <class KEY, class VALUE>
297 const typename std::multimap<KEY,VALUE>::value_type *
inq_CurElement() const298 SCI_MultiMap<KEY,VALUE>::inq_CurElement() const
299 {
300     if (itRun != itEnd)
301         return &(*itRun);
302     return 0;
303 }
304 
305 
306 template <class KEY, class VALUE>
307 bool
inq_IsSorted() const308 SCI_MultiMap<KEY,VALUE>::inq_IsSorted() const
309 {
310     return true;
311 }
312 
313 
314 
315 
316 
317 
318 
319 
320 template <class ELEM>
SCI_Set(const source & i_rSource)321 SCI_Set<ELEM>::SCI_Set( const source & i_rSource  )
322     :   itRun(i_rSource.begin()),
323         itEnd(i_rSource.end())
324 {
325 }
326 
327 template <class ELEM>
~SCI_Set()328 SCI_Set<ELEM>::~SCI_Set()
329 {
330 }
331 
332 
333 template <class ELEM>
334 void
do_Advance()335 SCI_Set<ELEM>::do_Advance()
336 {
337     if (itRun != itEnd)
338         ++itRun;
339 }
340 
341 template <class ELEM>
342 const typename SCI_Set<ELEM>::element *
inq_CurElement() const343 SCI_Set<ELEM>::inq_CurElement() const
344 {
345     if (itRun != itEnd)
346         return &(*itRun);
347     return 0;
348 }
349 
350 template <class ELEM>
351 bool
inq_IsSorted() const352 SCI_Set<ELEM>::inq_IsSorted() const
353 {
354     return true;
355 }
356 
357 
358 
359 
360 
361 
362 
363 template <class KEY, class VALUE>
SCI_DataInMap(const source & i_rSource)364 SCI_DataInMap<KEY,VALUE>::SCI_DataInMap( const source & i_rSource  )
365     :   itRun(i_rSource.begin()),
366         itEnd(i_rSource.end())
367 {
368 }
369 
370 template <class KEY, class VALUE>
~SCI_DataInMap()371 SCI_DataInMap<KEY,VALUE>::~SCI_DataInMap()
372 {
373 }
374 
375 template <class KEY, class VALUE>
376 void
do_Advance()377 SCI_DataInMap<KEY,VALUE>::do_Advance()
378 {
379     if (itRun != itEnd)
380         ++itRun;
381 }
382 
383 template <class KEY, class VALUE>
384 const VALUE *
inq_CurElement() const385 SCI_DataInMap<KEY,VALUE>::inq_CurElement() const
386 {
387     if (itRun != itEnd)
388         return &(*itRun).second;
389     return 0;
390 }
391 
392 
393 template <class KEY, class VALUE>
394 bool
inq_IsSorted() const395 SCI_DataInMap<KEY,VALUE>::inq_IsSorted() const
396 {
397     return true;
398 }
399 
400 
401 
402 
403 
404 
405 
406 }   // namespace ary
407 
408 
409 #endif
410