23 #include "openPMD/IO/AbstractIOHandler.hpp"
24 #include "openPMD/ThrowError.hpp"
25 #include "openPMD/auxiliary/OutOfRangeMsg.hpp"
26 #include "openPMD/backend/Attribute.hpp"
27 #include "openPMD/backend/Writable.hpp"
34 #include <type_traits>
38 #ifndef OPENPMD_protected
39 #define OPENPMD_protected protected:
47 struct GenerationPolicy;
49 class AbstractFilePosition;
69 using A_MAP = std::map<std::string, Attribute>;
96 using A_MAP = std::map<std::string, Attribute>;
98 template <
typename T_elem>
100 template <
typename T_elem>
101 friend class BaseRecordInterface;
104 template <
typename T,
typename T_key,
typename T_container>
106 template <
typename T>
114 std::shared_ptr<internal::AttributableData> m_attri{
118 Attributable(std::shared_ptr<internal::AttributableData>);
139 template <
typename T>
141 bool setAttribute(std::string
const &key,
char const value[]);
205 void seriesFlush(std::string backendConfig =
"{}");
215 std::string directory;
243 Series retrieveSeries()
const;
300 template <
typename T>
323 template <
typename T>
334 AbstractIOHandler
const *IOHandler()
const
336 auto &opt = m_attri->m_writable.IOHandler;
337 if (!opt || !opt->has_value())
341 return &*opt->value();
345 return m_attri->m_writable.parent;
347 Writable
const *parent()
const
349 return m_attri->m_writable.parent;
353 return m_attri->m_writable;
355 Writable
const &writable()
const
357 return m_attri->m_writable;
360 inline void setData(std::shared_ptr<internal::AttributableData> attri)
362 m_attri = std::move(attri);
365 inline internal::AttributableData &get()
369 inline internal::AttributableData
const &get()
const
376 return writable().dirty;
380 return writable().dirty;
397 virtual void linkHierarchy(Writable &w);
402 template <
typename T>
411 "Attribute",
"can not be set (read-only).");
412 error::throwNoSuchAttribute(out_of_range_msg(key));
416 auto it = attri.m_attributes.lower_bound(key);
417 if (it != attri.m_attributes.end() &&
418 !attri.m_attributes.key_comp()(key, it->first))
421 it->second =
Attribute(std::move(value));
427 attri.m_attributes.emplace_hint(
428 it, std::make_pair(key,
Attribute(std::move(value))));
439 template <
typename T>
443 std::is_floating_point<T>::value,
444 "Type of attribute must be floating point");
449 template <
typename T>
450 inline std::vector<T>
454 std::is_floating_point<T>::value,
455 "Type of attribute must be floating point");
Interface for communicating between logical and physically persistent data.
Definition: AbstractIOHandler.hpp:180
Layer to manage storage of attributes associated with file objects.
Definition: Attributable.hpp:94
std::vector< T > readVectorFloatingpoint(std::string const &key) const
Retrieve a vector of values of a floating point Attributes of user-defined precision with ensured typ...
Definition: Attributable.hpp:451
bool containsAttribute(std::string const &key) const
Check whether am Attribute with a given key exists.
Definition: Attributable.cpp:92
MyPath myPath() const
The path to this object within its containing Series.
Definition: Attributable.cpp:180
ReadMode
Definition: Attributable.hpp:261
@ FullyReread
Remove all attributes that have been read previously and read everything that the backend currently h...
Definition: Attributable.hpp:276
@ IgnoreExisting
Don't read an attribute from the backend if it has been previously read.
Definition: Attributable.hpp:266
@ OverrideExisting
Read all the attributes that the backend has to offer and override if it has been read previously.
Definition: Attributable.hpp:271
std::vector< std::string > attributes() const
List all currently stored Attributes' keys.
Definition: Attributable.cpp:76
Attribute getAttribute(std::string const &key) const
Retrieve value of Attribute stored with provided key.
Definition: Attributable.cpp:46
void seriesFlush(std::string backendConfig="{}")
Flush the corresponding Series object.
Definition: Attributable.cpp:109
T readFloatingpoint(std::string const &key) const
Retrieve the value of a floating point Attribute of user-defined precision with ensured type-safety.
Definition: Attributable.hpp:440
size_t numAttributes() const
Count all currently stored Attributes.
Definition: Attributable.cpp:87
bool deleteAttribute(std::string const &key)
Remove Attribute of provided value both logically and physically.
Definition: Attributable.cpp:56
bool setAttribute(std::string const &key, T value)
Populate Attribute of provided name with provided value.
Definition: Attributable.hpp:403
Attributable & setComment(std::string const &comment)
Populate Attribute corresponding to a comment with the user-supplied comment.
Definition: Attributable.cpp:103
std::string comment() const
Retrieve a user-supplied comment associated with the object.
Definition: Attributable.cpp:98
Iteration const & containingIteration() const
Returns the corresponding Iteration.
Definition: Attributable.cpp:126
Varidic datatype supporting at least all formats for attributes specified in the openPMD standard.
Definition: Attribute.hpp:95
U get() const
Retrieve a stored specific Attribute and cast if convertible.
Definition: Attribute.hpp:253
Definition: BaseRecord.hpp:59
Map-like container that enforces openPMD requirements and handles IO.
Definition: Container.hpp:132
Logical compilation of data from one snapshot (e.g.
Definition: Iteration.hpp:127
Implementation for the root level of the openPMD hierarchy.
Definition: Series.hpp:206
Layer to mirror structure of logical data and persistent data in file.
Definition: Writable.hpp:65
bool written
Whether a Writable has been written to the backend.
Definition: Writable.hpp:159
Writing side of the streaming API.
Definition: WriteIterations.hpp:67
Return an error string for read-only access.
Definition: OutOfRangeMsg.hpp:37
Definition: Attributable.hpp:57
Writable m_writable
The Writable associated with this Attributable.
Definition: Attributable.hpp:75
Definition: BaseRecord.hpp:37
@ Default
Mutability of objects in the openPMD object model is determined by the open mode (Access enum),...
Public definitions of openPMD-api.
Definition: Date.cpp:29
Access
File access mode to use during IO.
Definition: Access.hpp:30
@ READ_ONLY
Open Series as read-only, fails if Series is not found.
String serialization to describe an Attributable.
Definition: Attributable.hpp:214
std::string filePath() const
Reconstructs a path that can be passed to a Series constructor.
Definition: Attributable.cpp:175
std::string seriesName
e.g., samples/git-samples/
Definition: Attributable.hpp:216
std::string seriesExtension
e.g., dataT
Definition: Attributable.hpp:217
std::vector< std::string > group
e.g., .bp, .h5, .json, ...
Definition: Attributable.hpp:225
Parameters recursively passed through the openPMD hierarchy when flushing.
Definition: AbstractIOHandler.hpp:85
Container Element Creation Policy.
Definition: Container.hpp:51