libcamera: libcamera::Flags< E > Class Template Reference

libcamera v0.5.1 Supporting cameras in Linux since 2019 |

Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
libcamera::Flags< E > Class Template Reference

Type-safe container for enum-based bitfields. More...

## Public Types
using | Type = std::underlying_type_t<E>
| The underlying data type of the enum.

## Public Member Functions
constexpr | Flags ()
| Construct a Flags instance with a zero value.
constexpr | Flags (E flag)
| Construct a Flags instance storing the flag.
constexpr Flags & | operator&= (E flag)
| Store the bitwise AND of this Flags and the flag in this Flags.
constexpr Flags & | operator&= (Flags other)
| Store the bitwise AND of this Flags and the other Flags in this Flags.
constexpr Flags & | operator|= (E flag)
| Store the bitwise OR of this Flags and the flag in this Flags.
constexpr Flags & | operator|= (Flags other)
| Store the bitwise OR of this Flags and the other Flags in this Flags.
constexpr Flags & | operator^= (E flag)
| Store the bitwise XOR of this Flags and the flag in this Flags.
constexpr Flags & | operator^= (Flags other)
| Store the bitwise XOR of this Flags and the other Flags in this Flags.
constexpr bool | operator== (E flag)
| Compare flags for equality.
constexpr bool | operator== (Flags other)
| Compare flags for equality.
constexpr bool | operator!= (E flag)
| Compare flags for non-equality.
constexpr bool | operator!= (Flags other)
| Compare flags for non-equality.
constexpr | operator Type () const
| Convert the Flags to the underlying integer type.
constexpr | operator bool () const
| Convert the Flags to a boolean.
constexpr Flags | operator& (E flag) const
| Compute the bitwise AND of this Flags and the flag.
constexpr Flags | operator& (Flags other) const
| Compute the bitwise AND of this Flags and the other Flags.
constexpr Flags | operator| (E flag) const
| Compute the bitwise OR of this Flags and the flag.
constexpr Flags | operator| (Flags other) const
| Compute the bitwise OR of this Flags and the other Flags.
constexpr Flags | operator^ (E flag) const
| Compute the bitwise XOR of this Flags and the flag.
constexpr Flags | operator^ (Flags other) const
| Compute the bitwise XOR of this Flags and the other Flags.
constexpr Flags | operator~ () const
| Compute the bitwise NOT of this Flags.
constexpr bool | operator! () const
| Check if flags are set.

## Detailed Description

template<typename E>
class libcamera::Flags< E >

Type-safe container for enum-based bitfields.

The Flags template class provides type-safe bitwise operators on enum values. It allows using enum types for bitfields, while preventing unsafe casts from integer types and mixing of flags from different enum types.

To use the Flags class, declare an enum containing the desired bit flags, and use the Flags<enum> class to store bitfields based on the enum. If bitwise operators on the underlying enum are also desired, they can be enabled with the LIBCAMERA_FLAGS_ENABLE_OPERATORS(enum) macro.

## Constructor & Destructor Documentation

## ◆ Flags()

template<typename E>

libcamera::Flags< E >::Flags | ( | E | flag | ) |
| inlineconstexpr

Construct a Flags instance storing the flag.

Parameters

  [in] | flag | The initial value

## Member Function Documentation

## ◆ operator bool()

template<typename E>

libcamera::Flags< E >::operator bool | ( |  | ) | const
| inlineexplicitconstexpr

Convert the Flags to a boolean.

Returns
  True if at least one flag is set, false otherwise

## ◆ operator Type()

template<typename E>

libcamera::Flags< E >::operator Type | ( |  | ) | const
| inlineexplicitconstexpr

Convert the Flags to the underlying integer type.

Returns
  The Flags value as an integer

## ◆ operator!()

template<typename E>

bool libcamera::Flags< E >::operator! | ( |  | ) | const
| inlineconstexpr

Check if flags are set.

Returns
  True if no flags is set, false otherwise

## ◆ operator!=() [1/2]

template<typename E>

bool libcamera::Flags< E >::operator!= | ( | E | flag | ) |
| inlineconstexpr

Compare flags for non-equality.

Parameters

  [in] | flag | The second operand

Returns
  True if the Flags and flag are not equal, false otherwise

## ◆ operator!=() [2/2]

template<typename E>

bool libcamera::Flags< E >::operator!= | ( | Flags< E > | other | ) |
| inlineconstexpr

Compare flags for non-equality.

Parameters

  [in] | other | The second operand

Returns
  True if the Flags and other are not equal, false otherwise

## ◆ operator&() [1/2]

template<typename E>

Flags libcamera::Flags< E >::operator& | ( | E | flag | ) | const
| inlineconstexpr

Compute the bitwise AND of this Flags and the flag.

Parameters

  [in] | flag | The second operand

Returns
  A Flags containing the result of the AND operation

## ◆ operator&() [2/2]

template<typename E>

Flags libcamera::Flags< E >::operator& | ( | Flags< E > | other | ) | const
| inlineconstexpr

Compute the bitwise AND of this Flags and the other Flags.

Parameters

  [in] | other | The second operand

Returns
  A Flags containing the result of the AND operation

## ◆ operator&=() [1/2]

template<typename E>

Flags & libcamera::Flags< E >::operator&= | ( | E | flag | ) |
| inlineconstexpr

Store the bitwise AND of this Flags and the flag in this Flags.

Parameters

  [in] | flag | The second operand

Returns
  A reference to this Flags

## ◆ operator&=() [2/2]

template<typename E>

Flags & libcamera::Flags< E >::operator&= | ( | Flags< E > | other | ) |
| inlineconstexpr

Store the bitwise AND of this Flags and the other Flags in this Flags.

Parameters

  [in] | other | The second operand

Returns
  A reference to this Flags

## ◆ operator==() [1/2]

template<typename E>

bool libcamera::Flags< E >::operator== | ( | E | flag | ) |
| inlineconstexpr

Compare flags for equality.

Parameters

  [in] | flag | The second operand

Returns
  True if the Flags and flag are equal, false otherwise

## ◆ operator==() [2/2]

template<typename E>

bool libcamera::Flags< E >::operator== | ( | Flags< E > | other | ) |
| inlineconstexpr

Compare flags for equality.

Parameters

  [in] | other | The second operand

Returns
  True if the Flags and other are equal, false otherwise

## ◆ operator^() [1/2]

template<typename E>

Flags libcamera::Flags< E >::operator^ | ( | E | flag | ) | const
| inlineconstexpr

Compute the bitwise XOR of this Flags and the flag.

Parameters

  [in] | flag | The second operand

Returns
  A Flags containing the result of the XOR operation

## ◆ operator^() [2/2]

template<typename E>

Flags libcamera::Flags< E >::operator^ | ( | Flags< E > | other | ) | const
| inlineconstexpr

Compute the bitwise XOR of this Flags and the other Flags.

Parameters

  [in] | other | The second operand

Returns
  A Flags containing the result of the XOR operation

## ◆ operator^=() [1/2]

template<typename E>

Flags & libcamera::Flags< E >::operator^= | ( | E | flag | ) |
| inlineconstexpr

Store the bitwise XOR of this Flags and the flag in this Flags.

Parameters

  [in] | flag | The second operand

Returns
  A reference to this Flags

## ◆ operator^=() [2/2]

template<typename E>

Flags & libcamera::Flags< E >::operator^= | ( | Flags< E > | other | ) |
| inlineconstexpr

Store the bitwise XOR of this Flags and the other Flags in this Flags.

Parameters

  [in] | other | The second operand

Returns
  A reference to this Flags

## ◆ operator|() [1/2]

template<typename E>

Flags libcamera::Flags< E >::operator| | ( | E | flag | ) | const
| inlineconstexpr

Compute the bitwise OR of this Flags and the flag.

Parameters

  [in] | flag | The second operand

Returns
  A Flags containing the result of the OR operation

## ◆ operator|() [2/2]

template<typename E>

Flags libcamera::Flags< E >::operator| | ( | Flags< E > | other | ) | const
| inlineconstexpr

Compute the bitwise OR of this Flags and the other Flags.

Parameters

  [in] | other | The second operand

Returns
  A Flags containing the result of the OR operation

## ◆ operator|=() [1/2]

template<typename E>

Flags & libcamera::Flags< E >::operator|= | ( | E | flag | ) |
| inlineconstexpr

Store the bitwise OR of this Flags and the flag in this Flags.

Parameters

  [in] | flag | The second operand

Returns
  A reference to this Flags

## ◆ operator|=() [2/2]

template<typename E>

Flags & libcamera::Flags< E >::operator|= | ( | Flags< E > | other | ) |
| inlineconstexpr

Store the bitwise OR of this Flags and the other Flags in this Flags.

Parameters

  [in] | other | The second operand

Returns
  A reference to this Flags

## ◆ operator~()

template<typename E>

Flags libcamera::Flags< E >::operator~ | ( |  | ) | const
| inlineconstexpr

Compute the bitwise NOT of this Flags.

Returns
  A Flags containing the result of the NOT operation

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

- include/libcamera/base/flags.h
- src/libcamera/base/flags.cpp