HOPS
HOPS class reference
MHO_PyFringeDataInterface.hh
Go to the documentation of this file.
1 #ifndef MHO_PyFringeDataInterface_HH__
2 #define MHO_PyFringeDataInterface_HH__
3 
6 #include "MHO_ContainerStore.hh"
7 #include "MHO_FringeData.hh"
8 
12 #include "MHO_PyTableContainer.hh"
13 
14 //need these extras to be able to translate between nl:json and py:dict or py::object
15 #include "pybind11_json/pybind11_json.hpp"
16 #include <pybind11/embed.h>
17 #include <pybind11/pybind11.h>
18 namespace py = pybind11;
19 namespace nl = nlohmann;
20 using namespace pybind11::literals;
21 
22 namespace hops
23 {
24 
25 // Forward declaration - full definition is only required by modules that link MHO_Operators
26 class MHO_OperatorToolbox;
27 
37 {
38  public:
40  : fFringeData(fdata), fScanInterface(fdata->GetScanDataStore()), fContainerInterface(fdata->GetContainerStore()),
41  fParameterInterface(fdata->GetParameterStore()), fOperatorToolbox(nullptr){
42 
43  };
44 
46 
47  void SetOperatorToolbox(MHO_OperatorToolbox* toolbox) { fOperatorToolbox = toolbox; }
48 
49  MHO_OperatorToolbox* GetOperatorToolbox() { return fOperatorToolbox; }
50 
51  MHO_PyParameterStoreInterface& GetParameterStore() { return fParameterInterface; }
52 
53  MHO_PyContainerStoreInterface& GetContainerStore() { return fContainerInterface; }
54 
55  MHO_PyScanStoreInterface& GetScanStore() { return fScanInterface; }
56 
57  //return copy of vex data converted to py::dict
58  py::dict GetVex() const { return fFringeData->GetVex(); }
59 
60  py::dict GetPlotData() const { return fFringeData->GetPlotData(); }
61 
62  //for now we do not expose these to python
63  //access to the control format and parsed control statements as py::dict
64  // py::dict GetControlFormat() const {return fFringeData->GetControlFormat();}
65  // py::dict GetControlStatements() const {return fFringeData->GetControlStatements();}
66 
67  private:
68  MHO_FringeData* fFringeData;
69 
70  // Pointer to the operator toolbox - injected by pyMHO_Operators after construction.
71  // Only a pointer is stored here; the full type is forward-declared above.
72  MHO_OperatorToolbox* fOperatorToolbox;
73 
74  //pointer to the parameter store
75  MHO_PyScanStoreInterface fScanInterface;
76  MHO_PyContainerStoreInterface fContainerInterface;
77  MHO_PyParameterStoreInterface fParameterInterface;
78 };
79 
80 inline void DeclarePyFringeDataInterface(py::module& m, std::string pyclass_name)
81 {
82  py::class_< MHO_PyFringeDataInterface >(m, pyclass_name.c_str())
83  //no __init__ def here, as this class is not meant to be constructable on the python side
84  .def("get_parameter_store", &hops::MHO_PyFringeDataInterface::GetParameterStore, py::return_value_policy::reference,
85  "get the current parameter set object")
86  .def("get_container_store", &hops::MHO_PyFringeDataInterface::GetContainerStore, py::return_value_policy::reference,
87  "get the current container store object")
88  .def("get_scan_store", &hops::MHO_PyFringeDataInterface::GetScanStore, py::return_value_policy::reference,
89  "get the current scan data store object")
90  .def("get_vex", &hops::MHO_PyFringeDataInterface::GetVex, py::return_value_policy::copy,
91  "get the current scan ovex/root data as a python dictionary")
92  .def("get_plot_data", &hops::MHO_PyFringeDataInterface::GetPlotData, py::return_value_policy::copy,
93  "get the current plot data as a python dictionary");
94 }
95 
96 } // namespace hops
97 
98 #endif
Class MHO_FringeData.
Definition: MHO_FringeData.hh:30
Class MHO_OperatorToolbox.
Definition: MHO_OperatorToolbox.hh:28
python binding to the MHO_ContainerStore
Definition: MHO_PyContainerStoreInterface.hh:30
python bindings for the MHO_FringeData class
Definition: MHO_PyFringeDataInterface.hh:37
void SetOperatorToolbox(MHO_OperatorToolbox *toolbox)
Definition: MHO_PyFringeDataInterface.hh:47
MHO_PyScanStoreInterface & GetScanStore()
Definition: MHO_PyFringeDataInterface.hh:55
MHO_OperatorToolbox * GetOperatorToolbox()
Definition: MHO_PyFringeDataInterface.hh:49
MHO_PyParameterStoreInterface & GetParameterStore()
Definition: MHO_PyFringeDataInterface.hh:51
py::dict GetVex() const
Definition: MHO_PyFringeDataInterface.hh:58
MHO_PyFringeDataInterface(MHO_FringeData *fdata)
Definition: MHO_PyFringeDataInterface.hh:39
MHO_PyContainerStoreInterface & GetContainerStore()
Definition: MHO_PyFringeDataInterface.hh:53
py::dict GetPlotData() const
Definition: MHO_PyFringeDataInterface.hh:60
virtual ~MHO_PyFringeDataInterface()
Definition: MHO_PyFringeDataInterface.hh:45
python bindings for the MHO_ParameterStore
Definition: MHO_PyParameterStoreInterface.hh:26
python bindings for the MHO_ScanDataStore
Definition: MHO_PyScanStoreInterface.hh:31
Definition: MHO_AdhocFlagging.hh:18
void DeclarePyFringeDataInterface(py::module &m, std::string pyclass_name)
Definition: MHO_PyFringeDataInterface.hh:80