GridFire 0.0.1a
General Purpose Nuclear Network
Loading...
Searching...
No Matches
bindings.cpp
Go to the documentation of this file.
1#include <pybind11/pybind11.h>
2#include <pybind11/stl.h> // Needed for vectors, maps, sets, strings
3#include <pybind11/stl_bind.h> // Needed for binding std::vector, std::map etc. if needed directly
4
5#include "bindings.h"
6
7namespace py = pybind11;
8
10
11void register_expectation_bindings(py::module &m) {
12 py::enum_<gridfire::expectations::EngineErrorTypes>(m, "EngineErrorTypes")
16 .export_values();
17
18 py::enum_<gridfire::expectations::StaleEngineErrorTypes>(m, "StaleEngineErrorTypes")
20 .export_values();
21
22 // Bind the base class
23 py::class_<gridfire::expectations::EngineError>(m, "EngineError")
24 .def_readonly("message", &gridfire::expectations::EngineError::m_message)
25 .def_readonly("type", &gridfire::expectations::EngineError::type)
26 .def("__str__", [](const gridfire::expectations::EngineError &e) {return e.m_message;});
27
28 // Bind the EngineIndexError, specifying EngineError as the base
29 py::class_<gridfire::expectations::EngineIndexError, gridfire::expectations::EngineError>(m, "EngineIndexError")
30 .def(py::init<int>(), py::arg("index"))
32 .def("__str__", [](const gridfire::expectations::EngineIndexError &e) {
33 return e.m_message + " at index " + std::to_string(e.m_index);
34 });
35
36 // Bind the StaleEngineError, specifying EngineError as the base
37 py::class_<gridfire::expectations::StaleEngineError, gridfire::expectations::EngineError>(m, "StaleEngineError")
38 .def(py::init<gridfire::expectations::StaleEngineErrorTypes>(), py::arg("stale_type"))
39 .def_readonly("stale_type", &gridfire::expectations::StaleEngineError::staleType)
40 .def("__str__", [](const gridfire::expectations::StaleEngineError &e) {
41 return static_cast<std::string>(e);
42 });
43}
void register_expectation_bindings(py::module &m)
Definition bindings.cpp:11