Mantid
Loading...
Searching...
No Matches
SpectrumInfoPythonIterator.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
8
9#include <boost/python/class.hpp>
10#include <boost/python/copy_const_reference.hpp>
11#include <boost/python/iterator.hpp>
12#include <boost/python/module.hpp>
13
15using namespace boost::python;
16
17// Export SpectrumInfoPythonIterator
19
20 // Export to Python
21 class_<SpectrumInfoPythonIterator>("SpectrumInfoPythonIterator", no_init)
22 .def("__iter__", objects::identity_function())
23 .def("__next__", &SpectrumInfoPythonIterator::next, return_value_policy<copy_const_reference>());
24 /*
25 Return value policy for next is to copy the const reference. Copy by value is
26 essential for python 2.0 compatibility because items (SpectrumInfoItem) will
27 outlive their iterators if declared as part of for loops. There is no good
28 way to deal with this other than to force a copy so that internals of the
29 item are not also corrupted. Future developers may wish to choose a separte
30 policy for python 3.0 where this is not a concern, and const ref returns
31 would be faster.
32 */
33}
void export_SpectrumInfoPythonIterator()
const SpectrumInfoItem< SpectrumInfo > & next()