libcamera: libcamera::ControlValue Class Reference

libcamera v0.7.0 Supporting cameras in Linux since 2019

Loading...
Searching...
No Matches
libcamera::ControlValue Class Reference

Abstract type representing the value of a control. More...

## Public Member Functions
| ControlValue ()
| Construct an empty ControlValue.
template<typename T>
| ControlValue (const T &value)
| Construct a ControlValue of type T.
| ControlValue (const ControlValue &other)
| Construct a ControlValue with the content of other.
ControlValue & | operator= (const ControlValue &other)
| Replace the content of the ControlValue with a copy of the content of other.
ControlType | type () const
| Retrieve the data type of the value.
bool | isNone () const
| Determine if the value is not initialised.
bool | isArray () const
| Determine if the value stores an array.
std::size_t | numElements () const
| Retrieve the number of elements stored in the ControlValue.
Span< const uint8_t > | data () const
| Retrieve the raw data of a control value.
Span< uint8_t > | data ()
| Retrieve the raw data of a control value.
std::string | toString () const
| Assemble and return a string describing the value.
bool | operator== (const ControlValue &other) const
| Compare ControlValue instances for equality.
bool | operator!= (const ControlValue &other) const
| Compare ControlValue instances for non equality.
template<typename T>
T | get () const
| Get the control value.
template<typename T>
void | set (const T &value)
| Set the control value to value.
void | reserve (ControlType type, bool isArray=false, std::size_t numElements=1)
| Set the control type and reserve memory.

## 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>

libcamera::ControlValue::ControlValue | ( | const T & | value | ) |
| inline

Construct a ControlValue of type T.

Parameters

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

## ◆ ControlValue() [3/3]

libcamera::ControlValue::ControlValue | ( | const ControlValue & | other | ) |

Construct a ControlValue with the content of other.

Parameters

  [in] | other | The ControlValue to copy content from

## Member Function Documentation

## ◆ data() [1/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

## ◆ data() [2/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

## ◆ get()

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()

bool libcamera::ControlValue::isArray | ( |  | ) | const
| inline

Determine if the value stores an array.

Returns
  True if the value stores an array, false otherwise

## ◆ isNone()

bool libcamera::ControlValue::isNone | ( |  | ) | const
| inline

Determine if the value is not initialised.

Returns
  True if the value type is ControlTypeNone, false otherwise

## ◆ numElements()

std::size_t 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] | other | The 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] | 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.

## ◆ set()

template<typename T>

void libcamera::ControlValue::set | ( | const T & | value | ) |
| inline

Set the control value to value.

Parameters

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

## ◆ toString()

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

Assemble and return a string describing the value.

Returns
  A string describing the ControlValue

## ◆ type()

ControlType 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:

- include/libcamera/controls.h
- src/libcamera/controls.cpp