39 using padp = std::shared_ptr<jevois::python::PyParHelperBase>(*)(
jevois::Component *, std::string
const &,
40 std::string
const &, boost::python::object
const &,
68 static std::map<std::string, padp> padp_map
70 {
"bool", padp_bool },
71 {
"char", padp_char },
72 {
"byte", padp_byte },
73 {
"uint8", padp_byte },
74 {
"int16", padp_int16 },
75 {
"uint16", padp_uint16 },
77 {
"uint", padp_uint },
78 {
"int32", padp_int },
79 {
"uint32", padp_uint },
80 {
"long", padp_long },
81 {
"int64", padp_long },
82 {
"uint64", padp_ulong },
83 {
"float", padp_float },
84 {
"double", padp_double },
85 {
"str", padp_string },
86 {
"ipoint", padp_ipoint },
87 {
"fpoint", padp_fpoint },
88 {
"isize", padp_isize },
89 {
"fsize", padp_fsize },
90 {
"iscalar", padp_iscalar },
91 {
"fscalar", padp_fscalar },
94 {
"color", padp_color },
101 std::string
const & typ, std::string
const & description,
102 boost::python::object
const & defaultValue,
105 auto itr = padp_map.find(typ);
107 if (itr == padp_map.end())
109 std::string errmsg =
"Unsupported parameter type [" + typ +
"] -- Supported types are: ";
110 for (
auto const & mapping : padp_map) errmsg += std::string(mapping.first) +
", ";
115 jevois::Component * comp = jevois::python::engine()->getPythonComponent(pyinst.ptr()->ob_type);
118 itsPyPar = itr->second(comp, name, description, defaultValue, category);
127{
return itsPyPar->par()->name(); }
135{
return itsPyPar->get(); }
139{ itsPyPar->set(newVal); }
143{
return itsPyPar->par()->strget(); }
147{ itsPyPar->par()->strset(valstring); }
151{ itsPyPar->par()->freeze(doit); }
155{
return itsPyPar->par()->frozen(); }
159{ itsPyPar->par()->reset(); }
163{ itsPyPar->setCallback(cb); }
#define JEVOIS_VERSION_STRING
Software version, as string.
A component of a model hierarchy.
std::string descriptor() const
Get our full descriptor (including all parents) as [Instancename]:[...]:[...].
std::string const & name() const
Get the parameter name.
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 reset()
Reset this parameter to its default value.
bool frozen() const
Returns whether parameter is frozen.
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.
boost::python::object get() const
Get the value of this Parameter.
void freeze(bool doit)
Freeze/unfreeze this parameter, it becomes read-only and will not show up in the help message.
void setCallback(boost::python::object const &cb)
Set the parameter's callback.
~PythonParameter()
Destructor. Removes the dynamic parameter from the associated Component.
std::string descriptor() const
Get the parameter fully-qualified name, aka descriptor, including names of owning Component and all p...
jevois::Component * comp() const
Access the associated C++ Component.
virtual ~PyParHelperBase()
Remove param from component.
PyParHelperBase(jevois::Component *comp)
Constructor.
Typed class to allow creation of Parameter in Python.
#define LFATAL(msg)
Convenience macro for users to print out console or syslog messages, FATAL level.
A category to which multiple ParameterDef definitions can belong.