Mantid
Loading...
Searching...
No Matches
Framework
PythonInterface
mantid
api
src
Exports
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 +
7
#include "
MantidPythonInterface/api/SpectrumInfoPythonIterator.h
"
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
14
using
Mantid::PythonInterface::SpectrumInfoPythonIterator
;
15
using namespace
boost::python
;
16
17
// Export SpectrumInfoPythonIterator
18
void
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
}
export_SpectrumInfoPythonIterator
void export_SpectrumInfoPythonIterator()
Definition:
SpectrumInfoPythonIterator.cpp:18
SpectrumInfoPythonIterator.h
Mantid::PythonInterface::SpectrumInfoPythonIterator
SpectrumInfoPythonIterator.
Definition:
SpectrumInfoPythonIterator.h:42
Mantid::PythonInterface::SpectrumInfoPythonIterator::next
const SpectrumInfoItem< SpectrumInfo > & next()
Definition:
SpectrumInfoPythonIterator.h:47
boost::python
Definition:
NDArray.h:50
Generated on Tue Jan 3 2023 11:57:58 for Mantid by
1.9.5