23 #include "openPMD/IO/AbstractIOHandler.hpp" 24 #include "openPMD/backend/Attribute.hpp" 25 #include "openPMD/backend/Writable.hpp" 26 #include "openPMD/auxiliary/OutOfRangeMsg.hpp" 36 #ifndef OPENPMD_protected 37 # define OPENPMD_protected protected 45 template<
typename T >
60 : std::runtime_error(what_arg)
80 using A_MAP = std::map< std::string, Attribute >;
96 using A_MAP = std::map< std::string, Attribute >;
98 template<
typename T_elem >
106 template<
typename T >
119 template<
typename T >
143 template<
typename T >
144 bool setAttribute(std::string
const& key,
T value);
145 bool setAttribute(std::string
const& key,
char const value[]);
155 Attribute getAttribute(std::string
const& key)
const;
162 bool deleteAttribute(std::string
const& key);
168 std::vector< std::string > attributes()
const;
173 size_t numAttributes()
const;
179 bool containsAttribute(std::string
const& key)
const;
186 std::string comment()
const;
211 std::string directory;
212 std::string seriesName;
213 std::string seriesExtension;
221 std::vector< std::string > group;
224 std::string filePath()
const;
246 Iteration const & containingIteration()
const;
252 void flushAttributes();
286 template<
typename T >
287 T readFloatingpoint(std::string
const& key)
const;
302 template<
typename T >
303 std::vector< T > readVectorFloatingpoint(std::string
const& key)
const;
309 return m_attri->m_writable.IOHandler.get();
313 return m_attri->m_writable.IOHandler.get();
317 return m_attri->m_writable.parent;
321 return m_attri->m_writable.parent;
325 return m_attri->m_writable;
329 return m_attri->m_writable;
341 throw std::runtime_error(
342 "[AttributableInterface] " 343 "Cannot use default-constructed Attributable." );
355 throw std::runtime_error(
356 "[AttributableInterface] " 357 "Cannot use default-constructed Attributable." );
361 bool dirty()
const {
return writable().dirty; }
362 bool& dirty() {
return writable().dirty; }
363 bool written()
const {
return writable().written; }
364 bool& written() {
return writable().written; }
372 virtual void linkHierarchy(
Writable& w);
382 std::shared_ptr< internal::AttributableData > m_attributableData =
383 std::make_shared< internal::AttributableData >();
388 AttributableInterface::m_attri = m_attributableData.get();
393 template<
typename T >
397 auto & attri =
get();
402 "can not be set (read-only)." 408 auto it = attri.m_attributes.lower_bound(key);
409 if( it != attri.m_attributes.end()
410 && !attri.m_attributes.key_comp()(key, it->first) )
418 attri.m_attributes.emplace_hint(
419 it, std::make_pair(key,
Attribute(std::move(value))));
426 return this->setAttribute(key, std::string(value));
429 template<
typename T >
432 static_assert(std::is_floating_point< T >::value,
"Type of attribute must be floating point");
434 return getAttribute(key).
get<
T >();
437 template<
typename T >
438 inline std::vector< T >
441 static_assert(std::is_floating_point< T >::value,
"Type of attribute must be floating point");
443 return getAttribute(key).
get< std::vector< T > >();
Return an error string for read-only access.
Definition: OutOfRangeMsg.hpp:37
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:439
Definition: Attributable.hpp:56
U get() const
Retrieve a stored specific Attribute and cast if convertible.
Definition: Attribute.hpp:232
Definition: Series.hpp:441
Container Element Creation Policy.
Definition: Attributable.hpp:46
Logical compilation of data from one snapshot (e.g.
Definition: Iteration.hpp:39
FlushLevel
Determine what items should be flushed upon Series::flush()
Definition: AbstractIOHandler.hpp:63
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:430
Writing side of the streaming API.
Definition: WriteIterations.hpp:47
Root level of the openPMD hierarchy.
Definition: Series.hpp:476
Varidic datatype supporting at least all formats for attributes specified in the openPMD standard...
Definition: Attribute.hpp:50
Interface for communicating between logical and physically persistent data.
Definition: AbstractIOHandler.hpp:98
Public definitions of openPMD-api.
Definition: Date.cpp:29
Layer to mirror structure of logical data and persistent data in file.
Definition: Writable.hpp:64
Layer to manage storage of attributes associated with file objects.
Definition: Attributable.hpp:93
Definition: Attributable.hpp:67
bool setAttribute(std::string const &key, T value)
Populate Attribute of provided name with provided value.
Definition: Attributable.hpp:395
Definition: BaseRecord.hpp:36
Implementation for the root level of the openPMD hierarchy.
Definition: Series.hpp:112
ReadMode
Definition: Attributable.hpp:252
String serialization to describe an Attributable.
Definition: Attributable.hpp:208
Map-like container that enforces openPMD requirements and handles IO.
Definition: Container.hpp:106
Definition: AbstractFilePosition.hpp:26
Definition: Attributable.hpp:379
open series as read-only, fails if series is not found