xref: /aoo4110/main/autodoc/inc/ary/stdconstiter.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_STDCONSTITER_HXX
25 #define ARY_STDCONSTITER_HXX
26 //  KORR_DEPRECATED_3.0
27 
28 
29 // USED SERVICES
30     // BASE CLASSES
31     // COMPONENTS
32     // PARAMETERS
33 
34 
35 namespace ary
36 {
37 
38 template <class ELEM>
39 
40 class StdConstIterator
41 {
42   public:
~StdConstIterator()43     virtual             ~StdConstIterator() {}
44 
operator ++()45     void                operator++()            { do_Advance(); }
operator *() const46     const ELEM &        operator*() const       { return *inq_CurElement(); }
47                         operator bool() const   { return inq_CurElement() != 0; }
48 
49     /// Needed as replacement for operator bool() in gcc 2.95.
IsValid() const50     bool                IsValid() const         { return operator bool(); }
IsSorted() const51     bool                IsSorted() const        { return inq_IsSorted(); }
52 
53   protected:
StdConstIterator()54                         StdConstIterator() {}
55 
56   private:
57     //Locals
58     virtual void        do_Advance() = 0;
59     virtual const ELEM *
60                         inq_CurElement() const = 0;
61     virtual bool        inq_IsSorted() const = 0;
62 
63     // Forbidden:
64     StdConstIterator(const StdConstIterator<ELEM>&);
65     StdConstIterator<ELEM> & operator=(const StdConstIterator<ELEM>&);
66 };
67 
68 
69 template <class ELEM>
70 class Dyn_StdConstIterator
71 {
72   public:
73     typedef StdConstIterator<ELEM> client_type;
74 
Dyn_StdConstIterator(DYN client_type * pass_dpIterator=0)75                         Dyn_StdConstIterator(
76                             DYN client_type *   pass_dpIterator = 0 )
77                                                 : pClient(pass_dpIterator) {}
78     Dyn_StdConstIterator<ELEM> &
operator =(DYN client_type * pass_dpIterator)79                         operator=(
80                             DYN client_type *   pass_dpIterator )
81                                                 { pClient = pass_dpIterator;
82                                                   return *this; }
operator *() const83     client_type &       operator*() const       { return *pClient.MutablePtr(); }
84 
85   private:
86     Dyn<client_type>    pClient;
87 };
88 
89 
90 
91 
92 
93 }   // namespace ary
94 #endif
95