openPMD-api
 
Loading...
Searching...
No Matches
RandomAccessIterator.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/snapshots/ContainerTraits.hpp"
25#include "openPMD/snapshots/IteratorTraits.hpp"
26
27#include <utility>
28
29/*
30 * Private header not included in user code.
31 * Implements the Iterator interface for the random-access workflow.
32 */
33
34namespace openPMD
35{
36namespace detail
37{
38 template <typename iterator_t>
39 using iterator_to_value_type =
40 // do NOT remove const from type
41 std::remove_reference_t<decltype(*std::declval<iterator_t>())>;
42}
43
44template <typename iterator_t>
45class RandomAccessIterator
47 RandomAccessIterator<iterator_t>,
48 detail::iterator_to_value_type<iterator_t>>
49{
50private:
51 friend class RandomAccessIteratorContainer;
52 template <typename>
53 friend class OpaqueSeriesIterator;
54 template <
55 typename ConcreteIteratorClass,
56 typename ValueType,
57 typename... ConstructorArgs>
58 friend auto from_concrete_iterator(ConstructorArgs &&...args)
59 -> OpaqueSeriesIterator<ValueType>;
60
61 using parent_t = AbstractSeriesIterator<
62 RandomAccessIterator<iterator_t>,
63 detail::iterator_to_value_type<iterator_t>>;
64
65 RandomAccessIterator(iterator_t it);
66
67 /* Internal iterator */
68 iterator_t m_it;
69
70public:
71 using typename parent_t::value_type;
72
73 ~RandomAccessIterator() override;
74
75 RandomAccessIterator(RandomAccessIterator const &other);
76 RandomAccessIterator(RandomAccessIterator &&other) noexcept(
77 noexcept(iterator_t(std::declval<iterator_t &&>())));
78
79 RandomAccessIterator &operator=(RandomAccessIterator const &other);
80 RandomAccessIterator &
81 operator=(RandomAccessIterator &&other) noexcept(noexcept(
82 std::declval<iterator_t>().operator=(std::declval<iterator_t &&>())));
83
84 auto operator*() -> value_type &;
85 auto operator*() const -> value_type const &;
86
87 auto operator++() -> RandomAccessIterator &;
88 auto operator--() -> RandomAccessIterator &;
89 auto operator++(int) -> RandomAccessIterator;
90 auto operator--(int) -> RandomAccessIterator;
91
92 using parent_t::operator!=;
93 bool operator==(RandomAccessIterator const &other) const;
94};
95} // namespace openPMD
Definition IteratorTraits.hpp:93
Public definitions of openPMD-api.
Definition Date.cpp:29