dune-grid  2.3beta2
datahandleif.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #ifndef DUNE_DATAHANDLEIF_HH
4 #define DUNE_DATAHANDLEIF_HH
5 
12 #include <dune/common/bartonnackmanifcheck.hh>
13 
14 namespace Dune
15 {
16 
31  template <class MessageBufferImp>
33  {
34  MessageBufferImp & buff_;
35  public:
37  MessageBufferIF(MessageBufferImp & buff) : buff_(buff) {}
38 
44  template <class T>
45  void write(const T & val)
46  {
47  buff_.write(val);
48  }
49 
55  template <class T>
56  void read(T & val) const
57  {
58  buff_.read(val);
59  }
60  }; // end class MessageBufferIF
61 
62 
73  template <class DataHandleImp, class DataTypeImp>
75  {
76  public:
78  typedef DataTypeImp DataType;
79 
80  protected:
81  // one should not create an explicit instance of this inteface object
83 
84  public:
90  bool contains (int dim, int codim) const
91  {
92  CHECK_INTERFACE_IMPLEMENTATION((asImp().contains(dim,codim)));
93  return asImp().contains(dim,codim);
94  }
95 
101  bool fixedsize (int dim, int codim) const
102  {
103  CHECK_INTERFACE_IMPLEMENTATION((asImp().fixedsize(dim,codim)));
104  return asImp().fixedsize(dim,codim);
105  }
106 
111  template<class EntityType>
112  size_t size (const EntityType& e) const
113  {
114  CHECK_INTERFACE_IMPLEMENTATION((asImp().size(e)));
115  return asImp().size(e);
116  }
117 
122  template<class MessageBufferImp, class EntityType>
123  void gather (MessageBufferImp& buff, const EntityType& e) const
124  {
126  CHECK_AND_CALL_INTERFACE_IMPLEMENTATION((asImp().gather(buffIF,e)));
127  }
128 
134  template<class MessageBufferImp, class EntityType>
135  void scatter (MessageBufferImp& buff, const EntityType& e, size_t n)
136  {
138  CHECK_AND_CALL_INTERFACE_IMPLEMENTATION((asImp().scatter(buffIF,e,n)));
139  }
140 
141  private:
143  DataHandleImp& asImp () {return static_cast<DataHandleImp &> (*this);}
145  const DataHandleImp& asImp () const
146  {
147  return static_cast<const DataHandleImp &>(*this);
148  }
149  }; // end class CommDataHandleIF
150 
151 #undef CHECK_INTERFACE_IMPLEMENTATION
152 #undef CHECK_AND_CALL_INTERFACE_IMPLEMENTATION
153 
154 } // end namespace Dune
155 #endif