OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
Public Member Functions | Private Member Functions | Private Attributes | List of all members
PyOpal::PyLine_< C > Class Template Reference

#include <PyLine.h>

Inheritance diagram for PyOpal::PyLine_< C >:
Inheritance graph
[legend]
Collaboration diagram for PyOpal::PyLine_< C >:
Collaboration graph
[legend]

Public Member Functions

boost::python::object getElement (int i)
 
void setElement (int i, boost::python::object element)
 
void append (boost::python::object element)
 
std::string getName () const
 
void setName (std::string name)
 
int getLength () const
 
boost::python::class_< PyLinemake_class (const char *className)
 
void registerObject ()
 
std::string getName () const
 
void setName (std::string name)
 
void registerObject ()
 
boost::python::class_< PyLinemake_class (const char *className)
 
boost::python::object getElement (int i)
 
void setElement (int i, boost::python::object pyelement)
 
void append (boost::python::object pyelement)
 
- Public Member Functions inherited from PyOpal::PyOpalObjectNS::PyOpalObject< C >
 PyOpalObject ()
 
 PyOpalObject (std::shared_ptr< C > object)
 
 PyOpalObject (const PyOpalObject< C > &rhs)
 
virtual ~PyOpalObject ()=default
 
boost::python::class_< PyCmake_class (const char *className)
 
boost::python::class_< PyCmake_element_class (const char *className)
 
boost::python::class_< PyCmake_generic_class (const char *className)
 
template<class PYCLASS >
void addAttributes (PYCLASS &pyclass)
 
template<class PYCLASS >
void addExecute (PYCLASS &pyclass)
 
template<class PYCLASS >
void addRegister (PYCLASS &pyclass)
 
template<class PYCLASS >
void addGetOpalName (PYCLASS &pyclass)
 
template<class PYCLASS >
void addSetAttributes (PYCLASS &pyclass)
 
template<class PYCLASS >
void addSetOpalName (PYCLASS &pyclass)
 
template<class PYCLASS >
void addSetOpalElementName (PYCLASS &pyclass)
 
template<class PYCLASS >
void addGetOpalElement (PYCLASS &pyclass)
 
template<class PYCLASS >
void addGetFieldValue (PYCLASS &pyclass, double distanceUnits, double timeUnits, double bfieldUnits, double efieldUnits)
 
template<class ValueType >
ValueType dummyGet () const
 
virtual void doSetup ()
 
template<class ValueType >
void dummySet (ValueType test)
 
PyObject * getAttribute (AttributeType type, std::string opalName) const
 
void setAttribute (AttributeType type, std::string opalName, PyObject *value)
 
std::shared_ptr< C > getOpalShared ()
 
std::shared_ptr< C > getOpalShared () const
 
 PyOpalObject ()
 
void doSetup ()
 
 PyOpalObject ()
 
void doSetup ()
 
void doSetup ()
 
void doSetup ()
 

Private Member Functions

int wrangleIndex (int index)
 
int wrangleIndex (int index)
 

Private Attributes

std::vector< boost::python::object > line
 

Additional Inherited Members

- Public Types inherited from PyOpal::PyOpalObjectNS::PyOpalObject< C >
typedef PyOpalObject< C > PyC
 
- Protected Member Functions inherited from PyOpal::PyOpalObjectNS::PyOpalObject< C >
std::string getDocString (AttributeDef &def)
 
std::vector< PyOpalObjectNS::AttributeDefattributes
 
std::string classDocstring
 
std::vector< PyOpalObjectNS::AttributeDefattributes
 
std::string classDocstring
 
std::vector< PyOpalObjectNS::AttributeDefattributes
 
std::vector< PyOpalObjectNS::AttributeDefattributes
 
std::vector< PyOpalObjectNS::AttributeDefattributes
 
std::string classDocstring
 
std::vector< PyOpalObjectNS::AttributeDefattributes
 
std::string classDocstring
 
std::vector< PyOpalObjectNS::AttributeDefattributes
 
std::string classDocstring
 
std::vector< PyOpalObjectNS::AttributeDefattributes
 
std::string classDocstring
 
std::vector< PyOpalObjectNS::AttributeDefattributes
 
std::string classDocstring
 
