openPMD-api
ReadIterations.hpp
1 /* Copyright 2021 Franz Poeschel
2  *
3  * This file is part of openPMD-api.
4  *
5  * openPMD-api is free software: you can redistribute it and/or modify
6  * it under the terms of of either the GNU General Public License or
7  * the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * openPMD-api is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License and the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * and the GNU Lesser General Public License along with openPMD-api.
19  * If not, see <http://www.gnu.org/licenses/>.
20  */
21 #pragma once
22 
23 #include "openPMD/Iteration.hpp"
24 #include "openPMD/Series.hpp"
25 
26 namespace openPMD
27 {
33 {
34  friend class SeriesIterator;
35 
36 public:
37  using iterations_t = decltype(internal::SeriesData::iterations);
38  using index_t = iterations_t::key_type;
39  index_t const iterationIndex;
40 
41 private:
42  template <typename Iteration_t>
43  IndexedIteration(Iteration_t &&it, index_t index)
44  : Iteration(std::forward<Iteration_t>(it)), iterationIndex(index)
45  {}
46 };
47 
49 {
50  using iteration_index_t = IndexedIteration::index_t;
51 
53 
54  maybe_series_t m_series;
55  iteration_index_t m_currentIteration = 0;
56 
57 public:
59  explicit SeriesIterator();
60 
62 
63  SeriesIterator &operator++();
64 
65  IndexedIteration operator*();
66 
67  bool operator==(SeriesIterator const &other) const;
68 
69  bool operator!=(SeriesIterator const &other) const;
70 
71  static SeriesIterator end();
72 };
73 
91 {
92  friend class Series;
93 
94 private:
95  using iterations_t = decltype(internal::SeriesData::iterations);
96  using iterator_t = SeriesIterator;
97 
98  Series m_series;
99 
101 
102 public:
103  iterator_t begin();
104 
105  iterator_t end();
106 };
107 } // namespace openPMD
Subclass of Iteration that knows its own index withing the containing Series.
Definition: ReadIterations.hpp:32
Logical compilation of data from one snapshot (e.g.
Definition: Iteration.hpp:40
Reading side of the streaming API.
Definition: ReadIterations.hpp:90
Root level of the openPMD hierarchy.
Definition: Series.hpp:537
Public definitions of openPMD-api.
Definition: Date.cpp:28
Definition: ReadIterations.hpp:48