Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[modules/smesh.git] / src / SMDS / SMDS_SetIterator.hxx
1 //  SMESH SMDS : implementaion of Salome mesh data structure
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //
23 //
24 // File      : SMDS_SetIterator.hxx
25 // Created   : Mon Feb 27 16:57:43 2006
26 // Author    : Edward AGAPOV (eap)
27
28
29 #ifndef SMDS_SetIterator_HeaderFile
30 #define SMDS_SetIterator_HeaderFile
31
32 #include "SMDS_Iterator.hxx"
33
34 ///////////////////////////////////////////////////////////////////////////////
35 /// specific SMDS_Iterator iterating over abstract set of values like STL containers
36 ///
37 /// BE CAREFUL: iterator pointed value is static_cast'ed to VALUE
38 ///
39 ///////////////////////////////////////////////////////////////////////////////
40
41 template<typename VALUE, typename VALUE_SET_ITERATOR>
42 class SMDS_SetIterator : public SMDS_Iterator<VALUE>
43 {
44 protected:
45   VALUE_SET_ITERATOR _beg, _end;
46 public:
47   SMDS_SetIterator(const VALUE_SET_ITERATOR & begin,
48                    const VALUE_SET_ITERATOR & end)
49   { init ( begin, end ); }
50
51   /// Initialization
52   virtual void init(const VALUE_SET_ITERATOR & begin,
53                     const VALUE_SET_ITERATOR & end)
54   { _beg = begin; _end = end; }
55
56   /// Return true if and only if there are other object in this iterator
57   virtual bool more() { return _beg != _end; }
58
59   /// Return the current object and step to the next one
60   virtual VALUE next() { return static_cast<VALUE>( *_beg++ ); }
61
62 };
63
64 // useful specifications
65
66 #include <vector>
67
68 class SMDS_MeshElement;
69 class SMDS_MeshNode;
70
71 typedef const SMDS_MeshElement* SMDS_pElement;
72 typedef const SMDS_MeshNode*    SMDS_pNode;
73
74 // element iterators
75
76 typedef SMDS_SetIterator< SMDS_pElement, std::vector< SMDS_pElement >::const_iterator>
77 SMDS_ElementVectorIterator;
78
79
80 typedef SMDS_SetIterator< SMDS_pElement, SMDS_pElement const *>
81 SMDS_ElementArrayIterator;
82
83
84 typedef SMDS_SetIterator< SMDS_pElement, std::vector< SMDS_pNode >::const_iterator>
85 SMDS_NodeVectorElemIterator;
86
87
88 typedef SMDS_SetIterator< SMDS_pElement, SMDS_pNode const * >
89 SMDS_NodeArrayElemIterator;
90
91 // node iterators
92
93 typedef SMDS_SetIterator< SMDS_pNode, std::vector< SMDS_pNode >::const_iterator >
94 SMDS_NodeVectorIterator;
95
96
97 typedef SMDS_SetIterator< SMDS_pNode, SMDS_pNode const * >
98 SMDS_NodeArrayIterator;
99
100
101 #endif