std::string classDocstring
 
std::vector< PyOpalObjectNS::AttributeDefattributes
 
std::vector< PyOpalObjectNS::AttributeDefattributes
 
std::string classDocstring
 
std::vector< PyOpalObjectNS::AttributeDefattributes
 
std::string classDocstring
 
std::vector< PyOpalObjectNS::AttributeDefattributes
 
std::string classDocstring
 
std::vector< PyOpalObjectNS::AttributeDefattributes
 
std::string classDocstring
 
std::vector< PyOpalObjectNS::AttributeDefattributes
 
std::string classDocstring
 
std::vector< PyOpalObjectNS::AttributeDefattributes
 
std::string classDocstring
 
std::vector< PyOpalObjectNS::AttributeDefattributes
 
std::vector< PyOpalObjectNS::AttributeDefattributes
 
std::vector< PyOpalObjectNS::AttributeDefattributes
 
std::vector< PyOpalObjectNS::AttributeDefattributes
 
std::vector< PyOpalObjectNS::AttributeDefattributes
 
std::vector< PyOpalObjectNS::AttributeDefattributes
 
std::string classDocstring
 
- Static Protected Member Functions inherited from PyOpal::PyOpalObjectNS::PyOpalObject< C >
static boost::python::object getFieldValue (PyOpalObjectNS::PyOpalObject< C > &pyobject, double x, double y, double z, double t)
 
static std::string getOpalName (const PyOpalObject< C > &pyobject)
 
static void setOpalName (PyOpalObject< C > &pyobject, std::string name)
 
static void setOpalElementName (PyOpalObject< C > &pyobject, std::string name)
 
static void execute (PyOpalObject< C > &pyobject)
 
static void registerObject (PyOpalObject< C > &pyobject)
 
static boost::python::object getPyOpalElement (PyOpalObject< C > &pyobject)
 
static boost::python::object setAttributes (boost::python::tuple args, boost::python::dict kwargs)
 
- Protected Attributes inherited from PyOpal::PyOpalObjectNS::PyOpalObject< C >
std::shared_ptr< C > object_m
 
- Static Protected Attributes inherited from PyOpal::PyOpalObjectNS::PyOpalObject< C >
static std::vector< AttributeDefattributes
 
static std::map< std::string, AttributeDefpyNameToAttribute
 
static std::string classDocstring
 
static bool converterRegistered
 
static double distanceUnits_m = 1
 
static double timeUnits_m = 1
 
static double bfieldUnits_m = 1
 
static double efieldUnits_m = 1
 
static const std::string getFieldValueDocString
 

Detailed Description

template<class C>
class PyOpal::PyLine_< C >

PyLine_ is a list of elements in a beamline

PyLine_ is designed to look like a python list; but internally it holds a TBeamline object (which is used by OPAL to do a line of elements). TBeamline internally holds a linked list (std::list) of ElementBase. In order to keep the type information, which is valuable for users, we maintain in PyLine_ a std::vector of python objects of the appropriate Component type (the child class). This is in addition to the ElementBases stored in TBeamline. PyLine_ has the job of keeping the TBeamline and the std::vector up to date and consistent.

Normally I expect PyLine_<TBeamline<FlaggedElmPtr> > to be instantiated, which is typedef'd to a PyLine. I have not targetted any other specialization - caveat emptor if you try to do anything else.

Definition at line 51 of file PyLine.h.

Member Function Documentation

◆ append() [1/2]

template<class C >
void PyOpal::PyLine_< C >::append ( boost::python::object  element)

Extend the length of the vector and TBeamline.

element - the element to be appended. Must be suitable for use in setElement (see setElement doc for details).

Referenced by PyOpal::PyLineNS::BOOST_PYTHON_MODULE().

◆ append() [2/2]

void PyOpal::PyLine_< TBeamline< FlaggedElmPtr > >::append ( boost::python::object  pyelement)

Definition at line 207 of file PyLine.h.

◆ getElement() [1/2]

template<class C >
boost::python::object PyOpal::PyLine_< C >::getElement ( int  i)

Get a python object from the vector of stored objects

i - index of the element in the python object

Returns the stored python object.

