23 #include "openPMD/Error.hpp"
24 #include "openPMD/IO/Access.hpp"
25 #include "openPMD/backend/Attributable.hpp"
27 #include <initializer_list>
32 #include <type_traits>
36 #ifndef OPENPMD_protected
37 #define OPENPMD_protected protected:
53 constexpr
static bool is_noop =
true;
64 class EraseStaleEntries;
68 typename T_key = std::string,
69 typename T_container = std::map<T_key, T>>
73 using InternalContainer = T_container;
101 typename T_key = std::string,
102 typename T_container = std::map<T_key, T>>
106 std::is_base_of<Attributable, T>::value,
107 "Type of container element must be derived from Writable");
120 using InternalContainer = T_container;
122 std::shared_ptr<ContainerData> m_containerData;
124 inline void setData(std::shared_ptr<ContainerData> containerData)
126 m_containerData = std::move(containerData);
127 Attributable::setData(m_containerData);
130 inline InternalContainer
const &container()
const
132 return m_containerData->m_container;
135 inline InternalContainer &container()
137 return m_containerData->m_container;
141 using key_type =
typename InternalContainer::key_type;
142 using mapped_type =
typename InternalContainer::mapped_type;
143 using value_type =
typename InternalContainer::value_type;
144 using size_type =
typename InternalContainer::size_type;
145 using difference_type =
typename InternalContainer::difference_type;
146 using allocator_type =
typename InternalContainer::allocator_type;
147 using reference =
typename InternalContainer::reference;
148 using const_reference =
typename InternalContainer::const_reference;
149 using pointer =
typename InternalContainer::pointer;
150 using const_pointer =
typename InternalContainer::const_pointer;
151 using iterator =
typename InternalContainer::iterator;
152 using const_iterator =
typename InternalContainer::const_iterator;
153 using reverse_iterator =
typename InternalContainer::reverse_iterator;
154 using const_reverse_iterator =
155 typename InternalContainer::const_reverse_iterator;
157 iterator begin() noexcept;
158 const_iterator begin()
const noexcept;
159 const_iterator cbegin()
const noexcept;
161 iterator end() noexcept;
162 const_iterator end()
const noexcept;
163 const_iterator cend()
const noexcept;
165 reverse_iterator rbegin() noexcept;
166 const_reverse_iterator rbegin()
const noexcept;
167 const_reverse_iterator crbegin()
const noexcept;
169 reverse_iterator rend() noexcept;
170 const_reverse_iterator rend()
const noexcept;
171 const_reverse_iterator crend()
const noexcept;
173 bool empty()
const noexcept;
175 size_type size()
const noexcept;
185 std::pair<iterator, bool> insert(value_type
const &value);
186 std::pair<iterator, bool> insert(value_type &&value);
187 iterator insert(const_iterator hint, value_type
const &value);
188 iterator insert(const_iterator hint, value_type &&value);
189 template <
class InputIt>
190 void insert(InputIt first, InputIt last)
192 container().insert(first, last);
194 void insert(std::initializer_list<value_type> ilist);
198 mapped_type &at(key_type
const &key);
199 mapped_type
const &at(key_type
const &key)
const;
224 iterator find(key_type
const &key);
225 const_iterator find(key_type
const &key)
const;
232 size_type
count(key_type
const &key)
const;
250 size_type
erase(key_type
const &key);
257 template <
class... Args>
259 -> decltype(InternalContainer().
emplace(std::forward<Args>(args)...))
261 return container().emplace(std::forward<Args>(args)...);
268 void clear_unchecked();
310 template <
typename Container_t>
314 std::is_same_v<Container_t, std::remove_reference_t<Container_t>>);
315 using key_type =
typename Container_t::key_type;
316 using mapped_type =
typename Container_t::mapped_type;
317 std::set<key_type> m_accessedKeys;
325 Container_t &m_originalContainer;
333 mapped_type &operator[](
typename Container_t::key_type
const &k);
335 mapped_type &at(
typename Container_t::key_type
const &k);
342 void forget(
typename Container_t::key_type
const &k);
Layer to manage storage of attributes associated with file objects.
Definition: Attributable.hpp:222
Map-like container that enforces openPMD requirements and handles IO.
Definition: Container.hpp:104
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:258
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...
Logical compilation of data from one snapshot (e.g.
Definition: Iteration.hpp:146
Definition: ParticlePatches.hpp:32
Definition: ParticleSpecies.hpp:34
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:107
Definition: Container.hpp:71
InternalContainer m_container
The wrapped container holding all the actual data, e.g.
Definition: Container.hpp:78
This class wraps a Container and forwards operator[]() and at() to it.
Definition: Container.hpp:312
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
Parameters recursively passed through the openPMD hierarchy when flushing.
Definition: AbstractIOHandler.hpp:106
Container Element Creation Policy.
Definition: Container.hpp:52