23 #include "openPMD/Dataset.hpp"
24 #include "openPMD/Datatype.hpp"
25 #include "openPMD/auxiliary/ShareRaw.hpp"
26 #include "openPMD/auxiliary/TypeTraits.hpp"
27 #include "openPMD/auxiliary/UniquePtr.hpp"
28 #include "openPMD/backend/BaseRecordComponent.hpp"
38 #include <type_traits>
43 #ifndef OPENPMD_protected
44 #define OPENPMD_protected protected:
51 class DynamicMemoryView;
53 class RecordComponent;
73 void push_chunk(
IOTask &&task);
102 void reset()
override
104 BaseRecordComponentData::reset();
112 template <
typename,
typename>
113 class BaseRecordData;
121 template <
typename T,
typename T_key,
typename T_container>
127 template <
typename,
typename>
137 enum class Allocation
175 uint8_t getDimensionality()
const;
176 Extent getExtent()
const;
186 template <
typename T>
197 template <
typename T>
226 template <
typename T>
227 std::shared_ptr<T>
loadChunk(Offset = {0u}, Extent = {-1u});
229 using shared_ptr_dataset_types = auxiliary::detail::
230 map_variant<auxiliary::detail::as_shared_pointer, dataset_types>::type;
265 template <
typename T>
266 void loadChunk(std::shared_ptr<T> data, Offset offset, Extent extent);
284 template <
typename T>
285 void loadChunk(std::shared_ptr<T[]> data, Offset offset, Extent extent);
302 template <
typename T>
323 template <
typename T>
324 void storeChunk(std::shared_ptr<T> data, Offset offset, Extent extent);
335 template <
typename T>
336 void storeChunk(std::shared_ptr<T[]> data, Offset offset, Extent extent);
350 template <
typename T>
365 template <
typename T,
typename Del>
366 void storeChunk(std::unique_ptr<T, Del> data, Offset offset, Extent extent);
380 template <
typename T>
398 template <
typename T_ContiguousContainer>
399 typename std::enable_if_t<
400 auxiliary::IsContiguousContainer_v<T_ContiguousContainer>>
402 T_ContiguousContainer &data,
403 Offset offset = {0u},
404 Extent extent = {-1u});
439 template <
typename T,
typename F>
447 template <
typename T>
480 template <
typename Visitor,
typename... Args>
481 auto visit(Args &&...args) -> decltype(Visitor::template call<char>(
482 std::declval<RecordComponent &>(),
483 std::forward<Args>(args)...));
485 static constexpr
char const *
const SCALAR =
"\vScalar";
489 void read(
bool require_unit_si);
508 std::shared_ptr<Data_t> m_recordComponentData;
513 inline Data_t const &get()
const
517 return *m_recordComponentData;
522 setDatasetDefined(*m_recordComponentData);
523 return *m_recordComponentData;
526 inline void setData(std::shared_ptr<internal::RecordComponentData> data)
528 m_recordComponentData = std::move(data);
529 BaseRecordComponent::setData(m_recordComponentData);
532 void readBase(
bool require_unit_si);
534 template <
typename T>
535 void verifyChunk(Offset
const &, Extent
const &)
const;
537 void verifyChunk(
Datatype, Offset
const &, Extent
const &)
const;
542 #include "RecordComponent.tpp"
Variant datatype supporting at least all formats for attributes specified in the openPMD standard.
Definition: Attribute.hpp:56
Definition: BaseRecordComponent.hpp:81
Base class for any type of record (e.g.
Definition: BaseRecord.hpp:224
Map-like container that enforces openPMD requirements and handles IO.
Definition: Container.hpp:104
Definition: Dataset.hpp:38
A view into a buffer that might be reallocated at some points and thus has changing base pointers ove...
Definition: Span.hpp:97
Self-contained description of a single IO operation.
Definition: IOTask.hpp:670
Logical compilation of data from one snapshot (e.g.
Definition: Iteration.hpp:127
Container for N-dimensional, homogeneous Records.
Definition: Mesh.hpp:41
Definition: MeshRecordComponent.hpp:36
Definition: ParticleSpecies.hpp:34
Definition: RecordComponent.hpp:120
void loadChunk(std::shared_ptr< T[]> data, Offset offset, Extent extent)
Load a chunk of data into pre-allocated memory, array version.
RecordComponent & makeEmpty(uint8_t dimensions)
Create a dataset with zero extent in each dimension.
void storeChunk(UniquePtrWithLambda< T > data, Offset offset, Extent extent)
Store a chunk of data from a chunk of memory, unique pointer version.
DynamicMemoryView< T > storeChunk(Offset offset, Extent extent, F &&createBuffer)
Overload of storeChunk() that lets the openPMD API allocate a buffer.
void loadChunk(std::shared_ptr< T > data, Offset offset, Extent extent)
Load a chunk of data into pre-allocated memory.
virtual RecordComponent & resetDataset(Dataset)
Declare the dataset's type and extent.
Definition: RecordComponent.cpp:84
auto visit(Args &&...args) -> decltype(Visitor::template call< char >(std::declval< RecordComponent & >(), std::forward< Args >(args)...))
Run a template functor on the type of the record component, similar to std::visit().
bool empty() const
Returns true if this is an empty record component.
Definition: RecordComponent.cpp:229
std::enable_if_t< auxiliary::IsContiguousContainer_v< T_ContiguousContainer > > storeChunk(T_ContiguousContainer &data, Offset offset={0u}, Extent extent={-1u})
Store a chunk of data from a contiguous container.
void storeChunk(std::shared_ptr< T > data, Offset offset, Extent extent)
Store a chunk of data from a chunk of memory.
shared_ptr_dataset_types loadChunkVariant(Offset={0u}, Extent={-1u})
std::variant-based version of allocating loadChunk<T>(Offset, Extent)
Definition: RecordComponent.cpp:560
void storeChunk(std::unique_ptr< T, Del > data, Offset offset, Extent extent)
Store a chunk of data from a chunk of memory, unique pointer version.
void storeChunkRaw(T *data, Offset offset, Extent extent)
Store a chunk of data from a chunk of memory, raw pointer version.
std::shared_ptr< T > loadChunk(Offset={0u}, Extent={-1u})
Load and allocate a chunk of data.
void storeChunk(std::shared_ptr< T[]> data, Offset offset, Extent extent)
Store a chunk of data from a chunk of memory, array version.
void loadChunkRaw(T *data, Offset offset, Extent extent)
Load a chunk of data into pre-allocated memory, raw pointer version.
RecordComponent & makeConstant(T)
Create a dataset with regular extent and constant value.
DynamicMemoryView< T > storeChunk(Offset, Extent)
Overload of span-based storeChunk() that uses operator new() to create a buffer.
Definition: Record.hpp:33
Unique Pointer class that uses a dynamic destructor type.
Definition: UniquePtr.hpp:80
Definition: Attributable.hpp:57
Definition: BaseRecordComponent.hpp:39
Definition: BaseRecord.hpp:52
Definition: RecordComponent.hpp:58
bool m_hasBeenExtended
User has extended the dataset, but the EXTEND task must yet be flushed to the backend.
Definition: RecordComponent.hpp:100
std::queue< IOTask > m_chunks
Chunk reading/writing requests on the contained dataset.
Definition: RecordComponent.hpp:71
Attribute m_constantValue
Stores the value for constant record components.
Definition: RecordComponent.hpp:78
bool m_isEmpty
True if this component is an empty dataset, i.e.
Definition: RecordComponent.hpp:95
std::string m_name
The same std::string that the parent class would pass as parameter to RecordComponent::flush().
Definition: RecordComponent.hpp:88
Public definitions of openPMD-api.
Definition: Date.cpp:29
Datatype
Concrete datatype of an object available at runtime.
Definition: Datatype.hpp:51
Definition: Attributable.hpp:125
Definition: Memory.hpp:175
Parameters recursively passed through the openPMD hierarchy when flushing.
Definition: AbstractIOHandler.hpp:86