24 #include "openPMD/config.hpp" 25 #if openPMD_HAVE_ADIOS2 26 #include "openPMD/Dataset.hpp" 27 #include "openPMD/Datatype.hpp" 28 #include "openPMD/DatatypeHelpers.hpp" 44 using bool_representation =
unsigned char;
49 static std::string type();
55 static std::string type();
58 template <
typename T,
size_t n>
61 static std::string type();
67 static std::string type();
73 std::string operator()();
76 std::string operator()();
85 Datatype fromADIOS2Type(std::string
const &dt,
bool verbose =
true);
87 enum class VariableOrAttribute : unsigned char
98 std::string
const &attributeName,
101 template <
int n,
typename... Params>
102 static Extent call(Params &&...);
119 std::string
const &attributeName,
121 VariableOrAttribute voa = VariableOrAttribute::Attribute);
139 template <
typename Action,
typename... Args>
141 -> decltype(Action::template call<char>(std::forward<Args>(args)...))
144 decltype(Action::template call<char>(std::forward<Args>(args)...));
148 return Action::template call<char>(std::forward<Args>(args)...);
149 case Datatype::UCHAR:
150 return Action::template call<unsigned char>(
151 std::forward<Args>(args)...);
152 case Datatype::SCHAR:
153 return Action::template call<signed char>(std::forward<Args>(args)...);
154 case Datatype::SHORT:
155 return Action::template call<short>(std::forward<Args>(args)...);
157 return Action::template call<int>(std::forward<Args>(args)...);
159 return Action::template call<long>(std::forward<Args>(args)...);
160 case Datatype::LONGLONG:
161 return Action::template call<long long>(std::forward<Args>(args)...);
162 case Datatype::USHORT:
163 return Action::template call<unsigned short>(
164 std::forward<Args>(args)...);
166 return Action::template call<unsigned int>(std::forward<Args>(args)...);
167 case Datatype::ULONG:
168 return Action::template call<unsigned long>(
169 std::forward<Args>(args)...);
170 case Datatype::ULONGLONG:
171 return Action::template call<unsigned long long>(
172 std::forward<Args>(args)...);
173 case Datatype::FLOAT:
174 return Action::template call<float>(std::forward<Args>(args)...);
175 case Datatype::DOUBLE:
176 return Action::template call<double>(std::forward<Args>(args)...);
177 case Datatype::LONG_DOUBLE:
178 return Action::template call<long double>(std::forward<Args>(args)...);
179 case Datatype::CFLOAT:
180 return Action::template call<std::complex<float>>(
181 std::forward<Args>(args)...);
182 case Datatype::CDOUBLE:
183 return Action::template call<std::complex<double>>(
184 std::forward<Args>(args)...);
190 case Datatype::STRING:
191 return Action::template call<std::string>(std::forward<Args>(args)...);
192 case Datatype::UNDEFINED:
194 CallUndefinedDatatype<0, ReturnType, Action, Args &&...>::call(
195 std::forward<Args>(args)...);
197 throw std::runtime_error(
198 "Internal error: Encountered unknown datatype (switchType) ->" +
199 std::to_string(static_cast<int>(dt)));
219 template <
typename Action,
typename... Args>
221 -> decltype(Action::template call<char>(std::forward<Args>(args)...))
224 decltype(Action::template call<char>(std::forward<Args>(args)...));
228 return Action::template call<char>(std::forward<Args>(args)...);
229 case Datatype::UCHAR:
230 return Action::template call<unsigned char>(
231 std::forward<Args>(args)...);
232 case Datatype::SCHAR:
233 return Action::template call<signed char>(std::forward<Args>(args)...);
234 case Datatype::SHORT:
235 return Action::template call<short>(std::forward<Args>(args)...);
237 return Action::template call<int>(std::forward<Args>(args)...);
239 return Action::template call<long>(std::forward<Args>(args)...);
240 case Datatype::LONGLONG:
241 return Action::template call<long long>(std::forward<Args>(args)...);
242 case Datatype::USHORT:
243 return Action::template call<unsigned short>(
244 std::forward<Args>(args)...);
246 return Action::template call<unsigned int>(std::forward<Args>(args)...);
247 case Datatype::ULONG:
248 return Action::template call<unsigned long>(
249 std::forward<Args>(args)...);
250 case Datatype::ULONGLONG:
251 return Action::template call<unsigned long long>(
252 std::forward<Args>(args)...);
253 case Datatype::FLOAT:
254 return Action::template call<float>(std::forward<Args>(args)...);
255 case Datatype::DOUBLE:
256 return Action::template call<double>(std::forward<Args>(args)...);
257 case Datatype::LONG_DOUBLE:
258 return Action::template call<long double>(std::forward<Args>(args)...);
259 case Datatype::CFLOAT:
260 return Action::template call<std::complex<float>>(
261 std::forward<Args>(args)...);
262 case Datatype::CDOUBLE:
263 return Action::template call<std::complex<double>>(
264 std::forward<Args>(args)...);
270 case Datatype::UNDEFINED:
272 CallUndefinedDatatype<0, ReturnType, Action, Args &&...>::call(
273 std::forward<Args>(args)...);
275 throw std::runtime_error(
276 "Internal error: Encountered unknown datatype (switchType) ->" +
277 std::to_string(static_cast<int>(dt)));
282 #endif // openPMD_HAVE_ADIOS2 auto switchAdios2VariableType(Datatype dt, Args &&...args) -> decltype(Action::template call< char >(std::forward< Args >(args)...))
Generalizes switching over an openPMD datatype.
Definition: ADIOS2Auxiliary.hpp:220
Definition: ADIOS2Auxiliary.hpp:70
auto switchAdios2AttributeType(Datatype dt, Args &&...args) -> decltype(Action::template call< char >(std::forward< Args >(args)...))
Generalizes switching over an openPMD datatype.
Definition: ADIOS2Auxiliary.hpp:140
Definition: ADIOS2Auxiliary.hpp:93
Datatype
Concrete datatype of an object available at runtime.
Definition: Datatype.hpp:45
Varidic datatype supporting at least all formats for attributes specified in the openPMD standard...
Definition: Attribute.hpp:54
Definition: Container.cpp:51
Public definitions of openPMD-api.
Definition: ADIOS2Auxiliary.hpp:47