Salome HOME
0020832: EDF 1359 SMESH : Automatic meshing of boundary layers
authoreap <eap@opencascade.com>
Tue, 18 Jan 2011 10:55:06 +0000 (10:55 +0000)
committereap <eap@opencascade.com>
Tue, 18 Jan 2011 10:55:06 +0000 (10:55 +0000)
+ SMDS_IteratorOnIterators.hxx

src/SMDS/SMDS_IteratorOnIterators.hxx [new file with mode: 0644]

diff --git a/src/SMDS/SMDS_IteratorOnIterators.hxx b/src/SMDS/SMDS_IteratorOnIterators.hxx
new file mode 100644 (file)
index 0000000..2712f50
--- /dev/null
@@ -0,0 +1,64 @@
+//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+//  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.
+//
+//  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.
+//
+//  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
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+//  SMESH SMDS : implementaion of Salome mesh data structure
+// File      : SMDS_IteratorOnIterators.hxx
+// Author    : Edward AGAPOV (eap)
+//
+#ifndef SMDS_IteratorOnIterators_HeaderFile
+#define SMDS_IteratorOnIterators_HeaderFile
+
+#include "SMDS_Iterator.hxx"
+
+///////////////////////////////////////////////////////////////////////////////
+/// SMDS_Iterator iterating over all elements provides by other iterators
+///
+/// Other iterators must implement SMDS_Iterator iterface and
+/// must be provided within a stl-like container
+/// BE CAREFUL: iterator pointed value is static_cast'ed to VALUE
+///////////////////////////////////////////////////////////////////////////////
+
+template<typename VALUE,
+         typename CONTAINER_OF_ITERATORS >
+class SMDS_IteratorOnIterators : public SMDS_Iterator<VALUE>
+{
+protected:
+  CONTAINER_OF_ITERATORS _iterators;
+  typename CONTAINER_OF_ITERATORS::iterator _beg, _end;
+public:
+  SMDS_IteratorOnIterators(const CONTAINER_OF_ITERATORS& iterators):
+    _iterators( iterators ), _beg( _iterators.begin()), _end(_iterators.end() ) {}
+
+  /// Return true iff there are other object in this iterator
+  virtual bool more() { return _beg != _end && (*_beg)->more(); }
+
+  /// Return the current object and step to the next one
+  virtual VALUE next()
+  {
+    VALUE __v = (VALUE)(*_beg)->next();
+    while ( _beg != _end && !(*_beg)->more())
+      ++_beg;
+    return __v;
+  }
+};
+
+#endif