JeVois
1.22
JeVois Smart Embedded Machine Vision Toolkit
|
|
#include <jevois/Core/PythonParameter.H>
Wrapper for jevois Parameter in python.
This wrapper allows python modules to create JeVois Parameter objects, allowing users to interact with the parameters through the console, JeVois-Inventor, or the JeVois-Pro GUI. This class does not actually contain the parameter, it is just an interface. Parameters belong to the Component associated with the python code via PythonWrapper.
Definition at line 97 of file PythonParameter.H.
Public Member Functions | |
PythonParameter (boost::python::object &pyinst, std::string const &name, std::string const &typ, std::string const &description, boost::python::object const &defaultValue, jevois::ParameterCategory const &category) | |
Constructor. Adds a dynamic parameter to the Component associated with pyinst. | |
~PythonParameter () | |
Destructor. Removes the dynamic parameter from the associated Component. | |
std::string const & | name () const |
Get the parameter name. | |
std::string | descriptor () const |
Get the parameter fully-qualified name, aka descriptor, including names of owning Component and all parents. | |
boost::python::object | get () const |
Get the value of this Parameter. | |
void | set (boost::python::object const &newVal) |
Set the value of this Parameter. | |
std::string const | strget () const |
Get the value as a string. | |
void | strset (std::string const &valstring) |
Set the value from a string representation of it. | |
void | freeze (bool doit) |
Freeze/unfreeze this parameter, it becomes read-only and will not show up in the help message. | |
bool | frozen () const |
Returns whether parameter is frozen. | |
void | reset () |
Reset this parameter to its default value. | |
void | setCallback (boost::python::object const &cb) |
Set the parameter's callback. | |
jevois::PythonParameter::PythonParameter | ( | boost::python::object & | pyinst, |
std::string const & | name, | ||
std::string const & | typ, | ||
std::string const & | description, | ||
boost::python::object const & | defaultValue, | ||
jevois::ParameterCategory const & | category | ||
) |
Constructor. Adds a dynamic parameter to the Component associated with pyinst.
Definition at line 100 of file PythonParameter.C.
References JEVOIS_VERSION_STRING, and LFATAL.
jevois::PythonParameter::~PythonParameter | ( | ) |
Destructor. Removes the dynamic parameter from the associated Component.
Definition at line 122 of file PythonParameter.C.
std::string jevois::PythonParameter::descriptor | ( | ) | const |
Get the parameter fully-qualified name, aka descriptor, including names of owning Component and all parents.
Definition at line 130 of file PythonParameter.C.
References jevois::Component::descriptor().
void jevois::PythonParameter::freeze | ( | bool | doit | ) |
Freeze/unfreeze this parameter, it becomes read-only and will not show up in the help message.
Definition at line 150 of file PythonParameter.C.
bool jevois::PythonParameter::frozen | ( | ) | const |
Returns whether parameter is frozen.
Definition at line 154 of file PythonParameter.C.
boost::python::object jevois::PythonParameter::get | ( | ) | const |
Get the value of this Parameter.
Definition at line 134 of file PythonParameter.C.
std::string const & jevois::PythonParameter::name | ( | ) | const |
Get the parameter name.
Definition at line 126 of file PythonParameter.C.
void jevois::PythonParameter::reset | ( | ) |
Reset this parameter to its default value.
Definition at line 158 of file PythonParameter.C.
void jevois::PythonParameter::set | ( | boost::python::object const & | newVal | ) |
Set the value of this Parameter.
Will throw if the new value is not accepted, in which case the old value will remain in the Parameter.
Definition at line 138 of file PythonParameter.C.
void jevois::PythonParameter::setCallback | ( | boost::python::object const & | cb | ) |
Set the parameter's callback.
The callback function is called each time one tries to change the value of the parameter. It will also be called one first time, with the current parameter value, as soon as the callback is set.
The callback should examine the candidate value newval and (1) if it does not like it, throw and with a descriptive message of why the value is rejected, (2) otherwise, it is assumed that the value is accepted and the callback can then allocate resources or do other work with that value (the actual modification of the Parameter object is handled upstream and the callback does not need to worry about it: if it returns without throwing, the proposed value will become the new value of the Parameter). The Parameter is locked-up for writing as long as the callback is running, to avoid destruction of the parameter and/or concurrent parameter value changes by several different threads. Thus, callbacks should try to execute quickly, and should not call set(), etc on the parameter as this will always deadlock (get() is allowed if your callback needs to know the current value of the parameter).
Definition at line 162 of file PythonParameter.C.
std::string const jevois::PythonParameter::strget | ( | ) | const |
Get the value as a string.
Definition at line 142 of file PythonParameter.C.
void jevois::PythonParameter::strset | ( | std::string const & | valstring | ) |
Set the value from a string representation of it.
std::range_error | if the given string cannot be converted to a Parameter value, or the value is invalid according to our valid values spec or rejected by the Parameter's callback (if any). |
Definition at line 146 of file PythonParameter.C.