2011-06-06 14:15:39 +06:00
|
|
|
// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
|
2010-02-09 16:02:53 +05:00
|
|
|
//
|
2011-06-06 14:15:39 +06:00
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2.1 of the License.
|
2010-02-09 16:02:53 +05:00
|
|
|
//
|
2011-06-06 14:15:39 +06:00
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
2010-02-09 16:02:53 +05:00
|
|
|
//
|
2011-06-06 14:15:39 +06:00
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2010-02-09 16:02:53 +05:00
|
|
|
//
|
2011-06-06 14:15:39 +06:00
|
|
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
2010-02-09 16:02:53 +05:00
|
|
|
//
|
2010-05-14 21:32:37 +06:00
|
|
|
|
2010-02-09 16:02:53 +05:00
|
|
|
// SMESH SMDS : implementaion of Salome mesh data structure
|
|
|
|
// File : SMDS_StdIterator.hxx
|
|
|
|
// Created : Fri Feb 5 11:03:46 2010
|
|
|
|
// Author : Edward AGAPOV (eap)
|
2010-05-14 21:32:37 +06:00
|
|
|
//
|
2010-02-09 16:02:53 +05:00
|
|
|
#ifndef __SMDS_StdIterator_HXX__
|
|
|
|
#define __SMDS_StdIterator_HXX__
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
/*!
|
|
|
|
* \brief Wrapper over pointer to SMDS_Iterator, like SMDS_ElemIteratorPtr, enabling
|
|
|
|
* its usage in std-like way: provide operators ++, *, etc.
|
|
|
|
*/
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template<typename VALUE, class PtrSMDSIterator, class EqualVALUE = std::equal_to<VALUE> >
|
|
|
|
class SMDS_StdIterator : public std::iterator< std::input_iterator_tag, VALUE >
|
|
|
|
{
|
|
|
|
VALUE _value;
|
|
|
|
PtrSMDSIterator _piterator;
|
|
|
|
EqualVALUE _EqualVALUE;
|
|
|
|
|
|
|
|
public:
|
|
|
|
typedef SMDS_StdIterator<VALUE, PtrSMDSIterator> _Self;
|
|
|
|
|
|
|
|
// constructor to use as return from begin()
|
|
|
|
SMDS_StdIterator( PtrSMDSIterator pItr )
|
|
|
|
: _value( pItr->more() ? (VALUE)(pItr->next()) : 0 ), _piterator(pItr)
|
|
|
|
{}
|
|
|
|
// constructor to use as return from end()
|
|
|
|
SMDS_StdIterator(): _value( 0 )
|
|
|
|
{}
|
|
|
|
|
|
|
|
/// Return the current object
|
|
|
|
VALUE operator*() const
|
|
|
|
{ return _value; }
|
|
|
|
|
|
|
|
// Step to the next one
|
|
|
|
_Self&
|
|
|
|
operator++()
|
|
|
|
{ _value = _piterator->more() ? VALUE( _piterator->next()) : 0; return *this; }
|
|
|
|
|
2011-01-18 15:51:03 +05:00
|
|
|
// Step to the next one
|
|
|
|
_Self
|
|
|
|
operator++(int)
|
|
|
|
{ _Self res = *this; _value = _piterator->more() ? VALUE( _piterator->next()) : 0; return res; }
|
|
|
|
|
2010-02-09 16:02:53 +05:00
|
|
|
// Test of end
|
|
|
|
bool
|
|
|
|
operator!=(const _Self& __x) const
|
|
|
|
{ return !_EqualVALUE( _value, __x._value); }
|
|
|
|
|
2011-01-18 15:51:03 +05:00
|
|
|
// Test of equality
|
|
|
|
bool
|
|
|
|
operator==(const _Self& __x) const
|
|
|
|
{ return _EqualVALUE( _value, __x._value); }
|
|
|
|
|
2010-02-09 16:02:53 +05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|