Mantid
Loading...
Searching...
No Matches
ICompAssembly.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 +
9#include <boost/python/class.hpp>
10#include <boost/python/register_ptr_to_python.hpp>
11
14using namespace boost::python;
15
17
18namespace {
19// Deprecation wrappers. Legacy component-tree navigation is being retired in
20// favour of the index-based ComponentInfo access layer (children,
21// componentsInSubtree, detectorsInSubtree). See the 'Instrument Access via
22// SpectrumInfo, DetectorInfo, ComponentInfo' concept page.
23int nelementsDeprecated(const ICompAssembly &self) {
24 PyErr_Warn(PyExc_DeprecationWarning, "'ICompAssembly.nelements'/'len()' is deprecated in Mantid 7.0, "
25 "use 'ComponentInfo.componentsInSubtree' instead. "
26 "For more information, see the instrument access layers concept page: "
27 "https://docs.mantidproject.org/nightly/concepts/InstrumentAccessLayers.html");
28 return self.nelements();
29}
30
31std::shared_ptr<IComponent> getItemDeprecated(const ICompAssembly &self, const int index) {
32 PyErr_Warn(PyExc_DeprecationWarning, "'ICompAssembly.__getitem__' is deprecated in Mantid 7.0, "
33 "use 'ComponentInfo.children'/'componentsInSubtree' instead. "
34 "For more information, see the instrument access layers concept page: "
35 "https://docs.mantidproject.org/nightly/concepts/InstrumentAccessLayers.html");
36 return self[index];
37}
38} // namespace
39
41 register_ptr_to_python<std::shared_ptr<ICompAssembly>>();
42
43 class_<ICompAssembly, boost::python::bases<IComponent>, boost::noncopyable>("ICompAssembly", no_init)
44 .def("nelements", &nelementsDeprecated, arg("self"),
45 "Returns the number of elements in the assembly "
46 "(deprecated, use ComponentInfo.componentsInSubtree)")
47 .def("__len__", &nelementsDeprecated, arg("self"),
48 "Returns the number of elements in the assembly "
49 "(deprecated, use ComponentInfo.componentsInSubtree)")
50 .def("__getitem__", &getItemDeprecated, (arg("self"), arg("index")),
51 "Return the component at the given index "
52 "(deprecated, use ComponentInfo.children/componentsInSubtree)");
53}
#define GET_POINTER_SPECIALIZATION(TYPE)
Definition GetPointer.h:17
void export_ICompAssembly()
std::map< DeltaEMode::Type, std::string > index
Class for Assembly of geometric components.
virtual int nelements() const =0
Return the number of elements in the assembly.
base class for Geometric IComponent
Definition IComponent.h:53