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 &&... );
117 std::string
const & attributeName,
119 VariableOrAttribute voa = VariableOrAttribute::Attribute );
122 #if defined( _MSC_VER ) && !defined( __INTEL_COMPILER ) && !defined( __clang__ ) 123 #define OPENPMD_TEMPLATE_OPERATOR operator 125 #define OPENPMD_TEMPLATE_OPERATOR template operator 146 template<
typename Action,
typename... Args >
149 action.OPENPMD_TEMPLATE_OPERATOR() <
char >
150 ( std::forward< Args >( args )... ) )
152 using ReturnType = decltype(
153 action.OPENPMD_TEMPLATE_OPERATOR() <
char >
154 ( std::forward< Args >( args )... ) );
158 return action.OPENPMD_TEMPLATE_OPERATOR()<
char >(
159 std::forward< Args >( args )... );
160 case Datatype::UCHAR:
161 return action.OPENPMD_TEMPLATE_OPERATOR()<
unsigned char >(
162 std::forward< Args >( args )... );
163 case Datatype::SHORT:
164 return action.OPENPMD_TEMPLATE_OPERATOR()<
short >(
165 std::forward< Args >( args )... );
167 return action.OPENPMD_TEMPLATE_OPERATOR()<
int >(
168 std::forward< Args >( args )... );
170 return action.OPENPMD_TEMPLATE_OPERATOR()<
long >(
171 std::forward< Args >( args )... );
172 case Datatype::LONGLONG:
173 return action.OPENPMD_TEMPLATE_OPERATOR()<
long long >(
174 std::forward< Args >( args )... );
175 case Datatype::USHORT:
176 return action.OPENPMD_TEMPLATE_OPERATOR()<
unsigned short >(
177 std::forward< Args >( args )... );
179 return action.OPENPMD_TEMPLATE_OPERATOR()<
unsigned int >(
180 std::forward< Args >( args )... );
181 case Datatype::ULONG:
182 return action.OPENPMD_TEMPLATE_OPERATOR()<
unsigned long >(
183 std::forward< Args >( args )... );
184 case Datatype::ULONGLONG:
185 return action.OPENPMD_TEMPLATE_OPERATOR()<
unsigned long long >(
186 std::forward< Args >( args )... );
187 case Datatype::FLOAT:
188 return action.OPENPMD_TEMPLATE_OPERATOR()<
float >(
189 std::forward< Args >( args )... );
190 case Datatype::DOUBLE:
191 return action.OPENPMD_TEMPLATE_OPERATOR()<
double >(
192 std::forward< Args >( args )... );
193 case Datatype::LONG_DOUBLE:
194 return action.OPENPMD_TEMPLATE_OPERATOR()<
long double >(
195 std::forward< Args >( args )... );
196 case Datatype::CFLOAT:
197 return action.OPENPMD_TEMPLATE_OPERATOR()< std::complex< float > >(
198 std::forward< Args >( args )... );
199 case Datatype::CDOUBLE:
200 return action.OPENPMD_TEMPLATE_OPERATOR()< std::complex< double > >(
201 std::forward< Args >( args )... );
207 case Datatype::STRING:
208 return action.OPENPMD_TEMPLATE_OPERATOR()< std::string >(
209 std::forward< Args >( args )... );
210 case Datatype::DATATYPE:
217 call( std::move( action ), std::forward< Args >( args )... );
218 case Datatype::UNDEFINED:
225 call( std::move( action ), std::forward< Args >( args )... );
227 throw std::runtime_error(
228 "Internal error: Encountered unknown datatype (switchType) ->" +
229 std::to_string( static_cast< int >( dt ) ) );
252 template<
typename Action,
typename... Args >
255 action.OPENPMD_TEMPLATE_OPERATOR() <
char >
256 ( std::forward< Args >( args )... ) )
258 using ReturnType = decltype(
259 action.OPENPMD_TEMPLATE_OPERATOR() <
char >
260 ( std::forward< Args >( args )... ) );
264 return action.OPENPMD_TEMPLATE_OPERATOR()<
char >(
265 std::forward< Args >( args )... );
266 case Datatype::UCHAR:
267 return action.OPENPMD_TEMPLATE_OPERATOR()<
unsigned char >(
268 std::forward< Args >( args )... );
269 case Datatype::SHORT:
270 return action.OPENPMD_TEMPLATE_OPERATOR()<
short >(
271 std::forward< Args >( args )... );
273 return action.OPENPMD_TEMPLATE_OPERATOR()<
int >(
274 std::forward< Args >( args )... );
276 return action.OPENPMD_TEMPLATE_OPERATOR()<
long >(
277 std::forward< Args >( args )... );
278 case Datatype::LONGLONG:
279 return action.OPENPMD_TEMPLATE_OPERATOR()<
long long >(
280 std::forward< Args >( args )... );
281 case Datatype::USHORT:
282 return action.OPENPMD_TEMPLATE_OPERATOR()<
unsigned short >(
283 std::forward< Args >( args )... );
285 return action.OPENPMD_TEMPLATE_OPERATOR()<
unsigned int >(
286 std::forward< Args >( args )... );
287 case Datatype::ULONG:
288 return action.OPENPMD_TEMPLATE_OPERATOR()<
unsigned long >(
289 std::forward< Args >( args )... );
290 case Datatype::ULONGLONG:
291 return action.OPENPMD_TEMPLATE_OPERATOR()<
unsigned long long >(
292 std::forward< Args >( args )... );
293 case Datatype::FLOAT:
294 return action.OPENPMD_TEMPLATE_OPERATOR()<
float >(
295 std::forward< Args >( args )... );
296 case Datatype::DOUBLE:
297 return action.OPENPMD_TEMPLATE_OPERATOR()<
double >(
298 std::forward< Args >( args )... );
299 case Datatype::LONG_DOUBLE:
300 return action.OPENPMD_TEMPLATE_OPERATOR()<
long double >(
301 std::forward< Args >( args )... );
302 case Datatype::CFLOAT:
303 return action.OPENPMD_TEMPLATE_OPERATOR()< std::complex< float > >(
304 std::forward< Args >( args )... );
305 case Datatype::CDOUBLE:
306 return action.OPENPMD_TEMPLATE_OPERATOR()< std::complex< double > >(
307 std::forward< Args >( args )... );
313 case Datatype::DATATYPE:
320 call( std::move( action ), std::forward< Args >( args )... );
321 case Datatype::UNDEFINED:
328 call( std::move( action ), std::forward< Args >( args )... );
330 throw std::runtime_error(
331 "Internal error: Encountered unknown datatype (switchType) ->" +
332 std::to_string( static_cast< int >( dt ) ) );
336 #undef OPENPMD_TEMPLATE_OPERATOR 339 #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:253
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:147
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