00001
00002
00003 #ifndef DUNE_MAPPER2_HH
00004 #define DUNE_MAPPER2_HH
00005
00006 #include <iostream>
00007 #include <dune/common/exceptions.hh>
00008 #include <dune/common/helpertemplates.hh>
00009
00010 #include <dune/common/bartonnackmanifcheck.hh>
00011
00089 namespace Dune
00090 {
00109 template <typename G, typename MapperImp>
00110 class Mapper {
00111 public:
00112
00118 template<class EntityType>
00119 int map (const EntityType& e) const
00120 {
00121 CHECK_INTERFACE_IMPLEMENTATION((asImp().map(e)));
00122 return asImp().map(e);
00123 }
00124
00131 template<int cc>
00132 int map (const typename G::Traits::template Codim<0>::Entity& e, int i) const
00133 {
00134 CHECK_INTERFACE_IMPLEMENTATION((asImp().template map<cc>(e,i)));
00135 return asImp().template map<cc>(e,i);
00136 }
00137
00146 int size () const
00147 {
00148 CHECK_INTERFACE_IMPLEMENTATION((asImp().size()));
00149 return asImp().size();
00150 }
00151
00152
00160 template<class EntityType>
00161 bool contains (const EntityType& e, int& result) const
00162 {
00163 CHECK_INTERFACE_IMPLEMENTATION((asImp().contains(e,result )));
00164 return asImp().contains(e,result );
00165 }
00166
00175 template<int cc>
00176 bool contains (const typename G::Traits::template Codim<0>::Entity& e, int i, int& result) const
00177 {
00178 CHECK_INTERFACE_IMPLEMENTATION((asImp().template contains<cc>(e,i,result)))
00179 return asImp().template contains<cc>(e,i,result);
00180 }
00181
00184 void update ()
00185 {
00186 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION((asImp().update()));
00187 }
00188
00189 private:
00191 MapperImp& asImp () {return static_cast<MapperImp &> (*this);}
00193 const MapperImp& asImp () const {return static_cast<const MapperImp &>(*this);}
00194 };
00195
00198 #undef CHECK_INTERFACE_IMPLEMENTATION
00199 #undef CHECK_AND_CALL_INTERFACE_IMPLEMENTATION
00200
00201 }
00202 #endif