JeVois  1.20
JeVois Smart Embedded Machine Vision Toolkit
Share this page:

#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. More...
 
 ~PythonParameter ()
 Destructor. Removes the dynamic parameter from the associated Component. More...
 
const std::string & name () const
 Get the parameter name. More...
 
std::string descriptor () const
 Get the parameter fully-qualified name, aka descriptor, including names of owning Component and all parents. More...
 
boost::python::object get () const
 Get the value of this Parameter. More...
 
void set (boost::python::object const &newVal)
 Set the value of this Parameter. More...
 
const std::string strget () const
 Get the value as a string. More...
 
void strset (std::string const &valstring)
 Set the value from a string representation of it. More...
 
void freeze (bool doit)
 Freeze/unfreeze this parameter, it becomes read-only and will not show up in the help message. More...
 
void reset ()
 Reset this parameter to its default value. More...
 
void setCallback (boost::python::object const &cb)
 Set the parameter's callback. More...
 

Constructor & Destructor Documentation

◆ PythonParameter()

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 LFATAL.

◆ ~PythonParameter()

jevois::PythonParameter::~PythonParameter ( )

Destructor. Removes the dynamic parameter from the associated Component.

Definition at line 122 of file PythonParameter.C.

Member Function Documentation

◆ descriptor()

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.

◆ freeze()

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.

◆ get()

boost::python::object jevois::PythonParameter::get ( ) const

Get the value of this Parameter.

Definition at line 134 of file PythonParameter.C.

◆ name()

const std::string & jevois::PythonParameter::name ( ) const

Get the parameter name.

Definition at line 126 of file PythonParameter.C.

◆ reset()

void jevois::PythonParameter::reset ( )

Reset this parameter to its default value.

Definition at line 154 of file PythonParameter.C.

◆ set()

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.

◆ setCallback()

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 158 of file PythonParameter.C.

◆ strget()

const std::string jevois::PythonParameter::strget ( ) const

Get the value as a string.

Definition at line 142 of file PythonParameter.C.

◆ strset()

void jevois::PythonParameter::strset ( std::string const &  valstring)

Set the value from a string representation of it.

Exceptions
std::range_errorif 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.


The documentation for this class was generated from the following files: