1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ConstrainedIterator.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SD_TOOLPANEL_CONSTRAINED_ITERATOR_HXX
32 #define SD_TOOLPANEL_CONSTRAINED_ITERATOR_HXX
36 namespace sd
{ namespace toolpanel
{
39 template <class Container
>
43 virtual bool operator() (
44 const Container
& rContainer
,
45 const Container::iterator
& rIterator
) const = 0;
51 /** This iterator is a bidirectional iterator with something of random
52 access thrown in. It uses a constraint object to jump over
53 elements in the underlying container that do not meet the
56 template <class Container
>
57 class ConstrainedIterator
58 : public ::std::bidirectional_iterator_tag
61 typedef Container::value_type value_type
;
62 typedef value_type
& reference
;
63 typedef const value_type
& const_reference
;
65 ConstrainedIterator (void);
67 const Container
& rContainer
,
68 const Container::iterator
& rIterator
);
70 const Container
& rContainer
,
71 const Container::iterator
& rIterator
,
72 const Constraint
<Container
>& pConstraint
);
74 const ConstrainedIterator
& rIterator
);
76 ConstrainedIterator
& operator= (
77 const ConstrainedIterator
& aIterator
);
79 reference
operator* (void);
80 const_reference
operator* (void) const;
81 reference
operator-> (void);
82 const_reference
operator-> (void) const;
84 bool operator== (const ConstrainedIterator
& aIterator
) const;
85 bool operator!= (const ConstrainedIterator
& aIterator
) const;
87 ConstrainedIterator
& operator++ (void);
88 ConstrainedIterator
operator++ (int);
89 ConstrainedIterator
& operator-- (void);
90 ConstrainedIterator
operator-- (int);
92 ConstrainedIterator
operator+ (int nValue
) const;
93 ConstrainedIterator
operator- (int nValue
) const;
97 const Container
* mpContainer
;
98 Container::iterator maIterator
;
99 const Constraint
<Container
>* mpConstraint
;
101 void AdvanceToNextValidElement (void);
102 void AdvanceToPreviousValidElement (void);
105 } } // end of namespace ::sd::toolpanel