dune-fem  2.8-git
idgridpart/iterator.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_GRIDPART_IDGRIDPART_ITERATOR_HH
2 #define DUNE_FEM_GRIDPART_IDGRIDPART_ITERATOR_HH
3 
4 #include <type_traits>
5 #include <utility>
6 
7 #include <dune/common/version.hh>
8 #include <dune/grid/common/gridenums.hh>
9 
10 namespace Dune
11 {
12 
13  namespace Fem
14  {
15 
16  // IdIterator
17  // ----------
18 
19  template< int codim, PartitionIteratorType pitype, class GridFamily >
20  class IdIterator
21  {
22  typedef typename std::remove_const< GridFamily >::type::Traits Traits;
23 
24  typedef typename Traits::HostGridPartType HostGridPartType;
25 
26  public:
27  typedef typename Traits::ExtraData ExtraData;
28  typedef typename HostGridPartType::template Codim< codim >::template Partition< pitype >::IteratorType HostIteratorType;
29 
30 #if !DUNE_VERSION_NEWER(DUNE_GRID, 2, 6 )
31  static const int codimension = HostIteratorType::codimension;
32 #endif
33 
34  typedef typename Traits::template Codim< codim >::Entity Entity;
35 
36  IdIterator () = default;
37 
38  IdIterator ( ExtraData data, HostIteratorType hostIterator )
39  : data_( std::move( data ) ),
40  hostIterator_( std::move( hostIterator ) )
41  {}
42 
43  void increment ()
44  {
45  ++hostIterator_;
46  }
47 
49  {
50  return typename Entity::Implementation( data_, *hostIterator_ );
51  }
52 
53  bool equals ( const IdIterator &rhs ) const
54  {
55  return hostIterator_ == rhs.hostIterator_;
56  }
57 
58  int level () const
59  {
60  return hostIterator_.level();
61  }
62 
63  private:
64  ExtraData data_;
65  HostIteratorType hostIterator_;
66  };
67 
68  } // namespace Fem
69 
70 } // namespace Dune
71 
72 #endif // #ifndef DUNE_FEM_GRIDPART_IDGRIDPART_ITERATOR_HH
Definition: bindguard.hh:11
Definition: idgridpart/iterator.hh:21
bool equals(const IdIterator &rhs) const
Definition: idgridpart/iterator.hh:53
void increment()
Definition: idgridpart/iterator.hh:43
Traits::template Codim< codim >::Entity Entity
Definition: idgridpart/iterator.hh:34
Entity dereference() const
Definition: idgridpart/iterator.hh:48
static const int codimension
Definition: idgridpart/iterator.hh:31
HostGridPartType::template Codim< codim >::template Partition< pitype >::IteratorType HostIteratorType
Definition: idgridpart/iterator.hh:28
Traits::ExtraData ExtraData
Definition: idgridpart/iterator.hh:27
int level() const
Definition: idgridpart/iterator.hh:58
IdIterator(ExtraData data, HostIteratorType hostIterator)
Definition: idgridpart/iterator.hh:38