OPAL (Object Oriented Parallel Accelerator Library)  2024.1
OPAL
PyDistribution.cpp
Go to the documentation of this file.
1 //
2 // Python API for Distribution
3 //
4 // Copyright (c) 2023, Chris Rogers, STFC Rutherford Appleton Laboratory, Didcot, UK
5 //
6 // This file is part of OPAL.
7 //
8 // OPAL is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation, either version 3 of the License, or
11 // (at your option) any later version.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
15 //
16 
18 #include "PyOpal/PyCore/Globals.h"
21 
22 namespace PyOpal {
23 namespace PyDistributionNS {
24 
25 template <>
26 std::vector<PyOpalObjectNS::AttributeDef> PyOpalObjectNS::PyOpalObject<Distribution>::attributes = {
27  {"TYPE", "type", "", PyOpalObjectNS::PREDEFINED_STRING},
28  {"FNAME", "filename", "", PyOpalObjectNS::STRING},
29  {"INPUTMOUNITS", "momentum_units", "", PyOpalObjectNS::PREDEFINED_STRING},
30 };
31 
33  Object* obj = &(*dist.getOpalShared());
34  obj->update();
36 }
37 
42  auto distributionClass = distributionObject.make_class("Distribution");
43  distributionObject.addExecute(distributionClass);
44  distributionClass.def("register", &registerDistribution);
45 
46 }
47 
48 } // PyDistribution
49 } // PyOpal
50 
static OpalData * getInstance()
Definition: OpalData.cpp:196
The base class for all OPAL objects.
Definition: Object.h:48
void Initialise()
Definition: Globals.cpp:50
void addExecute(PYCLASS &pyclass)
Definition: PyOpalObject.h:761
void define(Object *newObject)
Define a new object.
Definition: OpalData.cpp:489
std::shared_ptr< C > getOpalShared()
Definition: PyOpalObject.h:286
virtual void update()
Update this object.
Definition: Object.cpp:263
b Accompany it with a written valid for at least three to give any third for a charge no more than your cost of physically performing source distribution
Definition: LICENSE:140
BOOST_PYTHON_MODULE(distribution)
boost::python::class_< PyC > make_class(const char *className)
Definition: PyOpalObject.h:745
void registerDistribution(PyOpalObjectNS::PyOpalObject< Distribution > &dist)