openPMD-api
Public Member Functions | List of all members
openPMD::Attribute Class Reference

Varidic datatype supporting at least all formats for attributes specified in the openPMD standard. More...

#include <Attribute.hpp>

Inheritance diagram for openPMD::Attribute:
Inheritance graph
[legend]
Collaboration diagram for openPMD::Attribute:
Collaboration graph
[legend]

Public Member Functions

 Attribute (resource r)
 
template<typename T >
 Attribute (T &&val)
 Compiler bug: CUDA (nvcc) releases 11.0.3 (v11.0.221), 11.1 (v11.1.105):

no instance of constructor "openPMD::Attribute::Attribute" matches the argument list argument types are: (int)

Same with ICC 19.1.2 (both use EDG compiler frontends). More...

 
template<typename U >
get () const
 Retrieve a stored specific Attribute and cast if convertible. More...
 
template<typename U >
std::optional< U > getOptional () const
 Retrieve a stored specific Attribute and cast if convertible. More...
 
- Public Member Functions inherited from openPMD::auxiliary::Variant< Datatype, char, unsigned char, signed char, short, int, long, long long, unsigned short, unsigned int, unsigned long, unsigned long long, float, double, long double, std::complex< float >, std::complex< double >, std::complex< long double >, std::string, std::vector< char >, std::vector< short >, std::vector< int >, std::vector< long >, std::vector< long long >, std::vector< unsigned char >, std::vector< unsigned short >, std::vector< unsigned int >, std::vector< unsigned long >, std::vector< unsigned long long >, std::vector< float >, std::vector< double >, std::vector< long double >, std::vector< std::complex< float > >, std::vector< std::complex< double > >, std::vector< std::complex< long double > >, std::vector< signed char >, std::vector< std::string >, std::array< double, 7 >, bool >
 Variant (resource r)
 Construct a lightweight wrapper around a generic object that indicates the concrete datatype of the specific object stored. More...
 
get () const
 Retrieve a stored specific object of known datatype with ensured type-safety. More...
 
resource getResource () const
 Retrieve the stored generic object. More...
 
constexpr size_t index () const noexcept
 Retrieve the index of the alternative that is currently been held. More...
 

Additional Inherited Members

- Public Types inherited from openPMD::auxiliary::Variant< Datatype, char, unsigned char, signed char, short, int, long, long long, unsigned short, unsigned int, unsigned long, unsigned long long, float, double, long double, std::complex< float >, std::complex< double >, std::complex< long double >, std::string, std::vector< char >, std::vector< short >, std::vector< int >, std::vector< long >, std::vector< long long >, std::vector< unsigned char >, std::vector< unsigned short >, std::vector< unsigned int >, std::vector< unsigned long >, std::vector< unsigned long long >, std::vector< float >, std::vector< double >, std::vector< long double >, std::vector< std::complex< float > >, std::vector< std::complex< double > >, std::vector< std::complex< long double > >, std::vector< signed char >, std::vector< std::string >, std::array< double, 7 >, bool >
using resource = std::variant< T... >
 
- Public Attributes inherited from openPMD::auxiliary::Variant< Datatype, char, unsigned char, signed char, short, int, long, long long, unsigned short, unsigned int, unsigned long, unsigned long long, float, double, long double, std::complex< float >, std::complex< double >, std::complex< long double >, std::string, std::vector< char >, std::vector< short >, std::vector< int >, std::vector< long >, std::vector< long long >, std::vector< unsigned char >, std::vector< unsigned short >, std::vector< unsigned int >, std::vector< unsigned long >, std::vector< unsigned long long >, std::vector< float >, std::vector< double >, std::vector< long double >, std::vector< std::complex< float > >, std::vector< std::complex< double > >, std::vector< std::complex< long double > >, std::vector< signed char >, std::vector< std::string >, std::array< double, 7 >, bool >
Datatype dtype
 

Detailed Description

Varidic datatype supporting at least all formats for attributes specified in the openPMD standard.

Note
Extending and/or modifying the available formats requires identical modifications to Datatype.

Constructor & Destructor Documentation

◆ Attribute()

template<typename T >
openPMD::Attribute::Attribute ( T &&  val)
inline

Compiler bug: CUDA (nvcc) releases 11.0.3 (v11.0.221), 11.1 (v11.1.105):

no instance of constructor "openPMD::Attribute::Attribute" matches the argument list argument types are: (int)

Same with ICC 19.1.2 (both use EDG compiler frontends).

Fix by explicitly instantiating resource

Member Function Documentation

◆ get()

template<typename U >
U openPMD::Attribute::get ( ) const

Retrieve a stored specific Attribute and cast if convertible.

Note
This performs a static_cast and might introduce precision loss if requested. Check dtype explicitly beforehand if needed.
Exceptions
std::runtime_errorif stored object is not static castable to U.
Template Parameters
UType of the object to be casted to.
Returns
Copy of the retrieved object, casted to type U.

◆ getOptional()

template<typename U >
std::optional< U > openPMD::Attribute::getOptional ( ) const

Retrieve a stored specific Attribute and cast if convertible.

Like Attribute::get<>(), but returns an empty std::optional if no conversion is possible instead of throwing an exception.

Note
This performs a static_cast and might introduce precision loss if requested. Check dtype explicitly beforehand if needed.
Template Parameters
UType of the object to be casted to.
Returns
Copy of the retrieved object, casted to type U. An empty std::optional if no conversion is possible.

The documentation for this class was generated from the following file: