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

Private Member Functions

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

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]

FlagSet ( )
inline

Constructors.

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

◆ FlagSet() [2/3]

FlagSet ( const ENUM &  en)
inlineexplicit

C'tor from Enum.

◆ FlagSet() [3/3]

FlagSet ( const FlagSet< ENUM > &  stat)
default

◆ ~FlagSet()

~FlagSet ( )
default

Destructor (default)

Member Function Documentation

◆ empty()

bool empty ( ) const
inline

checks if any bit is set

References FlagSet< ENUM >::value_.

◆ getPow_()

UInt64 getPow_ ( const ENUM &  en) const
inlineprivate

◆ isSuperSetOf() [1/2]

bool isSuperSetOf ( const ENUM &  required) const
inline

Check if this FlagSet has the bit for required.

◆ isSuperSetOf() [2/2]

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]

FlagSet operator& ( const ENUM &  en) const
inline

bitwise AND

◆ operator&() [2/2]

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

bitwise AND

◆ operator&=() [1/2]

FlagSet& operator&= ( const ENUM &  en)
inline

bitwise AND=

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

◆ operator&=() [2/2]

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

bitwise AND=

References FlagSet< ENUM >::value_.

◆ operator+() [1/2]

FlagSet operator+ ( const ENUM &  en) const
inline

bitwise OR (same as |)

◆ operator+() [2/2]

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

bitwise OR (same as |)

◆ operator+=() [1/2]

FlagSet& operator+= ( const ENUM &  rhs)
inline

bitwise OR= (same as |=)

◆ operator+=() [2/2]

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

bitwise OR= (same as |=)

◆ operator-() [1/2]

FlagSet operator- ( const ENUM &  rhs)
inline

remove flag in rhs from this

◆ operator-() [2/2]

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

remove all flags set in rhs from this

◆ operator-=() [1/2]

FlagSet& operator-= ( const ENUM &  rhs)
inline

remove flag in rhs from this

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

◆ operator-=() [2/2]

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

remove all flags set in rhs from this

References FlagSet< ENUM >::value_.

◆ operator=() [1/2]

FlagSet& operator= ( const ENUM &  en)
delete

no Assignment from Enum (would allow implicit conversion)

◆ operator=() [2/2]

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

Assignment.

◆ operator==()

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

Equality.

References FlagSet< ENUM >::value_.

◆ operator|() [1/2]

FlagSet operator| ( const ENUM &  en) const
inline

◆ operator|() [2/2]

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

bitwise OR

References FlagSet< ENUM >::value_.

◆ operator|=() [1/2]

FlagSet& operator|= ( const ENUM &  en)
inline

◆ operator|=() [2/2]

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

bitwise OR=

References FlagSet< ENUM >::value_.

◆ value()

UInt64 value ( ) const
inline

internal representation (mostly for illustrative purposes)

References FlagSet< ENUM >::value_.

Member Data Documentation

◆ value_

UInt64 value_
private