L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
L4::Types::Flags< BITS_ENUM, UNDERLYING > Class Template Reference

Template for defining typical Flags bitmaps. More...

#include <types>

+ 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).
 
typeoperator|= (type rhs)
 Support |= of two compatible Flags types.
 
typeoperator|= (bits_enum_type rhs)
 Support |= of Flags type and bit name.
 
typeoperator&= (type rhs)
 Support &= of two compatible Flags types.
 
typeoperator&= (bits_enum_type rhs)
 Support &= of Flags type and bit name.
 
type operator~ () const
 Support ~ for Flags types.
 
typeclear (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_ENUMenum 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).
UNDERLYINGThe 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) { ... }
Template for defining typical Flags bitmaps.
Definition types:64

Definition at line 63 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 79 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.

@ None
Use this to get an empty bitmap.
Definition types:79

Definition at line 89 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 102 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
flagThe flag that shall be cleared.

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

Definition at line 153 of file types.

References L4::Types::Flags< BITS_ENUM, UNDERLYING >::operator&=().

+ Here is the call graph for this function:

◆ from_raw()

template<typename BITS_ENUM , typename UNDERLYING = unsigned long>
static 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 109 of file types.


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