OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
PyLine.cpp
Go to the documentation of this file.
2#include "Lines/Line.h"
3#include "PyOpal/PyLine.h"
4#include "PyOpal/Globals.h"
5
6//using namespace boost::python;
7namespace PyOpal {
8namespace PyLineNS {
9
10const char* module_docstring =
11"The line module handles building of a line of elements in OPAL";
12
13template <>
14std::vector<PyOpalObjectNS::AttributeDef> PyOpalObjectNS::PyOpalObject<TBeamline<Element> >::attributes = {
15 {"L", "length", "", PyOpalObjectNS::DOUBLE},
16 {"ORIGIN", "origin", "", PyOpalObjectNS::STRING},
17 {"ORIENTATION", "orientation", "", PyOpalObjectNS::STRING},
18 {"X", "x", "", PyOpalObjectNS::DOUBLE},
19 {"Y", "y", "", PyOpalObjectNS::DOUBLE},
20 {"Z", "z", "", PyOpalObjectNS::DOUBLE},
21 {"THETA", "theta", "", PyOpalObjectNS::DOUBLE},
22 {"PHI", "phi", "", PyOpalObjectNS::DOUBLE},
23 {"PSI", "psi", "", PyOpalObjectNS::DOUBLE}
24};
25
26template <>
27std::string PyOpalObjectNS::PyOpalObject<TBeamline<Element> >::classDocstring = "";
28
32 PyLine element;
33 auto lineClass = element.make_class("Line");
34 // https://docs.python.org/3/library/collections.abc.html
35 // I tried to pull everything from:
36 // mutable sequence, sequence, reversible, iterator, iterable, container
37 // so should look like a python list
38 lineClass
39 .def("__len__", &PyLine::getLength)
40 .def("__getitem__", &PyLine::getElement)
41 .def("__setitem__", &PyLine::setElement)
42 .def("append", &PyLine::append)
43 /*
44 .def("__iter__", &PyElement<Line>::dummyGet<double>)
45 .def("__next__", &PyElement<Line>::dummyGet<double>)
46 .def("__delitem__", &PyElement<Line>::dummyGet<double>)
47 .def("__contains__", &PyElement<Line>::dummySet<double>)
48 .def("__reversed__", &PyElement<Line>::dummySet<double>)
49 .def("index", &PyElement<Line>::dummySet<double>)
50 .def("count", &PyElement<Line>::dummySet<double>)
51 .def("reverse", &PyElement<Line>::dummySet<double>)
52 .def("extend", &PyElement<Line>::dummySet<double>)
53 .def("pop", &PyElement<Line>::dummySet<double>)
54 .def("remove", &PyElement<Line>::dummySet<double>)
55 .def("append", &PyElement<Line>::dummySet<double>)
56 .def("__iadd__", &PyElement<Line>::dummySet<double>)*/
57 ;
58 element.addGetOpalElement(lineClass);
59 lineClass.def("register", &PyLine::registerObject);
60
61}
62
63}
64}
void Initialise()
Definition: Globals.cpp:78
BOOST_PYTHON_MODULE(line)
Definition: PyLine.cpp:29
const char * module_docstring
Definition: PyLine.cpp:10
void registerObject()
int getLength() const
Definition: PyLine.h:64
void append(boost::python::object element)
void setElement(int i, boost::python::object element)
boost::python::class_< PyLine > make_class(const char *className)
boost::python::object getElement(int i)
void addGetOpalElement(PYCLASS &pyclass)
Definition: PyOpalObject.h:462