Loading...
Searching...
No Matches
L4::Types::Flags< BITS_ENUM, UNDERLYING > Class Template Reference

Template for defining typical Flags bitmaps. More...

`#include <types>`

Inheritance diagram for L4::Types::Flags< BITS_ENUM, UNDERLYING >:
Collaboration diagram for L4::Types::Flags< BITS_ENUM, UNDERLYING >:

## Public Types

enum | None_type { None }
| The none type to get an empty bitmap. More...
typedef UNDERLYING | value_type
| type of the underlying value
typedef BITS_ENUM | bits_enum_type
| enum type defining a name for each bit
typedef Flags< BITS_ENUM, UNDERLYING > | type
| the Flags<> type itself

## Public Member Functions

| Flags (None_type)
| Make an empty bitmap.
| Flags ()
| Make default Flags.
| Flags (BITS_ENUM e)
| Make flags from bit name.
| operator bool () const
| Support for if (flags) syntax (test for non-empty flags).
bool | operator! () const
| Support for if (!flags) syntax (test for empty flags).
type & | operator|= (type rhs)
| Support |= of two compatible Flags types.
type & | operator|= (bits_enum_type rhs)
| Support |= of Flags type and bit name.
type & | operator&= (type rhs)
| Support &= of two compatible Flags types.
type & | operator&= (bits_enum_type rhs)
| Support &= of Flags type and bit name.
type | operator~ () const
| Support ~ for Flags types.
type & | clear (bits_enum_type flag)
| Clear the given flag.
value_type | as_value () const
| Get the underlying value.

## Static Public Member Functions

static type | from_raw (value_type v)
| Make flags from a raw value of value_type.

## Friends

type | operator| (type lhs, type rhs)
| Support | of two compatible Flags types.
type | operator| (type lhs, bits_enum_type rhs)
| Support | of Flags type and bit name.
type | operator& (type lhs, type rhs)
| Support & of two compatible Flags types.
type | operator& (type lhs, bits_enum_type rhs)
| Support & of Flags type and bit name.

## Detailed Description

template<typename BITS_ENUM, typename UNDERLYING = unsigned long>
class L4::Types::Flags< BITS_ENUM, UNDERLYING >

Template for defining typical Flags bitmaps.

Template Parameters

  BITS_ENUM | enum type that defines a name for each bit in the bitmap. The values of the enum members must be the number of the bit (not a mask).
  UNDERLYING | The underlying data type used to represent the bitmap.

The resulting data type provides a type-safe version that allows bitwise and and or operations with the BITS_ENUM members. As well as, test for 0or !0.

Example:

enum Test_flag
{
Do_weak_tests,
Do_strong_tests
};
typedef L4::Types::Flags<Test_flag> Test_flags;
Test_flags x = Do_weak_tests;
if (x & Do_strong_tests) { ... }
x |= Do_strong_tests;
if (x & Do_strong_tests) { ... }
L4::Types::Flags
Template for defining typical Flags bitmaps.
Definition types:53

Definition at line 52 of file types.

## Member Enumeration Documentation

## None_type

template<typename BITS_ENUM, typename UNDERLYING = unsigned long>

enum L4::Types::Flags::None_type

The none type to get an empty bitmap.

Enumerator
None | Use this to get an empty bitmap.

Definition at line 68 of file types.

## Constructor & Destructor Documentation

## Flags() [1/2]

template<typename BITS_ENUM, typename UNDERLYING = unsigned long>

L4::Types::Flags< BITS_ENUM, UNDERLYING >::Flags | ( | None_type |  | ) |

inline

Make an empty bitmap.

Usually used for implicit conversion from Flags::None.

Flags x = Flags::None;
L4::Types::Flags::None
@ None
Use this to get an empty bitmap.
Definition types:68

Definition at line 78 of file types.

## Flags() [2/2]

template<typename BITS_ENUM, typename UNDERLYING = unsigned long>

L4::Types::Flags< BITS_ENUM, UNDERLYING >::Flags | ( | BITS_ENUM | e | ) |

inline

Make flags from bit name.

Usually used for implicit conversion for a bit name.

Test_flags f = Do_strong_tests;

Definition at line 91 of file types.

## Member Function Documentation

## clear()

template<typename BITS_ENUM, typename UNDERLYING = unsigned long>

type & L4::Types::Flags< BITS_ENUM, UNDERLYING >::clear | ( | bits_enum_type | flag | ) |

inline

Clear the given flag.

Parameters

  flag | The flag that shall be cleared.

flags.clear(The_flag) is a shortcut for flags &= ~Flags(The_flag).

Definition at line 142 of file types.

## from_raw()

template<typename BITS_ENUM, typename UNDERLYING = unsigned long>

type L4::Types::Flags< BITS_ENUM, UNDERLYING >::from_raw | ( | value_type | v | ) |

inlinestatic

Make flags from a raw value of value_type.

This function may be used for example in C wrapper code.

Definition at line 98 of file types.

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

- l4/sys/cxx/types