1 #ifndef MHO_PyParameterStoreInterface_HH__
2 #define MHO_PyParameterStoreInterface_HH__
7 #include "pybind11_json/pybind11_json.hpp"
8 #include <pybind11/embed.h>
9 #include <pybind11/pybind11.h>
10 namespace py = pybind11;
11 namespace nl = nlohmann;
12 using namespace pybind11::literals;
31 bool IsPresent(
const std::string& value_path)
const {
return fParameterStore->IsPresent(value_path); }
34 py::object
Get(
const std::string& value_path)
const
37 bool ok = fParameterStore->Get(value_path, obj);
40 msg_error(
"python_bindings",
"error getting value associated with key: " << value_path << eom);
41 py::print(
"error getting value associated with key: ", value_path);
48 void Set(
const std::string& value_path, py::object
value)
const
51 bool ok = fParameterStore->Set(value_path, obj);
54 msg_error(
"python_bindings",
"error setting value associated with key: " << value_path << eom);
55 py::print(
"error setting value associated with key: ", value_path);
63 fParameterStore->DumpData(obj);
74 py::class_< MHO_PyParameterStoreInterface >(m, pyclass_name.c_str())
77 "check if parameter with specified path is present in the store", py::arg(
"value_path"))
80 py::arg(
"value_path"), py::arg(
"value"))
82 "get a copy of the contents of the parameter store as a dictionary");
#define msg_error(xKEY, xCONTENT)
Definition: MHO_Message.hh:244
Class MHO_ParameterStore.
Definition: MHO_ParameterStore.hh:52
python bindings for the MHO_ParameterStore
Definition: MHO_PyParameterStoreInterface.hh:26
py::object Get(const std::string &value_path) const
Definition: MHO_PyParameterStoreInterface.hh:34
void Set(const std::string &value_path, py::object value) const
Definition: MHO_PyParameterStoreInterface.hh:48
virtual ~MHO_PyParameterStoreInterface()
Definition: MHO_PyParameterStoreInterface.hh:29
bool IsPresent(const std::string &value_path) const
Definition: MHO_PyParameterStoreInterface.hh:31
MHO_PyParameterStoreInterface(MHO_ParameterStore *paramStore)
Definition: MHO_PyParameterStoreInterface.hh:28
py::dict GetContents()
Definition: MHO_PyParameterStoreInterface.hh:60
Definition: MHO_ChannelLabeler.hh:17
void DeclarePyParameterStoreInterface(py::module &m, std::string pyclass_name)
Definition: MHO_PyParameterStoreInterface.hh:72