libvisiontransfer  10.6.0
Public Types | Public Member Functions | List of all members
visiontransfer::param::Parameter Class Reference

Detailed Description

The main Parameter class. A variant-like type with current and default values and a lot of metadata. Parameter data is softly typed, the getters and setters accept a template parameter and are interoperable; with the notable exception of Tensor-type parameters, which have specific accessors.

If OpenCv is included ahead of including this file in your project, header-only TYPE_TENSOR<->OpenCv adapters for cv::Size and cv::Mat are made available.

Definition at line 71 of file parameter.h.

#include <visiontransfer/parameter.h>

Public Types

enum  GovernorType { GOVERNOR_NONE = 0, GOVERNOR_SHELL = 1, GOVERNOR_DBUS = 2 }
 
enum  ParameterAccessMode { ACCESS_NONE = 0, ACCESS_READONLY = 1, ACCESS_READWRITE = 2 }
 
enum  ParameterInteractionHint { INTERACTION_INVISIBLE = -1, INTERACTION_INACTIVE = 0, INTERACTION_ACTIVE = 1 }
 

Public Member Functions

 Parameter ()
 
 Parameter (const std::string &uid)
 
std::string getUid () const
 
std::string getName () const
 
std::string getModuleName () const
 
std::string getCategoryName () const
 
std::string getDescription () const
 
std::string getUnit () const
 
ParameterValue::ParameterType getType () const
 
ParameterAccessMode getAccessForConfig () const
 
ParameterAccessMode getAccessForApi () const
 
ParametersetAccessForConfig (ParameterAccessMode mode)
 
ParametersetAccessForApi (ParameterAccessMode mode)
 
ParameterInteractionHint getInteractionHint () const
 
ParametersetInteractionHint (ParameterInteractionHint hint)
 
bool getIsModified () const
 
ParametersetIsModified (bool mod)
 
GovernorType getGovernorType () const
 
std::string getGovernorString () const
 
ParametersetGovernor (GovernorType govType, const std::string &govStr)
 
bool getInvokeGovernorOnInit () const
 
ParametersetInvokeGovernorOnInit (bool invoke)
 
std::string interpolateCommandLine (const ParameterValue &newVal)
 
bool isTensor () const
 
bool isScalar () const
 
bool isCommand () const
 
unsigned int getTensorDimension () const
 
std::vector< unsigned int > getTensorShape () const
 
unsigned int getTensorNumElements () const
 
std::vector< double > getTensorData () const
 
std::vector< double > getTensorDefaultData () const
 
std::vector< double > & getTensorDataReference ()
 
std::vector< double > & getTensorDefaultDataReference ()
 
ParametersetTensorData (const std::vector< double > &data)
 
ParametersetTensorDefaultData (const std::vector< double > &data)
 
ParametersetTensorFromCvSize (const cv::Size &cvSize)
 
void setCvSizeFromTensor (cv::Size &cvSize)
 
template<typename T >
ParametersetTensorFromCvMat (const cv::Mat_< T > &cvMat)
 
template<typename T >
void setCvMatFromTensor (cv::Mat_< T > &cvMat)
 
ParametersetName (const std::string &name)
 
ParametersetModuleName (const std::string &n)
 
ParametersetCategoryName (const std::string &n)
 
ParametersetDescription (const std::string &d)
 
ParametersetUnit (const std::string &d)
 
ParametersetType (ParameterValue::ParameterType t)
 
ParametersetAsTensor (const std::vector< unsigned int > &shape)
 
template<typename T >
bool isValidNewValue (T t) const
 
bool ensureValidDefault ()
 
bool ensureValidCurrent ()
 
template<typename T >
enforceIncrement (T t)
 
template<typename T >
ParametersetDefault (T t)
 
template<typename T >
ParametersetRange (T mn, T mx)
 
ParameterunsetRange ()
 
template<typename T >
ParametersetIncrement (T t)
 
template<typename T >
ParametersetCurrent (T t)
 
