datahandleif.hh

Go to the documentation of this file.
00001 #ifndef DUNE_DATAHANDLEIF_HH
00002 #define DUNE_DATAHANDLEIF_HH
00003 
00010 #include <dune/common/bartonnackmanifcheck.hh>
00011 
00012 namespace Dune 
00013 {
00014 
00029 template <class MessageBufferImp>
00030 class MessageBufferIF 
00031 {
00032   MessageBufferImp & buff_;
00033 public:
00035   MessageBufferIF(MessageBufferImp & buff) : buff_(buff) {}
00036   
00042   template <class T> 
00043   void write(const T & val) 
00044   {
00045     buff_.write(val);
00046   }
00047 
00053   template <class T> 
00054   void read(T & val) const
00055   {
00056     buff_.read(val);
00057   }
00058 }; // end class MessageBufferIF 
00059 
00060 
00073 template <class DataHandleImp, class DataTypeImp>
00074 class CommDataHandleIF
00075 {
00076 public:
00078   typedef DataTypeImp DataType; 
00079 
00080 protected:  
00081   // one should not create an explicit instance of this inteface object
00082   CommDataHandleIF() {} 
00083 
00084 public:
00090   bool contains (int dim, int codim) const
00091   {
00092     CHECK_INTERFACE_IMPLEMENTATION((asImp().contains(dim,codim)));
00093     return asImp().contains(dim,codim);
00094   }
00095   
00101   bool fixedsize (int dim, int codim) const
00102   {
00103     CHECK_INTERFACE_IMPLEMENTATION((asImp().fixedsize(dim,codim)));
00104     return asImp().fixedsize(dim,codim); 
00105   }
00106   
00111   template<class EntityType>
00112   size_t size (const EntityType& e) const
00113   { 
00114     CHECK_INTERFACE_IMPLEMENTATION((asImp().size(e)));
00115     return asImp().size(e);
00116   }
00117   
00122   template<class MessageBufferImp, class EntityType>
00123   void gather (MessageBufferImp& buff, const EntityType& e) const
00124   { 
00125     MessageBufferIF<MessageBufferImp> buffIF(buff);
00126     CHECK_AND_CALL_INTERFACE_IMPLEMENTATION((asImp().gather(buffIF,e)));
00127   }
00128 
00135   template<class MessageBufferImp, class EntityType>
00136   void scatter (MessageBufferImp& buff, const EntityType& e, size_t n)
00137   { 
00138     MessageBufferIF<MessageBufferImp> buffIF(buff);
00139     CHECK_AND_CALL_INTERFACE_IMPLEMENTATION((asImp().scatter(buffIF,e,n)));
00140   }
00141 
00142 private:
00144   DataHandleImp& asImp () {return static_cast<DataHandleImp &> (*this);}
00146   const DataHandleImp& asImp () const 
00147   {
00148     return static_cast<const DataHandleImp &>(*this);
00149   }
00150 }; // end class CommDataHandleIF 
00151 
00152 #undef CHECK_INTERFACE_IMPLEMENTATION
00153 #undef CHECK_AND_CALL_INTERFACE_IMPLEMENTATION
00154 
00155 } // end namespace Dune 
00156 #endif

Generated on 6 Nov 2008 with Doxygen (ver 1.5.6) [logfile].