libcamera
v0.4.0
Supporting cameras in Linux since 2019
|
Abstract type representing the value of a control. More...
Public Member Functions | |
ControlValue () | |
Construct an empty ControlValue. More... | |
template<typename T > | |
ControlValue (const T &value) | |
Construct a ControlValue of type T. More... | |
ControlValue (const ControlValue &other) | |
Construct a ControlValue with the content of other. More... | |
ControlValue & | operator= (const ControlValue &other) |
Replace the content of the ControlValue with a copy of the content of other. More... | |
ControlType | type () const |
Retrieve the data type of the value. More... | |
bool | isNone () const |
Determine if the value is not initialised. More... | |
bool | isArray () const |
Determine if the value stores an array. More... | |
std::size_t | numElements () const |
Retrieve the number of elements stored in the ControlValue. More... | |
Span< const uint8_t > | data () const |
Retrieve the raw data of a control value. More... | |
Span< uint8_t > | data () |
Retrieve the raw data of a control value. More... | |
std::string | toString () const |
Assemble and return a string describing the value. More... | |
bool | operator== (const ControlValue &other) const |
Compare ControlValue instances for equality. More... | |
bool | operator!= (const ControlValue &other) const |
Compare ControlValue instances for non equality. More... | |
template<typename T > | |
T | get () const |
Get the control value. More... | |
template<typename T > | |
void | set (const T &value) |
Set the control value to value. More... | |
void | reserve (ControlType type, bool isArray=false, std::size_t numElements=1) |
Set the control type and reserve memory. More... | |
Abstract type representing the value of a control.
libcamera::ControlValue::ControlValue | ( | ) |
Construct an empty ControlValue.
|
inline |
Construct a ControlValue of type T.
[in] | value | Initial value |
This function constructs a new instance of ControlValue and stores the value inside it. If the type T is equivalent to Span<R>, the instance stores an array of values of type R. Otherwise the instance stores a single value of type T. The numElements() and type() are updated to reflect the stored value.
libcamera::ControlValue::ControlValue | ( | const ControlValue & | other | ) |
Construct a ControlValue with the content of other.
[in] | other | The ControlValue to copy content from |
Span< const uint8_t > libcamera::ControlValue::data | ( | ) | const |
Retrieve the raw data of a control value.
Span< uint8_t > libcamera::ControlValue::data | ( | ) |
Retrieve the raw data of a control value.
|
inline |
Get the control value.
This function returns the contained value as an instance of T. If the ControlValue instance stores a single value, the type T shall match the stored value type(). If the instance stores an array of values, the type T should be equal to Span<const R>, and the type R shall match the stored value type(). The behaviour is undefined otherwise.
Note that a ControlValue instance that stores a non-array value is not equivalent to an instance that stores an array value containing a single element. The latter shall be accessed through a Span<const R> type, while the former shall be accessed through a type T corresponding to type().
|
inline |
Determine if the value stores an array.
|
inline |
Determine if the value is not initialised.
|
inline |
Retrieve the number of elements stored in the ControlValue.
For instances storing an array, this function returns the number of elements in the array. For instances storing a string, it returns the length of the string, not counting the terminating '\0'. Otherwise, it returns 1.
|
inline |
Compare ControlValue instances for non equality.
ControlValue & libcamera::ControlValue::operator= | ( | const ControlValue & | other | ) |
Replace the content of the ControlValue with a copy of the content of other.
[in] | other | The ControlValue to copy content from |
bool libcamera::ControlValue::operator== | ( | const ControlValue & | other | ) | const |
Compare ControlValue instances for equality.
void libcamera::ControlValue::reserve | ( | ControlType | type, |
bool | isArray = false , |
||
std::size_t | numElements = 1 |
||
) |
Set the control type and reserve memory.
[in] | type | The control type |
[in] | isArray | True to make the value an array |
[in] | numElements | The number of elements |
This function sets the type of the control value to type, and reserves memory to store the control value. If isArray is true, the instance becomes an array control and storage for numElements is reserved. Otherwise the instance becomes a simple control, numElements is ignored, and storage for the single element is reserved.
|
inline |
Set the control value to value.
[in] | value | The control value |
This function stores the value in the instance. If the type T is equivalent to Span<R>, the instance stores an array of values of type R. Otherwise the instance stores a single value of type T. The numElements() and type() are updated to reflect the stored value.
The entire content of value is copied to the instance, no reference to value or to the data it references is retained. This may be an expensive operation for Span<> values that refer to large arrays.
std::string libcamera::ControlValue::toString | ( | ) | const |
Assemble and return a string describing the value.
|
inline |
Retrieve the data type of the value.