|
OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
|
Classes | |
| class | PyOpalObject |
| struct | PyOpalObjectGetProperty |
| struct | PyOpalObjectSetProperty |
| struct | AttributeDef |
Enumerations | |
| enum | AttributeType { STRING , PREDEFINED_STRING , UPPER_CASE_STRING , STRING_LIST , DOUBLE , BOOL , INT , FLOAT_LIST } |
Functions | |
| template<class C> | |
| void | update (PyOpalObjectNS::PyOpalObject< C > pyelement) |
Variables | |
| std::map< AttributeType, std::string > | attributeName |
| template<class C> | |
| std::map< std::string, AttributeDef > | PyOpalObject< C >::pyNameToAttribute |
| template<class C> | |
| double | PyOpalObject< C >::distanceUnits_m = 1 |
| template<class C> | |
| double | PyOpalObject< C >::timeUnits_m = 1 |
| template<class C> | |
| double | PyOpalObject< C >::bfieldUnits_m = 1 |
| template<class C> | |
| double | PyOpalObject< C >::efieldUnits_m = 1 |
| template<class C> | |
| const std::string | PyOpalObject< C >::getFieldValueDocString |
| template<class C> | |
| const PyOpalObject< C > * | PyOpalObjectGetProperty< C >::object_m = nullptr |
| template<class C> | |
| PyOpalObject< C > * | PyOpalObjectSetProperty< C >::object_m = nullptr |
PyOpalObjectNS namespace contains PyOpalObject, a wrapper for Object objects, and various supporting objects.
PyOpalObject<C>: basic element wrapper for C, which should be a subclass of OpalElement. AttributeType: enumeration of Opal Attribute Types (real, string, etc) AttributeDef: struct containing all of the things PyOpalObject needs to know about each attribute that should be exposed to the python api. PyElementGetProperty: call policy to handle access of an Attribute for a python property PyElementSetProperty: call policy to handle setting of an Attribute for a python property
To wrap an OpalElement, say MyOpalObjectClass, you need to:
Define static member data for the PyOpalObject<MyOpalObjectClass>. This includes defining the attributes and setting a few options for different methods to expose.
In BOOST_PYTHON_MODULE(my_opal_element_module), call
PyOpalObject<MyOpalObjectType>.make_class()
Nb: apologies, this is heavy template stuff so almost everything has to go in the header file.
| struct PyOpal::PyOpalObjectNS::AttributeDef |
AttributeDef defines an attribute opalName_m: the name of the opal Attribute pyName_m: the name that will be visible to the user in python. Properties should be_lower_case_with_underscores to comply with python API docString_m: docstring. If left empty (""), PyElement will generate a docstring like "py_name (type): Attribute help string" type_m: python type.
Definition at line 94 of file PyOpalObject.h.
| Class Members | ||
|---|---|---|
| string | docString_m | |
| string | opalName_m | |
| string | pyName_m | |
| AttributeType | type_m | |
AttributeType is used to control conversion from python to OpalAttribute
Float will convert to RealAttribute
String will convert to StringAttribute
Bool will convert to BoolAttribute (tho in python Bool is alias to long)
Long will convert to RealAttribute
VectorDouble will convert list to RealArray
| Enumerator | |
|---|---|
| STRING | |
| PREDEFINED_STRING | |
| UPPER_CASE_STRING | |
| STRING_LIST | |
| DOUBLE | |
| BOOL | |
| INT | |
| FLOAT_LIST | |
Definition at line 80 of file PyOpalObject.h.
| void PyOpal::PyOpalObjectNS::update | ( | PyOpalObjectNS::PyOpalObject< C > | pyelement | ) |
Call update on a pyelement
Note that C must be a subtype of OpalElement or some other class that has an C::update() method (i.e. not OpalObject).
Definition at line 340 of file PyOpalObject.h.
References PyOpal::PyOpalObjectNS::PyOpalObject< C >::getOpalShared().
Referenced by PyOpal::PyAsymmetricEnge::BOOST_PYTHON_MODULE(), PyOpal::PyEnge::BOOST_PYTHON_MODULE(), PyOpal::PyOpalPolynomialTimeDependence::BOOST_PYTHON_MODULE(), PyOpal::PyOpalSinusoidalTimeDependence::BOOST_PYTHON_MODULE(), and PyOpal::PyOpalSplineTimeDependence::BOOST_PYTHON_MODULE().
| std::map< AttributeType, std::string > PyOpal::PyOpalObjectNS::attributeName |
Maps the AttributeType to a string representation for docstrings/etc
Definition at line 22 of file PyOpalObject.cpp.
Referenced by PyOpal::PyOpalObjectNS::PyOpalObject< C >::getAttribute(), PyOpal::PyOpalObjectNS::PyOpalObject< C >::getDocString(), and PyOpal::PyOpalObjectNS::PyOpalObject< C >::setAttribute().
| double PyOpal::PyOpalObjectNS::PyOpalObject< C >::bfieldUnits_m = 1 |
Definition at line 889 of file PyOpalObject.h.
| double PyOpal::PyOpalObjectNS::PyOpalObject< C >::distanceUnits_m = 1 |
Definition at line 887 of file PyOpalObject.h.
| double PyOpal::PyOpalObjectNS::PyOpalObject< C >::efieldUnits_m = 1 |
Definition at line 890 of file PyOpalObject.h.
| const std::string PyOpal::PyOpalObjectNS::PyOpalObject< C >::getFieldValueDocString |
Definition at line 892 of file PyOpalObject.h.
| std::map<std::string, AttributeDef> PyOpal::PyOpalObjectNS::PyOpalObject< C >::pyNameToAttribute |
apparently this is okay because it is a template and doesnt break one definition rule
Definition at line 332 of file PyOpalObject.h.
| double PyOpal::PyOpalObjectNS::PyOpalObject< C >::timeUnits_m = 1 |
Definition at line 888 of file PyOpalObject.h.
| const PyOpalObject<C>* PyOpal::PyOpalObjectNS::PyOpalObjectGetProperty< C >::object_m = nullptr |
Definition at line 940 of file PyOpalObject.h.
| PyOpalObject<C>* PyOpal::PyOpalObjectNS::PyOpalObjectSetProperty< C >::object_m = nullptr |
Definition at line 959 of file PyOpalObject.h.