23 #include "openPMD/backend/BaseRecordComponent.hpp" 25 #include <unordered_map> 31 #ifndef OPENPMD_private 32 # define OPENPMD_private private 56 uint8_t getDimensionality()
const;
57 Extent getExtent()
const;
59 template<
typename T >
60 std::shared_ptr< T > load();
61 template<
typename T >
62 void load(std::shared_ptr< T >);
63 template<
typename T >
64 void store(uint64_t idx,
T);
70 void flush(std::string
const&);
73 std::shared_ptr< std::queue< IOTask > > m_chunks;
76 template<
typename T >
77 inline std::shared_ptr< T >
78 PatchRecordComponent::load()
80 uint64_t numPoints = getExtent()[0];
81 auto newData = std::shared_ptr< T >(
new T[numPoints], []( T *p ){
delete [] p; });
86 template<
typename T >
88 PatchRecordComponent::load(std::shared_ptr< T > data)
90 Datatype dtype = determineDatatype< T >();
91 if( dtype != getDatatype() )
92 throw std::runtime_error(
"Type conversion during particle patch loading not yet implemented");
95 throw std::runtime_error(
"Unallocated pointer passed during ParticlePatch loading.");
97 uint64_t numPoints = getExtent()[0];
103 dRead.extent = {numPoints};
104 dRead.dtype = getDatatype();
105 dRead.data = std::static_pointer_cast<
void >(data);
106 m_chunks->push(
IOTask(
this, dRead));
109 template<
typename T >
111 PatchRecordComponent::store(uint64_t idx,
T data)
113 Datatype dtype = determineDatatype< T >();
114 if( dtype != getDatatype() )
116 std::ostringstream oss;
117 oss <<
"Datatypes of patch data (" 121 <<
") do not match.";
122 throw std::runtime_error(oss.str());
125 Extent dse = getExtent();
126 if( dse[0] - 1u < idx )
127 throw std::runtime_error(
"Index does not reside inside patch (no. patches: " + std::to_string(dse[0])
128 +
" - index: " + std::to_string(idx) +
")");
131 dWrite.offset = {idx};
133 dWrite.dtype = dtype;
134 dWrite.data = std::make_shared< T >(data);
135 m_chunks->push(
IOTask(
this, dWrite));
Definition: ParticlePatches.hpp:32
Definition: Dataset.hpp:36
Self-contained description of a single IO operation.
Definition: IOTask.hpp:468
Definition: PatchRecord.hpp:32
Datatype
Concrete datatype of an object available at runtime.
Definition: Datatype.hpp:38
Public definitions of openPMD-api.
Definition: Date.cpp:28
Definition: IOTask.hpp:332
Definition: PatchRecordComponent.hpp:38
Map-like container that enforces openPMD requirements and handles IO.
Definition: Container.hpp:70
Definition: IOTask.hpp:303
Definition: BaseRecordComponent.hpp:34