ParametersetCurrentFrom (const Parameter &from)
 
ParametersetCurrentFromDefault ()
 
template<typename T >
ParametersetOptions (const std::vector< T > &opts, const std::vector< std::string > &descriptions)
 
template<typename T >
ParametersetOptions (std::initializer_list< T > opts, std::initializer_list< std::string > descriptions)
 
template<typename T >
std::vector< T > getOptions () const
 
std::vector< std::string > getOptionDescriptions () const
 
ParameterValue getCurrentParameterValue ()
 
template<typename T >
getCurrent () const
 
ParameterValue getDefaultParameterValue ()
 
template<typename T >
getDefault () const
 
template<typename T >
getMin () const
 
template<typename T >
getMax () const
 
template<typename T >
getIncrement () const
 
bool hasOptions () const
 
bool hasCurrent () const
 
bool hasDefault () const
 
bool hasRange () const
 
bool hasIncrement () const
 
double at (unsigned int x)
 
double at (unsigned int y, unsigned int x)
 
double at (unsigned int z, unsigned int y, unsigned int x)
 
template<>
VT_EXPORT bool enforceIncrement (bool t)
 
template<>
VT_EXPORT int enforceIncrement (int t)
 
template<>
VT_EXPORT double enforceIncrement (double t)
 
template<>
VT_EXPORT std::string enforceIncrement (std::string t)
 

Constructor & Destructor Documentation

◆ Parameter() [1/2]

visiontransfer::param::Parameter::Parameter ( )
inline

Generate a new Parameter for manual filling

Definition at line 104 of file parameter.h.

◆ Parameter() [2/2]

visiontransfer::param::Parameter::Parameter ( const std::string &  uid)

Generate a new Parameter with specified UID (preferred) for manual filling

Definition at line 54 of file parameter.cpp.

Member Function Documentation

◆ at() [1/3]

double visiontransfer::param::Parameter::at ( unsigned int  x)
inline

Returns the x-th element of a 1-d tensor (vector). Also extends to higher dimensional tensors by indexing the flat data (as if getTensorData() has been used)

Definition at line 471 of file parameter.h.

◆ at() [2/3]

double visiontransfer::param::Parameter::at ( unsigned int  y,
unsigned int  x 
)
inline

Returns the y-th row, x-th column data element for a 2-dimensional tensor. Fails for other shapes or types

Definition at line 473 of file parameter.h.

◆ at() [3/3]

double visiontransfer::param::Parameter::at ( unsigned int  z,
unsigned int  y,
unsigned int  x 
)
inline

Returns the z-th slice, y-th row, x-th column data element for a 3-dimensional tensor. Fails for other shapes or types

Definition at line 475 of file parameter.h.

◆ enforceIncrement()

template<typename T >
T visiontransfer::param::Parameter::enforceIncrement ( t)

Returns value with any increment applied (starting at minimum, if specified)

◆ ensureValidCurrent()

bool visiontransfer::param::Parameter::ensureValidCurrent ( )

Ensures that the current value is in the valid options (if set) or range (if set). Returns whether value was revised.

Definition at line 338 of file parameter.cpp.

◆ ensureValidDefault()

bool visiontransfer::param::Parameter::ensureValidDefault ( )

Ensures that the default value is in the valid options (if set) or range (if set). Returns whether value was revised.

Definition at line 294 of file parameter.cpp.

◆ getAccessForApi()

ParameterAccessMode visiontransfer::param::Parameter::getAccessForApi ( ) const
inline

Return the visibility / access mode for the external API bridge

Definition at line 124 of file parameter.h.

◆ getAccessForConfig()

ParameterAccessMode visiontransfer::param::Parameter::getAccessForConfig ( ) const
inline

Return the visibility / access mode for the configuration web interface

Definition at line 122 of file parameter.h.

◆ getCategoryName()

std::string visiontransfer::param::Parameter::getCategoryName ( ) const
inline

Return the finer-grained category name within a module

