ImpactX
Loading...
Searching...
No Matches
Iterator.H
Go to the documentation of this file.
1/* Copyright 2021-2022 The AMReX Community
2 *
3 * Authors: Axel Huebl
4 * License: BSD-3-Clause-LBNL
5 */
6#pragma once
7
8#include "pyImpactX.H"
9
10#include <AMReX_BoxArray.H>
12#include <AMReX_FArrayBox.H>
13#include <AMReX_FabArray.H>
14#include <AMReX_FabArrayBase.H>
15#include <AMReX_MultiFab.H>
16
17#include <memory>
18#include <string>
19
20
21namespace pyImpactX
22{
40 template< typename T_Iterator >
41 T_Iterator &
42 iterator_next( T_Iterator & it )
43 {
44 py::object self = py::cast(it);
45 if (!py::hasattr(self, "first_or_done"))
46 self.attr("first_or_done") = true;
47
48 bool first_or_done = self.attr("first_or_done").cast<bool>();
49 if (first_or_done) {
50 first_or_done = false;
51 self.attr("first_or_done") = first_or_done;
52 }
53 else
54 ++it;
55 if( !it.isValid() )
56 {
57 first_or_done = true;
58 it.Finalize();
59 throw py::stop_iteration();
60 }
61 return it;
62 }
63}
Definition Iterator.H:22
T_Iterator & iterator_next(T_Iterator &it)
Definition Iterator.H:42