23 #include "openPMD/backend/BaseRecordComponent.hpp" 28 #include <unordered_map> 31 #ifndef OPENPMD_private 32 #define OPENPMD_private private 43 template <
typename T,
typename T_key,
typename T_container>
56 uint8_t getDimensionality()
const;
57 Extent getExtent()
const;
60 std::shared_ptr<T> load();
62 void load(std::shared_ptr<T>);
64 void store(uint64_t idx,
T);
72 std::shared_ptr<std::queue<IOTask> > m_chunks;
82 bool dirtyRecursive()
const;
86 inline std::shared_ptr<T> PatchRecordComponent::load()
88 uint64_t numPoints = getExtent()[0];
90 std::shared_ptr<T>(
new T[numPoints], [](T *p) {
delete[] p; });
96 inline void PatchRecordComponent::load(std::shared_ptr<T> data)
98 Datatype dtype = determineDatatype<T>();
99 if (dtype != getDatatype())
100 throw std::runtime_error(
101 "Type conversion during particle patch loading not yet " 105 throw std::runtime_error(
106 "Unallocated pointer passed during ParticlePatch loading.");
108 uint64_t numPoints = getExtent()[0];
114 dRead.extent = {numPoints};
115 dRead.dtype = getDatatype();
116 dRead.data = std::static_pointer_cast<
void>(data);
117 m_chunks->push(
IOTask(
this, dRead));
120 template <
typename T>
121 inline void PatchRecordComponent::store(uint64_t idx,
T data)
123 Datatype dtype = determineDatatype<T>();
124 if (dtype != getDatatype())
126 std::ostringstream oss;
127 oss <<
"Datatypes of patch data (" << dtype <<
") and dataset (" 128 << getDatatype() <<
") do not match.";
129 throw std::runtime_error(oss.str());
132 Extent dse = getExtent();
133 if (dse[0] - 1u < idx)
134 throw std::runtime_error(
135 "Index does not reside inside patch (no. patches: " +
136 std::to_string(dse[0]) +
" - index: " + std::to_string(idx) +
")");
139 dWrite.offset = {idx};
141 dWrite.dtype = dtype;
142 dWrite.data = std::make_shared<T>(data);
143 m_chunks->push(
IOTask(
this, dWrite));
Definition: ParticlePatches.hpp:31
Definition: Dataset.hpp:35
Self-contained description of a single IO operation.
Definition: IOTask.hpp:615
Definition: PatchRecord.hpp:31
Datatype
Concrete datatype of an object available at runtime.
Definition: Datatype.hpp:45
Public definitions of openPMD-api.
Definition: Date.cpp:28
Definition: IOTask.hpp:384
Definition: BaseRecord.hpp:35
Parameters recursively passed through the openPMD hierarchy when flushing.
Definition: AbstractIOHandler.hpp:103
Definition: PatchRecordComponent.hpp:41
Map-like container that enforces openPMD requirements and handles IO.
Definition: Container.hpp:105
Definition: IOTask.hpp:350
Definition: BaseRecordComponent.hpp:33