Referenced by PyOpal::PyLineNS::BOOST_PYTHON_MODULE().

◆ getElement() [2/2]

boost::python::object PyOpal::PyLine_< TBeamline< FlaggedElmPtr > >::getElement ( int  i)

Definition at line 159 of file PyLine.h.

◆ getLength()

template<class C >
int PyOpal::PyLine_< C >::getLength ( ) const
inline

Returns the number of elements in the line

Definition at line 95 of file PyLine.h.

References PyOpal::PyLine_< C >::line.

Referenced by PyOpal::PyLineNS::BOOST_PYTHON_MODULE().

◆ getName() [1/2]

template<class C >
std::string PyOpal::PyLine_< C >::getName ( ) const

Set the name of the underlying object.

Note this is exposed as get_opal_name; technically this is the name of the underlying Classic ElementBase not an opal object

Referenced by PyOpal::PyLineNS::BOOST_PYTHON_MODULE().

◆ getName() [2/2]

std::string PyOpal::PyLine_< TBeamline< FlaggedElmPtr > >::getName ( ) const

Definition at line 114 of file PyLine.h.

◆ make_class() [1/2]

template<class C >
boost::python::class_< PyLine > PyOpal::PyLine_< C >::make_class ( const char *  className)

Make a python::class_ object for a PyLine.

Should normally be called during module definition. This overrides the PyObject make_class.

Referenced by PyOpal::PyLineNS::BOOST_PYTHON_MODULE().

◆ make_class() [2/2]

boost::python::class_< PyLine > PyOpal::PyLine_< TBeamline< FlaggedElmPtr > >::make_class ( const char *  className)

Definition at line 152 of file PyLine.h.

◆ registerObject() [1/2]

template<class C >
void PyOpal::PyLine_< C >::registerObject ( )

◆ registerObject() [2/2]

void PyOpal::PyLine_< TBeamline< FlaggedElmPtr > >::registerObject ( )

Definition at line 135 of file PyLine.h.

References Line::clone(), OpalData::define(), OpalData::getInstance(), ElementBase::getName(), and Element::setElement().

Here is the call graph for this function:

◆ setElement() [1/2]

template<class C >
void PyOpal::PyLine_< C >::setElement ( int  i,
boost::python::object  element 
)

Set a python object in the line vector and update the TBeamline.

i - index of the element in the python object element - the element to be stored. element must have a python method get_opal_element that returns python::object that is convertible to a PyOpalObject<OpalElement> using python::extract. Note that OpalElement::update is called at this time to update the underlying element properties.

Referenced by PyOpal::PyLineNS::BOOST_PYTHON_MODULE().

◆ setElement() [2/2]

void PyOpal::PyLine_< TBeamline< FlaggedElmPtr > >::setElement ( int  i,
boost::python::object  pyelement 
)

Definition at line 169 of file PyLine.h.

References Element::getElement(), PyOpal::PyOpalObjectNS::PyOpalObject< C >::getOpalShared(), and OpalElement::update().

Here is the call graph for this function:

◆ setName() [1/2]

template<class C >
void PyOpal::PyLine_< C >::setName ( std::string  name)

Set the name of the underlying object.

Note this is exposed as get_opal_name; technically this is the name of the underlying Classic ElementBase not an opal object.

Referenced by PyOpal::PyLineNS::BOOST_PYTHON_MODULE().

◆ setName() [2/2]

void PyOpal::PyLine_< TBeamline< FlaggedElmPtr > >::setName ( std::string  name)

Definition at line 120 of file PyLine.h.

References name.

◆ wrangleIndex() [1/2]

template<class C >
int PyOpal::PyLine_< C >::wrangleIndex ( int  index)
private

Handle negative indices in pythonic way

◆ wrangleIndex() [2/2]

int PyOpal::PyLine_< TBeamline< FlaggedElmPtr > >::wrangleIndex ( int  index)
private

Definition at line 126 of file PyLine.h.

Member Data Documentation

◆ line

template<class C >
std::vector<boost::python::object> PyOpal::PyLine_< C >::line
private

The python objects stored in the line

Definition at line 108 of file PyLine.h.

Referenced by PyOpal::PyLine_< C >::getLength().


The documentation for this class was generated from the following file: