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 }
PointMatcherSupport::Parametrizable::parametersDoc
const ParametersDoc parametersDoc
documentation of parameters
Definition: Parametrizable.h:203
PointMatcherSupport::Parametrizable::ParameterDoc::doc
std::string doc
short documentation
Definition: Parametrizable.h:163
PointMatcherSupport::Parametrizable::parametersUsed
ParametersUsed parametersUsed
parameters whose value has actually been read
Definition: Parametrizable.h:205
Parameters
PM::Parameters Parameters
Definition: filterProfiler.cpp:20
ParametersDoc
PointMatcherSupport::Parametrizable::ParametersDoc ParametersDoc
Definition: list_modules.cpp:42
parametrizable.h
python
Definition: add_descriptor.cpp:5
PointMatcherSupport::Parametrizable::ParametersDoc
std::vector< ParameterDoc > ParametersDoc
The documentation of all parameters.
Definition: Parametrizable.h:187
PointMatcherSupport::Parametrizable::ParameterDoc::defaultValue
std::string defaultValue
default value
Definition: Parametrizable.h:164
PointMatcherSupport::Parametrizable::parameters
Parameters parameters
parameters with their values encoded in string
Definition: Parametrizable.h:204
PointMatcherSupport::Parametrizable::ParameterDoc::maxValue
std::string maxValue
if bounds are checked, maxmimu value
Definition: Parametrizable.h:166
PointMatcherSupport::Parametrizable::ParameterDoc::name
std::string name
name
Definition: Parametrizable.h:162
InvalidParameter
Parametrizable::InvalidParameter InvalidParameter
Definition: pypoint_matcher_helper.h:42
PointMatcherSupport::Parametrizable::InvalidParameter
An exception thrown when one tries to fetch the value of an unexisting parameter.
Definition: Parametrizable.h:144
PointMatcherSupport::Parametrizable::getParamValueString
std::string getParamValueString(const std::string &paramName)
Get the value of a parameter, as a string.
Definition: Parametrizable.cpp:199
PointMatcherSupport::Parametrizable
The superclass of classes that are constructed using generic parameters. This class provides the para...
Definition: Parametrizable.h:141
python::pointmatchersupport::pybindParametrizable
void pybindParametrizable(py::module &p_module)
Definition: parametrizable.cpp:7
PointMatcherSupport::Parametrizable::ParameterDoc
The documentation of a parameter.
Definition: Parametrizable.h:160
Parametrizable
PointMatcherSupport::Parametrizable Parametrizable
Definition: PointToPlane.cpp:47
PointMatcherSupport::Parametrizable::ParameterDoc::minValue
std::string minValue
if bounds are checked, minimum value
Definition: Parametrizable.h:165
PointMatcherSupport::Parametrizable::className
const std::string className
name of the class
Definition: Parametrizable.h:202
PointMatcherSupport::Parametrizable::Parameters
std::map< std::string, Parameter > Parameters
Parameters stored as a map of string->string.
Definition: Parametrizable.h:199


libpointmatcher
Author(s):
autogenerated on Mon Sep 16 2024 02:24:09