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) {
32 return self.nelements();
33}
34
35std::shared_ptr<IComponent> getItemDeprecated(const ICompAssembly &self, const int index) {
44 return self[index];
45}
46} // namespace
47
49 register_ptr_to_python<std::shared_ptr<ICompAssembly>>();
50
51 class_<ICompAssembly, boost::python::bases<IComponent>, boost::noncopyable>("ICompAssembly", no_init)
52 .def("nelements", &nelementsDeprecated, arg("self"),
53 "Returns the number of elements in the assembly "
54 "(deprecated, use ComponentInfo.componentsInSubtree)")
55 .def("__len__", &nelementsDeprecated, arg("self"),
56 "Returns the number of elements in the assembly "
57 "(deprecated, use ComponentInfo.componentsInSubtree)")
58 .def("__getitem__", &getItemDeprecated, (arg("self"), arg("index")),
59 "Return the component at the given index "
60 "(deprecated, use ComponentInfo.children/componentsInSubtree)");
61}
#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