dune-grid  2.2.0
mapper.hh
Go to the documentation of this file.
1 // $Id: mapper.hh 8028 2012-05-03 15:59:56Z sander $
2 
3 #ifndef DUNE_MAPPER2_HH
4 #define DUNE_MAPPER2_HH
5 
6 #include <iostream>
7 #include <dune/common/exceptions.hh>
8 
9 #include <dune/common/bartonnackmanifcheck.hh>
10 
11 #include <dune/geometry/genericgeometry/conversion.hh>
12 
90 namespace Dune
91 {
110  template <typename G, typename MapperImp>
111  class Mapper {
112  public:
113 
119  template<class EntityType>
120  int map (const EntityType& e) const
121  {
122  CHECK_INTERFACE_IMPLEMENTATION((asImp().map(e)));
123  return asImp().map(e);
124  }
125 
126 
134  int map (const typename G::Traits::template Codim<0>::Entity& e,
135  int i,
136  unsigned int codim) const
137  {
138  CHECK_INTERFACE_IMPLEMENTATION((asImp().map(e,i,codim)));
139  return asImp().map(e,i,codim);
140  }
141 
150  int size () const
151  {
152  CHECK_INTERFACE_IMPLEMENTATION((asImp().size()));
153  return asImp().size();
154  }
155 
156 
164  template<class EntityType>
165  bool contains (const EntityType& e, int& result) const
166  {
167  CHECK_INTERFACE_IMPLEMENTATION((asImp().contains(e,result )));
168  return asImp().contains(e,result );
169  }
170 
171 
181  bool contains (const typename G::Traits::template Codim<0>::Entity& e, int i, int cc, int& result) const
182  {
183  CHECK_INTERFACE_IMPLEMENTATION((asImp().contains(e,i,cc,result)))
184  return asImp().contains(e,i,cc,result);
185  }
186 
189  void update ()
190  {
191  CHECK_AND_CALL_INTERFACE_IMPLEMENTATION((asImp().update()));
192  }
193 
194 private:
196  MapperImp& asImp () {return static_cast<MapperImp &> (*this);}
198  const MapperImp& asImp () const {return static_cast<const MapperImp &>(*this);}
199  };
200 
203 #undef CHECK_INTERFACE_IMPLEMENTATION
204 #undef CHECK_AND_CALL_INTERFACE_IMPLEMENTATION
205 
206 }
207 #endif