23 #include "openPMD/config.hpp" 24 #if openPMD_HAVE_ADIOS2 31 #include <type_traits> 33 #include "openPMD/Datatype.hpp" 76 char *destroy =
nullptr;
100 std::vector<char> m_rawBuffer;
101 std::map<std::string, AttributeLocation> m_offsets;
123 void preloadAttributes(adios2::IO &IO, adios2::Engine &engine);
135 template <
typename T>
138 Datatype attributeType(std::string
const &name)
const;
141 template <
typename T>
145 auto it = m_offsets.find(name);
146 if (it == m_offsets.end())
148 throw std::runtime_error(
149 "[ADIOS2] Requested attribute not found: " + name);
152 Datatype determinedDatatype = determineDatatype<T>();
153 if (std::is_same<T, signed char>::value)
158 determinedDatatype = Datatype::CHAR;
160 if (location.dt != determinedDatatype)
162 std::stringstream errorMsg;
163 errorMsg <<
"[ADIOS2] Wrong datatype for attribute: " << name
164 <<
"(location.dt=" << location.dt
165 <<
", T=" << determineDatatype<T>() <<
")";
166 throw std::runtime_error(errorMsg.str());
169 res.shape = location.shape;
170 res.data =
reinterpret_cast<T const *
>(&m_rawBuffer[location.offset]);
176 #endif // openPMD_HAVE_ADIOS2
Pointer to an attribute's data along with its shape.
Definition: ADIOS2PreloadAttributes.hpp:45
Datatype
Concrete datatype of an object available at runtime.
Definition: Datatype.hpp:45
Definition: Container.cpp:50
Public definitions of openPMD-api.
Definition: Date.cpp:28
Class that is responsible for scheduling and buffering openPMD attribute loads from ADIOS2...
Definition: ADIOS2PreloadAttributes.hpp:63
Internally used struct to store meta information on a buffered attribute.
Definition: ADIOS2PreloadAttributes.hpp:71
AttributeWithShape< T > getAttribute(std::string const &name) const
Get an attribute that has been buffered previously.
Definition: ADIOS2PreloadAttributes.hpp:143