Dune Core Modules (2.8.0)

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_GRID_COMMON_DATAHANDLEIF_HH
4#define DUNE_GRID_COMMON_DATAHANDLEIF_HH
5
13
14namespace Dune
15{
16
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
56 template <class T>
57 void read(T & val)
58 {
59 buff_.read(val);
60 }
61 }; // end class MessageBufferIF
62
63
74 template <class DataHandleImp, class DataTypeImp>
76 {
77 template <class M>
78 class CheckFixedSizeMethod
79 {
80 // check for old signature of deprecated fixedsize method.
81 template <class T>
82 static std::true_type testSignature(bool (T::*)(int, int) const);
83
84 template <class T>
85 static decltype(testSignature(&T::fixedsize)) test(std::nullptr_t);
86
87 template <class T>
88 static std::false_type test(...);
89
90 using type = decltype(test<M>(nullptr));
91 public:
92 static const bool value = type::value;
93 };
94
95
96 template <class DH, bool>
97 struct CallFixedSize
98 {
99 static bool fixedSize( const DH& dh, int dim, int codim )
100 {
101 return dh.fixedSize( dim, codim );
102 }
103 };
104
105 // old, deprecated implementation
106 template <class DH>
107 struct CallFixedSize< DH, true >
108 {
109 static bool fixedSize( const DH& dh, int dim, int codim )
110 {
111 return dh.overloaded_deprecated_fixedsize( dim, codim );
112 }
113 };
114
115 public:
117 typedef DataTypeImp DataType;
118
119 protected:
120 // one should not create an explicit instance of this interface object
122
123 public:
129 bool contains (int dim, int codim) const
130 {
131 CHECK_INTERFACE_IMPLEMENTATION((asImp().contains(dim,codim)));
132 return asImp().contains(dim,codim);
133 }
134
145 [[deprecated("fixedsize (lower case s) will be removed after release 2.8. Implement and call fixedSize (camelCase) instead!")]]
146 int fixedsize (int dim, int codim) const
147 {
148 return int(fixedSize( dim, codim ));
149 }
150
151 // if this deprecation appears then the DataHandle implementation
152 // is overloaded in the old 'fixedsize' method but not the new 'fixedSize'
153 // method.
154 [[deprecated("fixedsize (lower case s) will be removed after release 2.8. Implement and call fixedSize (camelCase) instead!")]]
155 bool overloaded_deprecated_fixedsize( int dim, int codim ) const
156 {
157 return asImp().fixedsize( dim, codim );
158 }
159
167 bool fixedSize (int dim, int codim) const
168 {
169 // this should be enabled once the old fixedsize is removed
170 //CHECK_INTERFACE_IMPLEMENTATION((asImp().fixedSize(dim,codim)));
171 return CallFixedSize< DataHandleImp,
172 CheckFixedSizeMethod< DataHandleImp >::value >::fixedSize( asImp(), dim, codim );
173 }
174
179 template<class EntityType>
180 size_t size (const EntityType& e) const
181 {
182 CHECK_INTERFACE_IMPLEMENTATION((asImp().size(e)));
183 return asImp().size(e);
184 }
185
190 template<class MessageBufferImp, class EntityType>
191 void gather (MessageBufferImp& buff, const EntityType& e) const
192 {
195 }
196
204 template<class MessageBufferImp, class EntityType>
205 void scatter (MessageBufferImp& buff, const EntityType& e, size_t n)
206 {
209 }
210
211 private:
213 DataHandleImp& asImp () {return static_cast<DataHandleImp &> (*this);}
215 const DataHandleImp& asImp () const
216 {
217 return static_cast<const DataHandleImp &>(*this);
218 }
219 }; // end class CommDataHandleIF
220
221#undef CHECK_INTERFACE_IMPLEMENTATION
222#undef CHECK_AND_CALL_INTERFACE_IMPLEMENTATION
223
224} // end namespace Dune
225#endif
Provides check for implementation of interface methods when using static polymorphism,...
#define CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(__interface_method_to_call__)
Definition: bartonnackmanifcheck.hh:59
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:76
void scatter(MessageBufferImp &buff, const EntityType &e, size_t n)
unpack data from message buffer to user.
Definition: datahandleif.hh:205
int fixedsize(int dim, int codim) const
returns true if size of data per entity of given dim and codim is a constant
Definition: datahandleif.hh:146
bool contains(int dim, int codim) const
returns true if data for given valid codim should be communicated
Definition: datahandleif.hh:129
size_t size(const EntityType &e) const
how many objects of type DataType have to be sent for a given entity
Definition: datahandleif.hh:180
void gather(MessageBufferImp &buff, const EntityType &e) const
pack data from user to message buffer
Definition: datahandleif.hh:191
bool fixedSize(int dim, int codim) const
returns true if size of data per entity of given dim and codim is a constant
Definition: datahandleif.hh:167
DataTypeImp DataType
data type of data to communicate
Definition: datahandleif.hh:117
Communication message buffer interface. This class describes the interface for reading and writing da...
Definition: datahandleif.hh:31
MessageBufferIF(MessageBufferImp &buff)
stores reference to original buffer buff
Definition: datahandleif.hh:35
void write(const T &val)
just wraps the call of the internal buffer method write which writes the data of type T from the buff...
Definition: datahandleif.hh:43
void read(T &val)
just wraps the call of the internal buffer method read which reads the data of type T from the buffer...
Definition: datahandleif.hh:57
Dune namespace.
Definition: alignedallocator.hh:11
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)