Dune Core Modules (2.3.1)

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
13
14namespace 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 {
127 }
128
134 template<class MessageBufferImp, class EntityType>
135 void scatter (MessageBufferImp& buff, const EntityType& e, size_t n)
136 {
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
Provides check for implementation of interface methods when using static polymorphism,...
#define CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(__interface_method_to_call__)
Definition: bartonnackmanifcheck.hh:53
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:75
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:101
void scatter(MessageBufferImp &buff, const EntityType &e, size_t n)
unpack data from message buffer to user.
Definition: datahandleif.hh:135
bool contains(int dim, int codim) const
returns true if data for given valid codim should be communicated
Definition: datahandleif.hh:90
size_t size(const EntityType &e) const
how many objects of type DataType have to be sent for a given entity
Definition: datahandleif.hh:112
void gather(MessageBufferImp &buff, const EntityType &e) const
pack data from user to message buffer
Definition: datahandleif.hh:123
DataTypeImp DataType
data type of data to communicate
Definition: datahandleif.hh:78
Communication message buffer interface. This class describes the interface for reading and writing da...
Definition: datahandleif.hh:33
MessageBufferIF(MessageBufferImp &buff)
stores reference to original buffer buff
Definition: datahandleif.hh:37
void read(T &val) const
just wraps the call of the internal buffer method read which reads the data of type T from the buffer...
Definition: datahandleif.hh:56
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:45
Dune namespace.
Definition: alignment.hh:14
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)