xref: /aoo41x/main/autodoc/inc/ary/stdconstiter.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef ARY_STDCONSTITER_HXX
29 #define ARY_STDCONSTITER_HXX
30 //  KORR_DEPRECATED_3.0
31 
32 
33 // USED SERVICES
34     // BASE CLASSES
35     // COMPONENTS
36     // PARAMETERS
37 
38 
39 namespace ary
40 {
41 
42 template <class ELEM>
43 
44 class StdConstIterator
45 {
46   public:
47     virtual             ~StdConstIterator() {}
48 
49     void                operator++()            { do_Advance(); }
50     const ELEM &        operator*() const       { return *inq_CurElement(); }
51                         operator bool() const   { return inq_CurElement() != 0; }
52 
53     /// Needed as replacement for operator bool() in gcc 2.95.
54     bool                IsValid() const         { return operator bool(); }
55     bool                IsSorted() const        { return inq_IsSorted(); }
56 
57   protected:
58                         StdConstIterator() {}
59 
60   private:
61     //Locals
62     virtual void        do_Advance() = 0;
63     virtual const ELEM *
64                         inq_CurElement() const = 0;
65     virtual bool        inq_IsSorted() const = 0;
66 
67     // Forbidden:
68     StdConstIterator(const StdConstIterator<ELEM>&);
69     StdConstIterator<ELEM> & operator=(const StdConstIterator<ELEM>&);
70 };
71 
72 
73 template <class ELEM>
74 class Dyn_StdConstIterator
75 {
76   public:
77     typedef StdConstIterator<ELEM> client_type;
78 
79                         Dyn_StdConstIterator(
80                             DYN client_type *   pass_dpIterator = 0 )
81                                                 : pClient(pass_dpIterator) {}
82     Dyn_StdConstIterator<ELEM> &
83                         operator=(
84                             DYN client_type *   pass_dpIterator )
85                                                 { pClient = pass_dpIterator;
86                                                   return *this; }
87     client_type &       operator*() const       { return *pClient.MutablePtr(); }
88 
89   private:
90     Dyn<client_type>    pClient;
91 };
92 
93 
94 
95 
96 
97 }   // namespace ary
98 #endif
99