23 #include "openPMD/Error.hpp"
24 #include "openPMD/IO/Access.hpp"
25 #include "openPMD/auxiliary/TypeTraits.hpp"
26 #include "openPMD/backend/Attributable.hpp"
27 #include "openPMD/backend/HierarchyVisitor.hpp"
29 #include <initializer_list>
34 #include <type_traits>
38 #ifndef OPENPMD_protected
39 #define OPENPMD_protected protected:
55 constexpr
static bool is_noop =
true;
66 class EraseStaleEntries;
70 typename T_key = std::string,
71 typename T_container = std::map<T_key, T>>
75 using InternalContainer = T_container;
103 typename T_key = std::string,
104 typename T_container = std::map<T_key, T>>
108 std::is_base_of<Attributable, T>::value,
109 "Type of container element must be derived from Writable");
122 using InternalContainer = T_container;
124 std::shared_ptr<ContainerData> m_containerData;
126 inline void setData(std::shared_ptr<ContainerData> containerData)
128 m_containerData = std::move(containerData);
129 Attributable::setData(m_containerData);
132 inline InternalContainer
const &container()
const
134 return m_containerData->m_container;
137 inline InternalContainer &container()
139 return m_containerData->m_container;
143 using key_type =
typename InternalContainer::key_type;
144 using mapped_type =
typename InternalContainer::mapped_type;
145 using value_type =
typename InternalContainer::value_type;
146 using size_type =
typename InternalContainer::size_type;
147 using difference_type =
typename InternalContainer::difference_type;
148 using allocator_type =
typename InternalContainer::allocator_type;
149 using reference =
typename InternalContainer::reference;
150 using const_reference =
typename InternalContainer::const_reference;
151 using pointer =
typename InternalContainer::pointer;
152 using const_pointer =
typename InternalContainer::const_pointer;
153 using iterator =
typename InternalContainer::iterator;
154 using const_iterator =
typename InternalContainer::const_iterator;
155 using reverse_iterator =
typename InternalContainer::reverse_iterator;
156 using const_reverse_iterator =
157 typename InternalContainer::const_reverse_iterator;
159 iterator begin() noexcept;
160 const_iterator begin()
const noexcept;
161 const_iterator cbegin()
const noexcept;
163 iterator end() noexcept;
164 const_iterator end()
const noexcept;
165 const_iterator cend()
const noexcept;
167 reverse_iterator rbegin() noexcept;
168 const_reverse_iterator rbegin()
const noexcept;
169 const_reverse_iterator crbegin()
const noexcept;
171 reverse_iterator rend() noexcept;
172 const_reverse_iterator rend()
const noexcept;
173 const_reverse_iterator crend()
const noexcept;
175 bool empty()
const noexcept;
177 size_type size()
const noexcept;
187 std::pair<iterator, bool> insert(value_type
const &value);
188 std::pair<iterator, bool> insert(value_type &&value);
189 iterator insert(const_iterator hint, value_type
const &value);
190 iterator insert(const_iterator hint, value_type &&value);
191 template <
class InputIt>
192 void insert(InputIt first, InputIt last)
194 container().insert(first, last);
196 void insert(std::initializer_list<value_type> ilist);
200 mapped_type &at(key_type
const &key);
201 mapped_type
const &at(key_type
const &key)
const;
226 iterator find(key_type
const &key);
227 const_iterator find(key_type
const &key)
const;
234 size_type
count(key_type
const &key)
const;
252 size_type
erase(key_type
const &key);
259 template <
class... Args>
261 -> decltype(InternalContainer().
emplace(std::forward<Args>(args)...))
263 return container().emplace(std::forward<Args>(args)...);
266 template <
typename ChildClass>
271 for (
auto &p : *
this)
273 p.second.visitHierarchy(v, recursive);
276 v(*
static_cast<ChildClass *
>(
this));
283 void clear_unchecked();
286 flush(std::string
const &path, internal::FlushParams
const &flushParams);
305 Container(Container
const &other);
307 Container(Container &&other) noexcept;
309 Container &operator=(Container
const &other);
311 Container &operator=(Container &&other) noexcept;
325 template <
typename Container_t>
329 std::is_same_v<Container_t, std::remove_reference_t<Container_t>>);
330 using key_type =
typename Container_t::key_type;
331 using mapped_type =
typename Container_t::mapped_type;
332 std::set<key_type> m_accessedKeys;
340 Container_t &m_originalContainer;
348 mapped_type &operator[](
typename Container_t::key_type
const &k);
350 mapped_type &at(
typename Container_t::key_type
const &k);
357 void forget(
typename Container_t::key_type
const &k);
Layer to manage storage of attributes associated with file objects.
Definition: Attributable.hpp:225
Map-like container that enforces openPMD requirements and handles IO.
Definition: Container.hpp:106
mapped_type & operator[](key_type const &key)
Access the value that is mapped to a key equivalent to key, creating it if such key does not exist al...
void clear()
Remove all objects from the container and (if written) from disk.
size_type erase(key_type const &key)
Remove a single element from the container and (if written) from disk.
size_type count(key_type const &key) const
This returns either 1 if the key is found in the container of 0 if not.
bool contains(key_type const &key) const
Checks if there is an element with a key equivalent to an exiting key in the container.
iterator erase(iterator res)
auto emplace(Args &&...args) -> decltype(InternalContainer().emplace(std::forward< Args >(args)...))
Definition: Container.hpp:260
mapped_type & operator[](key_type &&key)
Access the value that is mapped to a key equivalent to key, creating it if such key does not exist al...
Definition: HierarchyVisitor.hpp:20
Logical compilation of data from one snapshot (e.g.
Definition: Iteration.hpp:172
Definition: ParticlePatches.hpp:32
Definition: ParticleSpecies.hpp:39
Implementation for the root level of the openPMD hierarchy.
Definition: Series.hpp:288
Based on the logic of the former class ReadIterations, integrating into itself the logic of former Wr...
Definition: StatefulIterator.hpp:204
Definition: Attributable.hpp:110
Definition: Container.hpp:73
InternalContainer m_container
The wrapped container holding all the actual data, e.g.
Definition: Container.hpp:80
This class wraps a Container and forwards operator[]() and at() to it.
Definition: Container.hpp:327
void forget(typename Container_t::key_type const &k)
Remove key from the list of accessed keys.
Data members for Series.
Definition: Series.hpp:90
Public definitions of openPMD-api.
Definition: Date.cpp:29
Container Element Creation Policy.
Definition: Container.hpp:54