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;
48 static std::string type( );
53 static std::string type( );
56 template <
typename T,
size_t n >
59 static std::string type( );
64 static std::string type( );
69 template <
typename T > std::string operator( )( );
72 template <
int n > std::string operator( )( );
81 Datatype fromADIOS2Type( std::string
const & dt,
bool verbose =
true );
83 enum class VariableOrAttribute : unsigned char
91 template<
typename T >
95 std::string
const & attributeName,
96 VariableOrAttribute );
98 template <
int n,
typename... Params >
99 Extent operator( )( Params &&... );
114 std::string
const & attributeName,
116 VariableOrAttribute = VariableOrAttribute::Attribute );
119 #if defined( _MSC_VER ) && !defined( __INTEL_COMPILER ) && !defined( __clang__ ) 120 #define OPENPMD_TEMPLATE_OPERATOR operator 122 #define OPENPMD_TEMPLATE_OPERATOR template operator 143 template<
typename Action,
typename... Args >
146 action.OPENPMD_TEMPLATE_OPERATOR() <
char >
147 ( std::forward< Args >( args )... ) )
149 using ReturnType = decltype(
150 action.OPENPMD_TEMPLATE_OPERATOR() <
char >
151 ( std::forward< Args >( args )... ) );
155 return action.OPENPMD_TEMPLATE_OPERATOR()<
char >(
156 std::forward< Args >( args )... );
157 case Datatype::UCHAR:
158 return action.OPENPMD_TEMPLATE_OPERATOR()<
unsigned char >(
159 std::forward< Args >( args )... );
160 case Datatype::SHORT:
161 return action.OPENPMD_TEMPLATE_OPERATOR()<
short >(
162 std::forward< Args >( args )... );
164 return action.OPENPMD_TEMPLATE_OPERATOR()<
int >(
165 std::forward< Args >( args )... );
167 return action.OPENPMD_TEMPLATE_OPERATOR()<
long >(
168 std::forward< Args >( args )... );
169 case Datatype::LONGLONG:
170 return action.OPENPMD_TEMPLATE_OPERATOR()<
long long >(
171 std::forward< Args >( args )... );
172 case Datatype::USHORT:
173 return action.OPENPMD_TEMPLATE_OPERATOR()<
unsigned short >(
174 std::forward< Args >( args )... );
176 return action.OPENPMD_TEMPLATE_OPERATOR()<
unsigned int >(
177 std::forward< Args >( args )... );
178 case Datatype::ULONG:
179 return action.OPENPMD_TEMPLATE_OPERATOR()<
unsigned long >(
180 std::forward< Args >( args )... );
181 case Datatype::ULONGLONG:
182 return action.OPENPMD_TEMPLATE_OPERATOR()<
unsigned long long >(
183 std::forward< Args >( args )... );
184 case Datatype::FLOAT:
185 return action.OPENPMD_TEMPLATE_OPERATOR()<
float >(
186 std::forward< Args >( args )... );
187 case Datatype::DOUBLE:
188 return action.OPENPMD_TEMPLATE_OPERATOR()<
double >(
189 std::forward< Args >( args )... );
190 case Datatype::LONG_DOUBLE:
191 return action.OPENPMD_TEMPLATE_OPERATOR()<
long double >(
192 std::forward< Args >( args )... );
193 case Datatype::CFLOAT:
194 return action.OPENPMD_TEMPLATE_OPERATOR()< std::complex< float > >(
195 std::forward< Args >( args )... );
196 case Datatype::CDOUBLE:
197 return action.OPENPMD_TEMPLATE_OPERATOR()< std::complex< double > >(
198 std::forward< Args >( args )... );
204 case Datatype::STRING:
205 return action.OPENPMD_TEMPLATE_OPERATOR()< std::string >(
206 std::forward< Args >( args )... );
207 case Datatype::DATATYPE:
214 call( std::move( action ), std::forward< Args >( args )... );
215 case Datatype::UNDEFINED:
222 call( std::move( action ), std::forward< Args >( args )... );
224 throw std::runtime_error(
225 "Internal error: Encountered unknown datatype (switchType) ->" +
226 std::to_string( static_cast< int >( dt ) ) );
249 template<
typename Action,
typename... Args >
252 action.OPENPMD_TEMPLATE_OPERATOR() <
char >
253 ( std::forward< Args >( args )... ) )
255 using ReturnType = decltype(
256 action.OPENPMD_TEMPLATE_OPERATOR() <
char >
257 ( std::forward< Args >( args )... ) );
261 return action.OPENPMD_TEMPLATE_OPERATOR()<
char >(
262 std::forward< Args >( args )... );
263 case Datatype::UCHAR:
264 return action.OPENPMD_TEMPLATE_OPERATOR()<
unsigned char >(
265 std::forward< Args >( args )... );
266 case Datatype::SHORT:
267 return action.OPENPMD_TEMPLATE_OPERATOR()<
short >(
268 std::forward< Args >( args )... );
270 return action.OPENPMD_TEMPLATE_OPERATOR()<
int >(
271 std::forward< Args >( args )... );
273 return action.OPENPMD_TEMPLATE_OPERATOR()<
long >(
274 std::forward< Args >( args )... );
275 case Datatype::LONGLONG:
276 return action.OPENPMD_TEMPLATE_OPERATOR()<
long long >(
277 std::forward< Args >( args )... );
278 case Datatype::USHORT:
279 return action.OPENPMD_TEMPLATE_OPERATOR()<
unsigned short >(
280 std::forward< Args >( args )... );
282 return action.OPENPMD_TEMPLATE_OPERATOR()<
unsigned int >(
283 std::forward< Args >( args )... );
284 case Datatype::ULONG:
285 return action.OPENPMD_TEMPLATE_OPERATOR()<
unsigned long >(
286 std::forward< Args >( args )... );
287 case Datatype::ULONGLONG:
288 return action.OPENPMD_TEMPLATE_OPERATOR()<
unsigned long long >(
289 std::forward< Args >( args )... );
290 case Datatype::FLOAT:
291 return action.OPENPMD_TEMPLATE_OPERATOR()<
float >(
292 std::forward< Args >( args )... );
293 case Datatype::DOUBLE:
294 return action.OPENPMD_TEMPLATE_OPERATOR()<
double >(
295 std::forward< Args >( args )... );
296 case Datatype::LONG_DOUBLE:
297 return action.OPENPMD_TEMPLATE_OPERATOR()<
long double >(
298 std::forward< Args >( args )... );
299 case Datatype::CFLOAT:
300 return action.OPENPMD_TEMPLATE_OPERATOR()< std::complex< float > >(
301 std::forward< Args >( args )... );
302 case Datatype::CDOUBLE:
303 return action.OPENPMD_TEMPLATE_OPERATOR()< std::complex< double > >(
304 std::forward< Args >( args )... );
310 case Datatype::DATATYPE:
317 call( std::move( action ), std::forward< Args >( args )... );
318 case Datatype::UNDEFINED:
325 call( std::move( action ), std::forward< Args >( args )... );
327 throw std::runtime_error(
328 "Internal error: Encountered unknown datatype (switchType) ->" +
329 std::to_string( static_cast< int >( dt ) ) );
333 #undef OPENPMD_TEMPLATE_OPERATOR 336 #endif // openPMD_HAVE_ADIOS2 Definition: ADIOS2Auxiliary.hpp:67
auto switchAdios2VariableType(Datatype dt, Action action, Args &&... args) -> decltype(action. template operator()< char >(std::forward< Args >(args)...))
Generalizes switching over an openPMD datatype.
Definition: ADIOS2Auxiliary.hpp:250
Purpose of this struct is to detect at compile time whether Action::template operator()<0>() exists...
Definition: DatatypeHelpers.hpp:82
Definition: ADIOS2Auxiliary.hpp:89
auto switchAdios2AttributeType(Datatype dt, Action action, Args &&... args) -> decltype(action. template operator()< char >(std::forward< Args >(args)...))
Generalizes switching over an openPMD datatype.
Definition: ADIOS2Auxiliary.hpp:144
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:50
Definition: Container.cpp:51
Public definitions of openPMD-api.
Definition: Date.cpp:29
Definition: ADIOS2Auxiliary.hpp:46