Definition at line 114 of file parameter.h.

◆ getCurrent()

template<typename T >
T visiontransfer::param::Parameter::getCurrent ( ) const
inline

Returns the current value for the Parameter. Not supported for tensors (use getTensorData() instead).

Definition at line 406 of file parameter.h.

◆ getCurrentParameterValue()

ParameterValue visiontransfer::param::Parameter::getCurrentParameterValue ( )
inline

Returns the ParameterValue representing the Parameters current or default value

Definition at line 393 of file parameter.h.

◆ getDefault()

template<typename T >
T visiontransfer::param::Parameter::getDefault ( ) const
inline

Returns the default value for the Parameter. Not supported for tensors.

Definition at line 422 of file parameter.h.

◆ getDescription()

std::string visiontransfer::param::Parameter::getDescription ( ) const
inline

Return the parameter description (explanatory comment string)

Definition at line 116 of file parameter.h.

◆ getGovernorString()

std::string visiontransfer::param::Parameter::getGovernorString ( ) const
inline

Return the governor string, i.e. the specific script cmdline or the controlling D-Bus name

Definition at line 140 of file parameter.h.

◆ getGovernorType()

GovernorType visiontransfer::param::Parameter::getGovernorType ( ) const
inline

Return the governor type (whether setting the parameter is controlled by a script, D-Bus, or nothing yet)

Definition at line 138 of file parameter.h.

◆ getIncrement()

template<typename T >
T visiontransfer::param::Parameter::getIncrement ( ) const
inline

Returns the increment (granularity) for the Parameter (or the smallest possible value for the inferred template type if unset). Not supported for tensors.

Definition at line 437 of file parameter.h.

◆ getInteractionHint()

ParameterInteractionHint visiontransfer::param::Parameter::getInteractionHint ( ) const
inline

Gets the interaction UI hint (invisible / inactive / active)

Definition at line 130 of file parameter.h.

◆ getInvokeGovernorOnInit()

bool visiontransfer::param::Parameter::getInvokeGovernorOnInit ( ) const
inline

Gets the oninit action (after first load). False = do nothing; true = perform the same action as on change. Used for calling governor scripts immediately when the parameter daemon initializes.

Definition at line 144 of file parameter.h.

◆ getIsModified()

bool visiontransfer::param::Parameter::getIsModified ( ) const
inline

Returns whether the Parameter has unsaved (and unreverted) run-time modifications to its previously saved value, according to the parameter server.

Definition at line 134 of file parameter.h.

◆ getMax()

template<typename T >
T visiontransfer::param::Parameter::getMax ( ) const
inline

Returns the maximum value for the Parameter (or the highest possible value for the inferred template type if unset). Not supported for tensors.

Definition at line 432 of file parameter.h.

◆ getMin()

template<typename T >
T visiontransfer::param::Parameter::getMin ( ) const
inline

Returns the minimum value for the Parameter (or the lowest representable value for the inferred template type if unset). Not supported for tensors.

Definition at line 427 of file parameter.h.

◆ getModuleName()

std::string visiontransfer::param::Parameter::getModuleName ( ) const
inline

Return the overarching module name (abstract categorization for GUI etc.)

Definition at line 112 of file parameter.h.

◆ getName()

std::string visiontransfer::param::Parameter::getName ( ) const
inline

Return the current human-readable name

Definition at line 110 of file parameter.h.

◆ getOptionDescriptions()

std::vector<std::string> visiontransfer::param::Parameter::getOptionDescriptions ( ) const
inline

Returns the list of option descriptions for an enum-style Parameter (or an empty list for non-enums).

Definition at line 389 of file parameter.h.

◆ getOptions()

template<typename T >
std::vector<T> visiontransfer::param::Parameter::getOptions ( ) const
inline

Returns the list of possible values for an enum-style Parameter (or an empty list for non-enums).

Definition at line 381 of file parameter.h.

◆ getTensorData()

std::vector< double > visiontransfer::param::Parameter::getTensorData ( ) const

Returns a flat copy of the tensor data as a vector<double>

Definition at line 266 of file parameter.cpp.

◆ getTensorDataReference()

std::vector< double > & visiontransfer::param::Parameter::getTensorDataReference ( )

Returns a reference to the tensor data (CAUTION)

Definition at line 254 of file parameter.cpp.

◆ getTensorDefaultData()

std::vector< double > visiontransfer::param::Parameter::getTensorDefaultData ( ) const

Returns a flat copy of the tensor default data as a vector<double> (mostly internal use)

Definition at line 286 of file parameter.cpp.

◆ getTensorDefaultDataReference()

std::vector< double > & visiontransfer::param::Parameter::getTensorDefaultDataReference ( )

Returns a reference to the tensor default data (CAUTION)

Definition at line 278 of file parameter.cpp.

◆ getTensorDimension()

unsigned int visiontransfer::param::Parameter::getTensorDimension ( ) const
inline

Returns the tensor dimension, i.e. 1 for vectors, 2 for matrices etc.

Definition at line 158 of file parameter.h.

◆ getTensorNumElements()

unsigned int visiontransfer::param::Parameter::getTensorNumElements ( ) const
inline

Returns the total number of elements in the Tensor (product of the sizes in all dimensions).

Definition at line 164 of file parameter.h.

◆ getTensorShape()

std::vector<unsigned int> visiontransfer::param::Parameter::getTensorShape ( ) const
inline

Returns the tensor shape in all dimensions. This is {rows, columns} for matrices.

Definition at line 161 of file parameter.h.

◆ getType()

ParameterValue::ParameterType visiontransfer::param::Parameter::getType ( ) const
inline

Return the type of the parameter values, one of the scalar, tensor, or command types from ParameterValue::ParameterType. Value assignments are subject to type compatibility checks.

Definition at line 120 of file parameter.h.

◆ getUid()

std::string visiontransfer::param::Parameter::getUid ( ) const
inline

Return the current UID

Definition at line 108 of file parameter.h.

◆ getUnit()

std::string visiontransfer::param::Parameter::getUnit ( ) const
inline

Return the reference unit for the values of the Parameter as a string (e.g. "cm", "µs" etc.)

Definition at line 118 of file parameter.h.

◆ hasCurrent()

bool visiontransfer::param::Parameter::hasCurrent ( ) const
inline

Returns true iff the Parameter has a defined current value

Definition at line 445 of file parameter.h.

◆ hasDefault()

bool visiontransfer::param::Parameter::hasDefault ( ) const
inline

Returns true iff the Parameter has a defined default value

Definition at line 454 of file parameter.h.

◆ hasIncrement()

bool visiontransfer::param::Parameter::hasIncrement ( ) const
inline

Returns true iff the Parameter has an increment (granularity) set, false otherwise

Definition at line 467 of file parameter.h.

◆ hasOptions()

bool visiontransfer::param::Parameter::hasOptions ( ) const
inline

Returns true for an enum-style Parameter (i.e. a list of valid options has been set), false otherwise.

Definition at line 441 of file parameter.h.

◆ hasRange()

bool visiontransfer::param::Parameter::hasRange ( ) const
inline

Returns true iff the Parameter has a limited range set, false otherwise

Definition at line 463 of file parameter.h.

◆ interpolateCommandLine()

std::string visiontransfer::param::Parameter::interpolateCommandLine ( const ParameterValue newVal)

Perform a substition of %-initiated placeholders with correctly quoted parameter [meta-]data (for compiling shell commandlines).

Definition at line 58 of file parameter.cpp.

◆ isCommand()

bool visiontransfer::param::Parameter::isCommand ( ) const
inline

Returns true iff the value type of the Parameter is COMMAND (a special string type that corresponds to single-shot actions such as buttons)

Definition at line 156 of file parameter.h.

◆ isScalar()

bool visiontransfer::param::Parameter::isScalar ( ) const
inline

Returns true iff the value type of the Parameter is scalar, i.e. neither TENSOR nor COMMAND

Definition at line 154 of file parameter.h.

◆ isTensor()

bool visiontransfer::param::Parameter::isTensor ( ) const
inline

Returns true iff the value type of the Parameter is TENSOR

Definition at line 152 of file parameter.h.

◆ isValidNewValue()

template<typename T >
bool visiontransfer::param::Parameter::isValidNewValue ( t) const
inline

Returns whether the specified value is acceptable for the current Parameter (if it is constrained by range or enum list)

Definition at line 281 of file parameter.h.

◆ setAccessForApi()

Parameter& visiontransfer::param::Parameter::setAccessForApi ( ParameterAccessMode  mode)
inline

Sets the visibility / access mode for the external API bridge

Definition at line 128 of file parameter.h.

◆ setAccessForConfig()

Parameter& visiontransfer::param::Parameter::setAccessForConfig ( ParameterAccessMode  mode)
inline

Sets the visibility / access mode for the configuration web interface

Definition at line 126 of file parameter.h.

◆ setAsTensor()

Parameter& visiontransfer::param::Parameter::setAsTensor ( const std::vector< unsigned int > &  shape)
inline

Sets a Parameter to be a tensor, specifying the shape at the same time

Definition at line 273 of file parameter.h.

◆ setCategoryName()

Parameter& visiontransfer::param::Parameter::setCategoryName ( const std::string &  n)
inline

Sets the finer-grained category name within a module

Definition at line 254 of file parameter.h.

◆ setCurrent()

template<typename T >
Parameter& visiontransfer::param::Parameter::setCurrent ( t)
inline

Sets or overwrites the current value of the Parameter. Type compatibility is enforced and std::runtime_error is thrown for violations.

Definition at line 348 of file parameter.h.

◆ setCurrentFrom()

Parameter & visiontransfer::param::Parameter::setCurrentFrom ( const Parameter from)

Copies over the current value from the specified Parameter into the present one

Definition at line 135 of file parameter.cpp.

◆ setCurrentFromDefault()

Parameter & visiontransfer::param::Parameter::setCurrentFromDefault ( )

Copies over the current value from the default value, if specified

Definition at line 167 of file parameter.cpp.

◆ setCvMatFromTensor()

template<typename T >
void visiontransfer::param::Parameter::setCvMatFromTensor ( cv::Mat_< T > &  cvMat)
inline

Sets an OpenCV Mat object of arbitrary base type from a Tensor-type Parameter, which must be two-dimensional.

Definition at line 234 of file parameter.h.

◆ setCvSizeFromTensor()

void visiontransfer::param::Parameter::setCvSizeFromTensor ( cv::Size &  cvSize)
inline

Sets an OpenCV Size object from a Tensor-type Parameter, which must be of shape {2}.

Definition at line 203 of file parameter.h.

◆ setDefault()

template<typename T >
Parameter& visiontransfer::param::Parameter::setDefault ( t)
inline

Sets the default value for the Parameter (Caveat: for scalars only)

Definition at line 312 of file parameter.h.

◆ setDescription()

Parameter& visiontransfer::param::Parameter::setDescription ( const std::string &  d)
inline

Sets the parameter description (explanatory comment string)

Definition at line 256 of file parameter.h.

◆ setGovernor()

Parameter& visiontransfer::param::Parameter::setGovernor ( GovernorType  govType,
const std::string &  govStr 
)
inline

Sets the parameter governor, a script or D-Bus name that controls setting the parameter

Definition at line 142 of file parameter.h.

◆ setIncrement()

template<typename T >
Parameter& visiontransfer::param::Parameter::setIncrement ( t)
inline

Sets the uniform increment (granularity) for the Parameter (only checked for numerical scalars)

Definition at line 339 of file parameter.h.

◆ setInteractionHint()

Parameter& visiontransfer::param::Parameter::setInteractionHint ( ParameterInteractionHint  hint)
inline

Sets the interaction UI hint (invisible / inactive / active)

Definition at line 132 of file parameter.h.

◆ setInvokeGovernorOnInit()

Parameter& visiontransfer::param::Parameter::setInvokeGovernorOnInit ( bool  invoke)
inline

Sets the oninit action (see getInvokeGovernorOnInit).

Definition at line 146 of file parameter.h.

◆ setIsModified()

Parameter& visiontransfer::param::Parameter::setIsModified ( bool  mod)
inline

Sets the runtime-modified flag. This is controlled by the device; changing it has no effect in client-side code.

Definition at line 136 of file parameter.h.

◆ setModuleName()

Parameter& visiontransfer::param::Parameter::setModuleName ( const std::string &  n)
inline

Sets the overarching module name (abstract categorization for GUI etc.)

Definition at line 252 of file parameter.h.

◆ setName()

Parameter& visiontransfer::param::Parameter::setName ( const std::string &  name)
inline

Sets the human-readable name

Definition at line 250 of file parameter.h.

◆ setOptions() [1/2]

template<typename T >
Parameter& visiontransfer::param::Parameter::setOptions ( const std::vector< T > &  opts,
const std::vector< std::string > &  descriptions 
)
inline

Specifies a vector of possible values and a vector of description strings, making the present Parameter an enum-style option list. Use zero-length arguments to remove an enum restriction.

Definition at line 360 of file parameter.h.

◆ setOptions() [2/2]

template<typename T >
Parameter& visiontransfer::param::Parameter::setOptions ( std::initializer_list< T >  opts,
std::initializer_list< std::string >  descriptions 
)
inline

Specifies an initializer_list of possible values and an initializer_list of description strings, making the present Parameter an enum-style option list

Definition at line 374 of file parameter.h.

◆ setRange()

template<typename T >
Parameter& visiontransfer::param::Parameter::setRange ( mn,
mx 
)
inline

Sets the valid value range for the Parameter (only checked for numerical scalars)

Definition at line 320 of file parameter.h.

◆ setTensorData()

Parameter& visiontransfer::param::Parameter::setTensorData ( const std::vector< double > &  data)
inline

Sets the tensor data from a flat representation

Definition at line 175 of file parameter.h.

◆ setTensorDefaultData()

Parameter& visiontransfer::param::Parameter::setTensorDefaultData ( const std::vector< double > &  data)
inline

Sets the fallback tensor data

Definition at line 180 of file parameter.h.

◆ setTensorFromCvMat()

template<typename T >
Parameter& visiontransfer::param::Parameter::setTensorFromCvMat ( const cv::Mat_< T > &  cvMat)
inline

Sets a Tensor-type (or still undefined) Parameter from an OpenCV Mat object, yielding a two-dimensional tensor of identical shape

Definition at line 210 of file parameter.h.

◆ setTensorFromCvSize()

Parameter& visiontransfer::param::Parameter::setTensorFromCvSize ( const cv::Size &  cvSize)
inline

Sets a Tensor-type (or still undefined) Parameter from an OpenCV Size object, yielding a tensor of shape {2}

Definition at line 186 of file parameter.h.

◆ setType()

Parameter& visiontransfer::param::Parameter::setType ( ParameterValue::ParameterType  t)
inline

Sets the type of the parameter values, one of the scalar, tensor, or command types from ParameterValue::ParameterType. Value assignments are subject to type compatibility checks.

Definition at line 260 of file parameter.h.

◆ setUnit()

Parameter& visiontransfer::param::Parameter::setUnit ( const std::string &  d)
inline

Sets the reference unit for the values of the Parameter as a string (e.g. "cm", "µs" etc.)

Definition at line 258 of file parameter.h.

◆ unsetRange()

Parameter& visiontransfer::param::Parameter::unsetRange ( )
inline

Unsets the valid value range for the Parameter; i.e. removes min and max bounds

Definition at line 330 of file parameter.h.


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