libcamera  v0.4.0
Supporting cameras in Linux since 2019
Public Member Functions | List of all members
libcamera::ControlValue Class Reference

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...
 
ControlValueoperator= (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 >
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...
 

Detailed Description

Abstract type representing the value of a control.

Constructor & Destructor Documentation

◆ ControlValue() [1/3]

libcamera::ControlValue::ControlValue ( )

Construct an empty ControlValue.

Todo:
Revisit the ControlValue layout when stabilizing the ABI

◆ ControlValue() [2/3]

template<typename T >
template< typename T > T libcamera::ControlValue::ControlValue ( const T &  value)
inline

Construct a ControlValue of type T.

Parameters
[in]valueInitial 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.

◆ ControlValue() [3/3]

libcamera::ControlValue::ControlValue ( const ControlValue other)

Construct a ControlValue with the content of other.

Parameters
[in]otherThe ControlValue to copy content from

Member Function Documentation

◆ data() [1/2]

Span< const uint8_t > libcamera::ControlValue::data ( ) const

Retrieve the raw data of a control value.

Returns
The raw data of the control value as a span of uint8_t

◆ data() [2/2]

Span< uint8_t > libcamera::ControlValue::data ( )

Retrieve the raw data of a control value.

Returns
The raw data of the control value as a span of uint8_t

◆ get()

template<typename T >
template< typename T > T libcamera::ControlValue::get ( ) const
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().

Returns
The control value

◆ isArray()

libcamera::ControlValue::isArray ( ) const
inline

Determine if the value stores an array.

Returns
True if the value stores an array, false otherwise

◆ isNone()

libcamera::ControlValue::isNone ( ) const
inline

Determine if the value is not initialised.

Returns
True if the value type is ControlTypeNone, false otherwise

◆ numElements()

libcamera::ControlValue::numElements ( ) const
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.

Returns
The number of elements stored in the ControlValue

◆ operator!=()

bool libcamera::ControlValue::operator!= ( const ControlValue other) const
inline

Compare ControlValue instances for non equality.

Returns
False if the values have identical types and values, true otherwise

◆ operator=()

ControlValue & libcamera::ControlValue::operator= ( const ControlValue other)

Replace the content of the ControlValue with a copy of the content of other.

Parameters
[in]otherThe ControlValue to copy content from
Returns
The ControlValue with its content replaced with the one of other

◆ operator==()

bool libcamera::ControlValue::operator== ( const ControlValue other) const

Compare ControlValue instances for equality.

Returns
True if the values have identical types and values, false otherwise

◆ reserve()

void libcamera::ControlValue::reserve ( ControlType  type,
bool  isArray = false,
std::size_t  numElements = 1 
)

Set the control type and reserve memory.

Parameters
[in]typeThe control type
[in]isArrayTrue to make the value an array
[in]numElementsThe 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.

◆ set()

template<typename T >
template< typename T > void libcamera::ControlValue::set ( const T &  value)
inline

Set the control value to value.

Parameters
[in]valueThe 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.

◆ toString()

std::string libcamera::ControlValue::toString ( ) const

Assemble and return a string describing the value.

Returns
A string describing the ControlValue

◆ type()

libcamera::ControlValue::type ( ) const
inline

Retrieve the data type of the value.

Returns
The value data type

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