17#ifndef PyOpal_PyLine_h
77 void append(boost::python::object element);
102 boost::python::class_<PyLine>
make_class(
const char* className);
108 std::vector<boost::python::object>
line;
115 std::shared_ptr<TBeamline<FlaggedElmPtr>> objectPtr =
getOpalShared();
116 return objectPtr->getName();
121 std::shared_ptr<TBeamline<FlaggedElmPtr>> objectPtr =
getOpalShared();
122 objectPtr->setName(
name);
130 index =
line.size()+index;
142 line->setElement(wrapped);
144 if (objectPtr ==
nullptr) {
145 throw OpalException(
"PyLine_<TBeamline<FlaggedElmPtr> >::register",
146 "Trying to register something that was not a Opal Object");
153 boost::python::docstring_options docop(
true,
true,
false);
154 auto pyclass = boost::python::class_<PyLine>(className);
163 }
catch (std::exception& exc) {
174 line.at(i) = pyelement;
175 }
catch (std::exception& exc) {
176 throw OpalException(
"PyLine::setElement",
"Failed to set element");
178 boost::python::object pyopalelement = pyelement.attr(
"get_opal_element")();
180 boost::python::extract<PyOpal::PyOpalObjectNS::PyOpalObject<OpalElement>& >(pyopalelement);
185 std::shared_ptr<OpalElement> opalElementShared = cpyelement.
getOpalShared();
186 OpalElement* opalElement = opalElementShared.get();
188 throw OpalException(
"PyLine::setElement",
"Failed to extract element");
193 throw OpalException(
"PyLine::setElement",
"Failed to cast element");
197 BL::iterator new_it =
object_m->erase(it);
210 line.push_back(boost::python::object());
PyLine_< TBeamline< FlaggedElmPtr > > PyLine
ElementBase * getElement() const
Return the embedded CLASSIC element.
The base class for all OPAL objects.
static OpalData * getInstance()
void define(Object *newObject)
Define a new object.
virtual const std::string & getName() const
Get element name.
A section of a beam line.
A section of a beam line.
virtual void update()
Update the embedded CLASSIC element.
virtual Line * clone(const std::string &name)
Make clone.
std::shared_ptr< TBeamline< FlaggedElmPtr > > object_m
std::shared_ptr< TBeamline< FlaggedElmPtr > > getOpalShared()
void setName(std::string name)
std::vector< boost::python::object > line
int wrangleIndex(int index)
void append(boost::python::object element)
void setElement(int i, boost::python::object element)
std::string getName() const
boost::python::class_< PyLine > make_class(const char *className)
boost::python::object getElement(int i)
The base class for all OPAL exceptions.