OpenMS
Loading...
Searching...
No Matches
FlagSet< ENUM > Class Template Reference

Stores and handles combinations of enum values, e.g. a set of flags as bits flipped in an UInt64. More...

#include <OpenMS/DATASTRUCTURES/FlagSet.h>

Inheritance diagram for FlagSet< ENUM >:
[legend]
Collaboration diagram for FlagSet< ENUM >:
[legend]

Public Member Functions

 FlagSet ()
 Constructors.
 
 FlagSet (const ENUM &en)
 C'tor from Enum.
 
 FlagSet (const FlagSet &stat)=default
 
FlagSetoperator= (const FlagSet &stat)=default
 Assignment.
 
FlagSetoperator= (const ENUM &en)=delete
 no Assignment from Enum (would allow implicit conversion)
 
 ~FlagSet ()=default
 Destructor (default)
 
bool operator== (const FlagSet &stat) const
 Equality.
 
FlagSet operator& (const ENUM &en) const
 bitwise AND
 
FlagSet operator& (const FlagSet &rhs) const
 bitwise AND
 
FlagSetoperator&= (const ENUM &en)
 bitwise AND=
 
FlagSetoperator&= (const FlagSet &rhs)
 bitwise AND=
 
FlagSet operator| (const ENUM &en) const
 bitwise OR
 
FlagSet operator| (const FlagSet &rhs) const
 bitwise OR
 
FlagSetoperator|= (const ENUM &en)
 bitwise OR=
 
FlagSetoperator|= (const FlagSet &rhs)
 bitwise OR=
 
FlagSet operator+ (const ENUM &en) const
 bitwise OR (same as |)
 
FlagSet operator+ (const FlagSet &en) const
 bitwise OR (same as |)
 
FlagSetoperator+= (const ENUM &rhs)
 bitwise OR= (same as |=)
 
FlagSetoperator+= (const FlagSet &rhs)
 bitwise OR= (same as |=)
 
FlagSet operator- (const FlagSet &rhs)
 remove all flags set in rhs from this
 
FlagSetoperator-= (const FlagSet &rhs)
 remove all flags set in rhs from this
 
FlagSet operator- (const ENUM &rhs)
 remove flag in rhs from this
 
FlagSetoperator-= (const ENUM &rhs)
 remove flag in rhs from this
 
bool isSuperSetOf (const FlagSet &required) const
 Check if this FlagSet has at least the active bits of another required FlagSet.
 
bool isSuperSetOf (const ENUM &required) const
 Check if this FlagSet has the bit for required.
 
bool empty () const
 checks if any bit is set
 
UInt64 value () const
 internal representation (mostly for illustrative purposes)
 

Private Member Functions

UInt64 getPow_ (const ENUM &en) const
 computes pow(2, r)
 

Private Attributes

UInt64 value_
 

Detailed Description

template<class ENUM>
class OpenMS::FlagSet< ENUM >

Stores and handles combinations of enum values, e.g. a set of flags as bits flipped in an UInt64.

Conversion from the enum is computed as pow(2, r). Thus make sure that 0 <= 'r' <=63 for all enum values. Multiple enum values can be computed by bitwise 'or' (operator|=)

This class allows assignment and bit operations with itself and an object of type ENUM, i.e. not with any numeric types.

Constructor & Destructor Documentation

◆ FlagSet() [1/3]

template<class ENUM >
FlagSet ( )
inline

Constructors.

Referenced by FlagSet< ENUM >::operator-=().

◆ FlagSet() [2/3]

template<class ENUM >
FlagSet ( const ENUM &  en)
inlineexplicit

C'tor from Enum.

◆ FlagSet() [3/3]

template<class ENUM >
FlagSet ( const FlagSet< ENUM > &  stat)
default

◆ ~FlagSet()

template<class ENUM >
~FlagSet ( )
default

Destructor (default)

Member Function Documentation

◆ empty()

template<class ENUM >
bool empty ( ) const
inline

checks if any bit is set

References FlagSet< ENUM >::value_.

◆ getPow_()

template<class ENUM >
UInt64 getPow_ ( const ENUM &  en) const
inlineprivate

◆ isSuperSetOf() [1/2]

template<class ENUM >
bool isSuperSetOf ( const ENUM &  required) const
inline

Check if this FlagSet has the bit for required.

◆ isSuperSetOf() [2/2]

template<class ENUM >
bool isSuperSetOf ( const FlagSet< ENUM > &  required) const
inline

Check if this FlagSet has at least the active bits of another required FlagSet.

◆ operator&() [1/2]

template<class ENUM >
FlagSet operator& ( const ENUM &  en) const
inline

bitwise AND

◆ operator&() [2/2]

template<class ENUM >
FlagSet operator& ( const FlagSet< ENUM > &  rhs) const
inline

bitwise AND

◆ operator&=() [1/2]

template<class ENUM >
FlagSet & operator&= ( const ENUM &  en)
inline

bitwise AND=

References FlagSet< ENUM >::getPow_(), and FlagSet< ENUM >::value_.

◆ operator&=() [2/2]

template<class ENUM >
FlagSet & operator&= ( const FlagSet< ENUM > &  rhs)
inline

bitwise AND=

References FlagSet< ENUM >::value_.

◆ operator+() [1/2]

template<class ENUM >
FlagSet operator+ ( const ENUM &  en) const
inline

bitwise OR (same as |)

◆ operator+() [2/2]

template<class ENUM >
FlagSet operator+ ( const FlagSet< ENUM > &  en) const
inline

bitwise OR (same as |)

◆ operator+=() [1/2]

template<class ENUM >
FlagSet & operator+= ( const ENUM &  rhs)
inline

bitwise OR= (same as |=)

◆ operator+=() [2/2]

template<class ENUM >
FlagSet & operator+= ( const FlagSet< ENUM > &  rhs)
inline

bitwise OR= (same as |=)

◆ operator-() [1/2]

template<class ENUM >
FlagSet operator- ( const ENUM &  rhs)
inline

remove flag in rhs from this

◆ operator-() [2/2]

template<class ENUM >
FlagSet operator- ( const FlagSet< ENUM > &  rhs)
inline

remove all flags set in rhs from this

◆ operator-=() [1/2]

template<class ENUM >
FlagSet & operator-= ( const ENUM &  rhs)
inline

remove flag in rhs from this

References FlagSet< ENUM >::FlagSet(), and FlagSet< ENUM >::value_.

◆ operator-=() [2/2]

template<class ENUM >
FlagSet & operator-= ( const FlagSet< ENUM > &  rhs)
inline

remove all flags set in rhs from this

References FlagSet< ENUM >::value_.

◆ operator=() [1/2]

template<class ENUM >
FlagSet & operator= ( const ENUM &  en)
delete

no Assignment from Enum (would allow implicit conversion)

◆ operator=() [2/2]

template<class ENUM >
FlagSet & operator= ( const FlagSet< ENUM > &  stat)
default

Assignment.

◆ operator==()

template<class ENUM >
bool operator== ( const FlagSet< ENUM > &  stat) const
inline

Equality.

References FlagSet< ENUM >::value_.

◆ operator|() [1/2]

template<class ENUM >
FlagSet operator| ( const ENUM &  en) const
inline

◆ operator|() [2/2]

template<class ENUM >
FlagSet operator| ( const FlagSet< ENUM > &  rhs) const
inline

bitwise OR

References FlagSet< ENUM >::value_.

◆ operator|=() [1/2]

template<class ENUM >
FlagSet & operator|= ( const ENUM &  en)
inline

◆ operator|=() [2/2]

template<class ENUM >
FlagSet & operator|= ( const FlagSet< ENUM > &  rhs)
inline

bitwise OR=

References FlagSet< ENUM >::value_.

◆ value()

template<class ENUM >
UInt64 value ( ) const
inline

internal representation (mostly for illustrative purposes)

References FlagSet< ENUM >::value_.

Member Data Documentation

◆ value_