dune-grid  2.2.1
datahandleif.hh
Go to the documentation of this file.
1 #ifndef DUNE_DATAHANDLEIF_HH
2 #define DUNE_DATAHANDLEIF_HH
3 
10 #include <dune/common/bartonnackmanifcheck.hh>
11 
12 namespace Dune
13 {
14 
29 template <class MessageBufferImp>
31 {
32  MessageBufferImp & buff_;
33 public:
35  MessageBufferIF(MessageBufferImp & buff) : buff_(buff) {}
36 
42  template <class T>
43  void write(const T & val)
44  {
45  buff_.write(val);
46  }
47 
53  template <class T>
54  void read(T & val) const
55  {
56  buff_.read(val);
57  }
58 }; // end class MessageBufferIF
59 
60 
71 template <class DataHandleImp, class DataTypeImp>
73 {
74 public:
76  typedef DataTypeImp DataType;
77 
78 protected:
79  // one should not create an explicit instance of this inteface object
81 
82 public:
88  bool contains (int dim, int codim) const
89  {
90  CHECK_INTERFACE_IMPLEMENTATION((asImp().contains(dim,codim)));
91  return asImp().contains(dim,codim);
92  }
93 
99  bool fixedsize (int dim, int codim) const
100  {
101  CHECK_INTERFACE_IMPLEMENTATION((asImp().fixedsize(dim,codim)));
102  return asImp().fixedsize(dim,codim);
103  }
104 
109  template<class EntityType>
110  size_t size (const EntityType& e) const
111  {
112  CHECK_INTERFACE_IMPLEMENTATION((asImp().size(e)));
113  return asImp().size(e);
114  }
115 
120  template<class MessageBufferImp, class EntityType>
121  void gather (MessageBufferImp& buff, const EntityType& e) const
122  {
124  CHECK_AND_CALL_INTERFACE_IMPLEMENTATION((asImp().gather(buffIF,e)));
125  }
126 
133  template<class MessageBufferImp, class EntityType>
134  void scatter (MessageBufferImp& buff, const EntityType& e, size_t n)
135  {
137  CHECK_AND_CALL_INTERFACE_IMPLEMENTATION((asImp().scatter(buffIF,e,n)));
138  }
139 
140 private:
142  DataHandleImp& asImp () {return static_cast<DataHandleImp &> (*this);}
144  const DataHandleImp& asImp () const
145  {
146  return static_cast<const DataHandleImp &>(*this);
147  }
148 }; // end class CommDataHandleIF
149 
150 #undef CHECK_INTERFACE_IMPLEMENTATION
151 #undef CHECK_AND_CALL_INTERFACE_IMPLEMENTATION
152 
153 } // end namespace Dune
154 #endif