BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
entity_iterator.hpp
1 // Copyright (C) 2011-2012 by the BEM++ Authors
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 // THE SOFTWARE.
20 
21 #ifndef bempp_entity_iterator_hpp
22 #define bempp_entity_iterator_hpp
23 
24 #include "../common/common.hpp"
25 
26 #include "entity_pointer.hpp"
27 #include <memory>
28 
29 namespace Bempp
30 {
31 
33 template<int codim> class Entity;
58 template<int codim>
59 class EntityIterator: public EntityPointer<codim>
60 {
61 protected: /* Can't be changed to private, derived classes use it */
62  bool m_finished;
63 public:
65  virtual void next() = 0;
66 
68  bool finished() const {
69  return m_finished;
70  }
71 
72  // virtual void reset() = 0; // Would such a method be useful?
73 
74  // This redeclaration appears so that the docstring can be changed wrt. to the base class.
76  virtual const Entity<codim>& entity() const = 0;
77 
83  virtual std::auto_ptr<EntityPointer<codim> > frozen() const = 0;
84 };
85 
86 } // namespace Bempp
87 
88 #endif
Abstract base class for an object providing read-only access to an entity of codimension codim...
Definition: entity_pointer.hpp:42
Abstract wrapper of an entity of codimension codim.
Definition: entity.hpp:46
virtual const Entity< codim > & entity() const =0
Read-only access to the entity referenced by the iterator.
virtual std::auto_ptr< EntityPointer< codim > > frozen() const =0
A stable pointer to the entity currently referenced by the iterator.
bool finished() const
True if iterator points past the end of the iteration range.
Definition: entity_iterator.hpp:68
Abstract base class for iterators over entities.
Definition: entity_iterator.hpp:59
virtual void next()=0
Increment iterator.