1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SMESH SMDS : implementaion of Salome mesh data structure
24 // File : SMDS_StdIterator.hxx
25 // Created : Fri Feb 5 11:03:46 2010
26 // Author : Edward AGAPOV (eap)
29 #ifndef __SMDS_StdIterator_HXX__
30 #define __SMDS_StdIterator_HXX__
33 ///////////////////////////////////////////////////////////////////////////////
35 * \brief Wrapper over pointer to SMDS_Iterator, like SMDS_ElemIteratorPtr, enabling
36 * its usage in std-like way: provide operators ++, *, etc.
38 ///////////////////////////////////////////////////////////////////////////////
40 template<typename VALUE, class PtrSMDSIterator, class EqualVALUE = std::equal_to<VALUE> >
41 class SMDS_StdIterator : public std::iterator< std::input_iterator_tag, VALUE >
44 PtrSMDSIterator _piterator;
45 EqualVALUE _EqualVALUE;
48 typedef SMDS_StdIterator<VALUE, PtrSMDSIterator> _Self;
50 // constructor to use as return from begin()
51 SMDS_StdIterator( PtrSMDSIterator pItr )
52 : _value( pItr->more() ? (VALUE)(pItr->next()) : 0 ), _piterator(pItr)
54 // constructor to use as return from end()
55 SMDS_StdIterator(): _value( 0 )
58 /// Return the current object
59 VALUE operator*() const
62 // Step to the next one
65 { _value = _piterator->more() ? VALUE( _piterator->next()) : 0; return *this; }
69 operator!=(const _Self& __x) const
70 { return !_EqualVALUE( _value, __x._value); }