OPAL (Object Oriented Parallel Accelerator Library)  2024.1
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 ()
 
template<>
std::string getName () const
 
template<>
void setName (std::string name)
 
template<>
void registerObject ()
 
template<>
boost::python::class_< PyLinemake_class (const char *className)
 
template<>
boost::python::object getElement (int i)
 
template<>
void setElement (int i, boost::python::object pyelement)
 
template<>
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)
 
 ~PyOpalObject ()
 
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
 
template<>
 PyOpalObject ()
 
template<>
void doSetup ()
 
template<>
void doSetup ()
 
template<>
void doSetup ()
 

Private Member Functions

int wrangleIndex (int index)
 
template<>
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)
 
- 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,
AttributeDef
pyNameToAttribute
 
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 32 of file PyLine.h.

Member Function Documentation

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().

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

Definition at line 207 of file PyLine.h.

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().

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

Definition at line 159 of file PyLine.h.

References exception.

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().

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().

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

Definition at line 114 of file PyLine.h.

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().

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

Definition at line 152 of file PyLine.h.

template<class C >
void PyOpal::PyLine_< C >::registerObject ( )
template<>
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:

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().

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

Definition at line 169 of file PyLine.h.

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

Here is the call graph for this function:

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().

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

Definition at line 120 of file PyLine.h.

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

Handle negative indices in pythonic way

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

Definition at line 126 of file PyLine.h.

Member Data Documentation

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(), and minimal_runner.MinimalRunner::make_line().


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