OPAL (Object Oriented Parallel Accelerator Library) 2022.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)
 
int getLength () const
 
boost::python::class_< PyLinemake_class (const char *className)
 
void registerObject ()
 
boost::python::object getElement (int i)
 
void setElement (int i, boost::python::object element)
 
void append (boost::python::object element)
 
int getLength () const
 
boost::python::class_< PyLinemake_class (const char *className)
 
void registerObject ()
 
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)
 
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)
 
 ~PyOpalObject ()
 
boost::python::class_< PyCmake_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 addGetOpalElement (PYCLASS &pyclass)
 
template<class ValueType >
ValueType dummyGet () const
 
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 ()
 
 PyOpalObject ()
 
 PyOpalObject (std::shared_ptr< C > object)
 
 PyOpalObject (const PyOpalObject< C > &rhs)
 
 ~PyOpalObject ()
 
boost::python::class_< PyCmake_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 addSetOpalName (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
 
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 ()
 
 PyOpalObject ()
 

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
 
typedef PyOpalObject< C > PyC
 
- Protected Member Functions inherited from PyOpal::PyOpalObjectNS::PyOpalObject< C >
std::string getDocString (AttributeDef &def)
 
std::string getDocString (AttributeDef &def)
 
- Static Protected Member Functions inherited from PyOpal::PyOpalObjectNS::PyOpalObject< C >
static void execute (PyOpalObject< C > &pyobject)
 
static void registerObject (PyOpalObject< C > &pyobject)
 
static boost::python::object getPyOpalElement (PyOpalObject< C > &pyobject)
 
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 execute (PyOpalObject< C > &pyobject)
 
static void registerObject (PyOpalObject< C > &pyobject)
 
static boost::python::object getPyOpalElement (PyOpalObject< C > &pyobject)
 
- 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::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 35 of file PyLine.h.

Member Function Documentation

◆ append() [1/4]

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/4]

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

◆ append() [3/4]

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

Definition at line 149 of file PyLine.h.

◆ append() [4/4]

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

Definition at line 159 of file PyLine.h.

◆ getElement() [1/4]

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/4]

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

Definition at line 102 of file PyLine.h.

◆ getElement() [3/4]

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.

◆ getElement() [4/4]

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

Definition at line 111 of file PyLine.h.

◆ getLength() [1/2]

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

Returns the number of elements in the line

Definition at line 64 of file PyLine.h.

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

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

◆ getLength() [2/2]

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

Returns the number of elements in the line

Definition at line 64 of file PyLine.h.

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

◆ make_class() [1/4]

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.

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

◆ make_class() [2/4]

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

Definition at line 95 of file PyLine.h.

◆ make_class() [3/4]

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.

◆ make_class() [4/4]

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

Definition at line 104 of file PyLine.h.

◆ registerObject() [1/4]

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

◆ registerObject() [2/4]

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

Definition at line 80 of file PyLine.h.

References OpalData::define(), endl(), OpalData::getInstance(), and Element::setElement().

Here is the call graph for this function:

◆ registerObject() [3/4]

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

◆ registerObject() [4/4]

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

Definition at line 91 of file PyLine.h.

References OpalData::define(), OpalData::getInstance(), and Element::setElement().

Here is the call graph for this function:

◆ setElement() [1/4]

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 PyElement<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/4]

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.

◆ setElement() [3/4]

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

Definition at line 111 of file PyLine.h.

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

Here is the call graph for this function:

◆ setElement() [4/4]

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

Definition at line 121 of file PyLine.h.

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

Here is the call graph for this function:

◆ 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 82 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 76 of file PyLine.h.

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


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