parametrizable.cpp
Go to the documentation of this file.
1 #include "parametrizable.h"
2 
3 namespace python
4 {
5  namespace pointmatchersupport
6  {
7  void pybindParametrizable(py::module& p_module)
8  {
10  py::class_<Parametrizable, std::shared_ptr<Parametrizable>> pyParametrizable(p_module, "Parametrizable");
11 
12  pyParametrizable.doc() = R"pbdoc(
13 The superclass of classes that are constructed using generic parameters.
14 This class provides the parameter storage and fetching mechanism
15 )pbdoc";
16 
18  py::register_exception<InvalidParameter>(pyParametrizable, "InvalidParameter");
19 
20  py::class_<ParameterDoc>(pyParametrizable, "ParameterDoc", "The documentation of a parameter")
21  .def_readwrite("name", &ParameterDoc::name, "name")
22  .def_readwrite("doc", &ParameterDoc::doc, "short documentation")
23  .def_readwrite("defaultValue", &ParameterDoc::defaultValue, "default value")
24  .def_readwrite("minValue", &ParameterDoc::minValue, "if bounds are checked, minimum value")
25  .def_readwrite("maxValue", &ParameterDoc::maxValue, "if bounds are checked, maxmimu value")
26 // .def_readwrite("comp", &ParameterDoc::comp, "pointer to comparison function") // FIXME Get this error when compiling -> error: invalid conversion from ‘bool (*)(std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char>)’ to ‘const void*’ [-fpermissive]
27 
28  .def(py::init<const std::string&, const std::string&, const std::string&, const std::string&, const std::string&, Parametrizable::LexicalComparison>(), py::arg("name"), py::arg("doc"), py::arg("defaultValue"), py::arg("minValue"), py::arg("maxValue"), py::arg("comp"))
29  .def(py::init<const std::string&, const std::string&, const std::string&>(), py::arg("name"), py::arg("doc"), py::arg("defaultValue"))
30 
31  .def("__str__", [](const ParameterDoc& self)
32  {
33  std::ostringstream oss;
34  oss << self;
35  return oss.str();
36  });
37 
39  py::bind_vector<ParametersDoc>(pyParametrizable, "ParametersDoc", "The documentation of all parameters");
40 
42  py::bind_map<Parameters>(pyParametrizable, "Parameters", "The documentation of all parameters", py::module_local())
43  .def("clear", &Parameters::clear, "Remove all items from D.");
44 
45  pyParametrizable.def_readonly("className", &Parametrizable::className, "name of the class")
46  .def_readonly("parametersDoc", &Parametrizable::parametersDoc, "documentation of parameters")
47  .def_readwrite("parameters", &Parametrizable::parameters, "parameters with their values encoded in string")
48  .def_readwrite("parametersUsed", &Parametrizable::parametersUsed, "parameters whose value has actually been read")
49 
50  .def(py::init<>())
51  .def(py::init<const std::string&, const ParametersDoc, Parameters&>(), py::arg("className"), py::arg("paramsDoc"), py::arg("params"))
52 
53  .def("getParamValueString", &Parametrizable::getParamValueString)
54  .def("__str__", [](const Parametrizable& self)
55  {
56  std::ostringstream oss;
57  oss << self;
58  return oss.str();
59  });
60 
61  p_module.def("__str__", [](const ParametersDoc& self)
62  {
63  std::ostringstream oss;
64  oss << self;
65  return oss.str();
66  });
67  }
68  }
69 }
void pybindParametrizable(py::module &p_module)
ParametersUsed parametersUsed
parameters whose value has actually been read
PointMatcherSupport::Parametrizable Parametrizable
std::string minValue
if bounds are checked, minimum value
std::map< std::string, Parameter > Parameters
Parameters stored as a map of string->string.
PointMatcherSupport::Parametrizable::ParametersDoc ParametersDoc
PM::Parameters Parameters
std::string maxValue
if bounds are checked, maxmimu value
Parameters parameters
parameters with their values encoded in string
The documentation of a parameter.
The superclass of classes that are constructed using generic parameters. This class provides the para...
An exception thrown when one tries to fetch the value of an unexisting parameter. ...
std::string getParamValueString(const std::string &paramName)
Get the value of a parameter, as a string.
std::vector< ParameterDoc > ParametersDoc
The documentation of all parameters.
const std::string className
name of the class
Parametrizable::InvalidParameter InvalidParameter
const ParametersDoc parametersDoc
documentation of parameters


libpointmatcher
Author(s):
autogenerated on Sat May 27 2023 02:38:02