23 #include "openPMD/backend/BaseRecordComponent.hpp" 25 #include <unordered_map> 31 #ifndef OPENPMD_private 32 # define OPENPMD_private private 61 uint8_t getDimensionality()
const;
62 Extent getExtent()
const;
64 template<
typename T >
65 std::shared_ptr< T > load();
66 template<
typename T >
67 void load(std::shared_ptr< T >);
68 template<
typename T >
69 void store(uint64_t idx,
T);
74 void flush(std::string
const&);
77 std::shared_ptr< std::queue< IOTask > > m_chunks;
78 std::shared_ptr< bool > hasBeenRead = std::make_shared< bool >( false );
89 dirtyRecursive()
const;
92 template<
typename T >
93 inline std::shared_ptr< T >
94 PatchRecordComponent::load()
96 uint64_t numPoints = getExtent()[0];
97 auto newData = std::shared_ptr< T >(
new T[numPoints], []( T *p ){
delete [] p; });
102 template<
typename T >
104 PatchRecordComponent::load(std::shared_ptr< T > data)
106 Datatype dtype = determineDatatype< T >();
107 if( dtype != getDatatype() )
108 throw std::runtime_error(
"Type conversion during particle patch loading not yet implemented");
111 throw std::runtime_error(
"Unallocated pointer passed during ParticlePatch loading.");
113 uint64_t numPoints = getExtent()[0];
119 dRead.extent = {numPoints};
120 dRead.dtype = getDatatype();
121 dRead.data = std::static_pointer_cast<
void >(data);
122 m_chunks->push(
IOTask(
this, dRead));
125 template<
typename T >
127 PatchRecordComponent::store(uint64_t idx,
T data)
129 Datatype dtype = determineDatatype< T >();
130 if( dtype != getDatatype() )
132 std::ostringstream oss;
133 oss <<
"Datatypes of patch data (" 137 <<
") do not match.";
138 throw std::runtime_error(oss.str());
141 Extent dse = getExtent();
142 if( dse[0] - 1u < idx )
143 throw std::runtime_error(
"Index does not reside inside patch (no. patches: " + std::to_string(dse[0])
144 +
" - index: " + std::to_string(idx) +
")");
147 dWrite.offset = {idx};
149 dWrite.dtype = dtype;
150 dWrite.data = std::make_shared< T >(data);
151 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:550
Definition: PatchRecord.hpp:32
Datatype
Concrete datatype of an object available at runtime.
Definition: Datatype.hpp:42
Public definitions of openPMD-api.
Definition: Date.cpp:29
Definition: IOTask.hpp:365
Definition: BaseRecord.hpp:36
Definition: PatchRecordComponent.hpp:42
Map-like container that enforces openPMD requirements and handles IO.
Definition: Container.hpp:70
Definition: IOTask.hpp:336
Definition: BaseRecordComponent.hpp:34