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 >
54 : std::runtime_error(what_arg)
67 using A_MAP = std::map< std::string, Attribute >;
69 template<
typename T_elem >
77 template<
typename T >
103 template<
typename T >
104 bool setAttribute(std::string
const& key,
T const& value);
105 bool setAttribute(std::string
const& key,
char const value[]);
115 Attribute getAttribute(std::string
const& key)
const;
122 bool deleteAttribute(std::string
const& key);
128 std::vector< std::string > attributes()
const;
133 size_t numAttributes()
const;
139 bool containsAttribute(std::string
const& key)
const;
146 std::string comment()
const;
155 void flushAttributes();
156 void readAttributes();
172 template<
typename T >
173 T readFloatingpoint(std::string
const& key)
const;
188 template<
typename T >
189 std::vector< T > readVectorFloatingpoint(std::string
const& key)
const;
191 std::shared_ptr< Writable > m_writable;
197 bool& dirty()
const {
return m_writable->dirty; }
198 bool& written()
const {
return m_writable->written; }
201 virtual void linkHierarchy(std::shared_ptr< Writable >
const& w);
203 std::shared_ptr< A_MAP > m_attributes;
207 template<
typename T >
215 "can not be set (read-only)." 221 auto it = m_attributes->lower_bound(key);
222 if( it != m_attributes->end() && !m_attributes->key_comp()(key, it->first) )
230 m_attributes->emplace_hint(it,
238 return this->setAttribute(key, std::string(value));
241 template<
typename T >
245 static_assert(std::is_floating_point< T >::value,
"Type of attribute must be floating point");
247 return getAttribute(key).get<
T >();
250 template<
typename T >
251 inline std::vector< T >
254 static_assert(std::is_floating_point< T >::value,
"Type of attribute must be floating point");
256 return getAttribute(key).get< std::vector< T > >();
Return an error string for read-only access.
Definition: OutOfRangeMsg.hpp:37
Definition: Attributable.hpp:50
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:243
Container Element Creation Policy.
Definition: Attributable.hpp:46
Logical compilation of data from one snapshot (e.g.
Definition: Iteration.hpp:38
bool setAttribute(std::string const &key, T const &value)
Populate Attribute of provided name with provided value.
Definition: Attributable.hpp:209
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:252
Root level of the openPMD hierarchy.
Definition: Series.hpp:64
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:68
Public definitions of openPMD-api.
Definition: Date.cpp:29
Layer to mirror structure of logical data and persistent data in file.
Definition: Writable.hpp:55
Definition: BaseRecord.hpp:36
Map-like container that enforces openPMD requirements and handles IO.
Definition: Container.hpp:70
Definition: AbstractFilePosition.hpp:26
open series as read-only, fails if series is not found
Layer to manage storage of attributes associated with file objects.
Definition: Attributable.hpp:65