libcamera  v0.3.2+116-83c5ad0f
Supporting cameras in Linux since 2019
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. More...
 
constexpr Flagsoperator &= (E flag)
 
constexpr Flagsoperator &= (Flags other)
 
constexpr Flagsoperator|= (E flag)
 Store the bitwise OR of this Flags and the flag in this Flags. More...
 
constexpr Flagsoperator|= (Flags other)
 Store the bitwise OR of this Flags and the other Flags in this Flags. More...
 
constexpr Flagsoperator^= (E flag)
 Store the bitwise XOR of this Flags and the flag in this Flags. More...
 
constexpr Flagsoperator^= (Flags other)
 Store the bitwise XOR of this Flags and the other Flags in this Flags. More...
 
constexpr bool operator== (E flag)
 Compare flags for equality. More...
 
constexpr bool operator== (Flags other)
 Compare flags for equality. More...
 
constexpr bool operator!= (E flag)
 Compare flags for non-equality. More...
 
constexpr bool operator!= (Flags other)
 Compare flags for non-equality. More...
 
constexpr operator Type () const
 Convert the Flags to the underlying integer type. More...
 
constexpr operator bool () const
 Convert the Flags to a boolean. More...
 
constexpr Flags operator & (E flag) const
 
constexpr Flags operator & (Flags other) const
 
constexpr Flags operator| (E flag) const
 Compute the bitwise OR of this Flags and the flag. More...
 
constexpr Flags operator| (Flags other) const
 Compute the bitwise OR of this Flags and the other Flags. More...
 
constexpr Flags operator^ (E flag) const
 Compute the bitwise XOR of this Flags and the flag. More...
 
constexpr Flags operator^ (Flags other) const
 Compute the bitwise XOR of this Flags and the other Flags. More...
 
constexpr Flags operator~ () const
 Compute the bitwise NOT of this Flags. More...
 
constexpr bool operator! () const
 Check if flags are set. More...
 

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

Construct a Flags instance storing the flag.

Parameters
[in]flagThe initial value

Member Function Documentation

◆ operator bool()

template<typename E>
libcamera::Flags< E >::operator bool ( ) const
inlineexplicit

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
inlineexplicit

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
inline

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!= ( flag)
inline

Compare flags for non-equality.

Parameters
[in]flagThe 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)
inline

Compare flags for non-equality.

Parameters
[in]otherThe second operand
Returns
True if the Flags and other are not equal, false otherwise

◆ operator==() [1/2]

template<typename E>
bool libcamera::Flags< E >::operator== ( flag)
inline

Compare flags for equality.

Parameters
[in]flagThe 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)
inline

Compare flags for equality.

Parameters
[in]otherThe second operand
Returns
True if the Flags and other are equal, false otherwise

◆ operator^() [1/2]

template<typename E>
Flags libcamera::Flags< E >::operator^ ( flag) const
inline

Compute the bitwise XOR of this Flags and the flag.

Parameters
[in]flagThe 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
inline

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

Parameters
[in]otherThe second operand
Returns
A Flags containing the result of the XOR operation

◆ operator^=() [1/2]

template<typename E>
Flags & libcamera::Flags< E >::operator^= ( flag)
inline

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

Parameters
[in]flagThe second operand
Returns
A reference to this Flags

◆ operator^=() [2/2]

template<typename E>
Flags & libcamera::Flags< E >::operator^= ( Flags< E >  other)
inline

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

Parameters
[in]otherThe second operand
Returns
A reference to this Flags

◆ operator|() [1/2]

template<typename E>
Flags libcamera::Flags< E >::operator| ( flag) const
inline

Compute the bitwise OR of this Flags and the flag.

Parameters
[in]flagThe 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
inline

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

Parameters
[in]otherThe second operand
Returns
A Flags containing the result of the OR operation

◆ operator|=() [1/2]

template<typename E>
Flags & libcamera::Flags< E >::operator|= ( flag)
inline

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

Parameters
[in]flagThe second operand
Returns
A reference to this Flags

◆ operator|=() [2/2]

template<typename E>
Flags & libcamera::Flags< E >::operator|= ( Flags< E >  other)
inline

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

Parameters
[in]otherThe second operand
Returns
A reference to this Flags

◆ operator~()

template<typename E>
Flags libcamera::Flags< E >::operator~ ( ) const
inline

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: