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 ) )
45  , iterationIndex( index )
46  {
47  }
48 };
49 
51 {
52  using iteration_index_t = IndexedIteration::index_t;
53 
55 
56  maybe_series_t m_series;
57  iteration_index_t m_currentIteration = 0;
58 
59 public:
61  explicit SeriesIterator();
62 
64 
65  SeriesIterator & operator++();
66 
67  IndexedIteration operator*();
68 
69  bool operator==( SeriesIterator const & other ) const;
70 
71  bool operator!=( SeriesIterator const & other ) const;
72 
73  static SeriesIterator end();
74 };
75 
93 {
94  friend class Series;
95 
96 private:
97  using iterations_t = decltype( internal::SeriesData::iterations );
98  using iterator_t = SeriesIterator;
99 
100  Series m_series;
101 
103 
104 public:
105  iterator_t begin();
106 
107  iterator_t end();
108 };
109 } // namespace openPMD
openPMD::Series
Root level of the openPMD hierarchy.
Definition: Series.hpp:478
openPMD::IndexedIteration
Subclass of Iteration that knows its own index withing the containing Series.
Definition: ReadIterations.hpp:32
openPMD::auxiliary::Option< Series >
openPMD::Iteration
Logical compilation of data from one snapshot (e.g.
Definition: Iteration.hpp:39
openPMD
Public definitions of openPMD-api.
Definition: Date.cpp:29
openPMD::SeriesIterator
Definition: ReadIterations.hpp:50
openPMD::SeriesIterator::SeriesIterator
SeriesIterator()
construct the end() iterator
Definition: ReadIterations.cpp:29
openPMD::ReadIterations
Reading side of the streaming API.
Definition: ReadIterations.hpp:92