ug4
ug::Flag< TEnum, TStorageType, defaultValue > Class Template Reference

Helps maintaining, activating and deactivating a set of flags from an enum. More...

#include <flags.h>

Public Member Functions

Flagadd (TStorageType flag)
 
bool contains (const Flag &flag) const
 
bool contains (TStorageType flag) const
 
 Flag ()
 
 Flag (const Flag &flag)
 
 Flag (TStorageType flag)
 
TStorageType get () const
 
bool operator!= (const Flag &flag) const
 
bool operator!= (TStorageType val) const
 
Flag operator& (const Flag &flag) const
 
Flag operator&= (const Flag &flag)
 
TStorageType operator() () const
 
Flag operator= (const Flag &flag)
 
Flag operator= (TStorageType val)
 
bool operator== (const Flag &flag) const
 
bool operator== (TStorageType val) const
 
Flag operator| (const Flag &flag) const
 
Flag operator|= (const Flag &flag)
 
bool partially_contains (const Flag &flag) const
 
bool partially_contains (TStorageType flag) const
 
Flagremove (TStorageType flag)
 
Flagset (TStorageType flag)
 

Private Attributes

TStorageType m_value
 

Detailed Description

template<class TEnum, class TStorageType = unsigned int, TStorageType defaultValue = 0>
class ug::Flag< TEnum, TStorageType, defaultValue >

Helps maintaining, activating and deactivating a set of flags from an enum.

Given an enum

enum SomeEnum{
E1 = 0,
E2 = 1,
E3 = 1 << 1,
E4 = 1 << 2
};

One can use the Flag class as follows:

typedef Flag<SomeEnum> SomeFlag;
...
SomeFlag f1(E2), f2(E4);
SomeFlag f3(f1 | f2);
if(f3.contains(E2))
f3.remove(E2);
...

Constructor & Destructor Documentation

◆ Flag() [1/3]

template<class TEnum , class TStorageType = unsigned int, TStorageType defaultValue = 0>
ug::Flag< TEnum, TStorageType, defaultValue >::Flag ( )
inline

◆ Flag() [2/3]

template<class TEnum , class TStorageType = unsigned int, TStorageType defaultValue = 0>
ug::Flag< TEnum, TStorageType, defaultValue >::Flag ( TStorageType  flag)
inline

◆ Flag() [3/3]

template<class TEnum , class TStorageType = unsigned int, TStorageType defaultValue = 0>
ug::Flag< TEnum, TStorageType, defaultValue >::Flag ( const Flag< TEnum, TStorageType, defaultValue > &  flag)
inline

Member Function Documentation

◆ add()

template<class TEnum , class TStorageType = unsigned int, TStorageType defaultValue = 0>
Flag& ug::Flag< TEnum, TStorageType, defaultValue >::add ( TStorageType  flag)
inline

◆ contains() [1/2]

template<class TEnum , class TStorageType = unsigned int, TStorageType defaultValue = 0>
bool ug::Flag< TEnum, TStorageType, defaultValue >::contains ( const Flag< TEnum, TStorageType, defaultValue > &  flag) const
inline

◆ contains() [2/2]

template<class TEnum , class TStorageType = unsigned int, TStorageType defaultValue = 0>
bool ug::Flag< TEnum, TStorageType, defaultValue >::contains ( TStorageType  flag) const
inline

◆ get()

template<class TEnum , class TStorageType = unsigned int, TStorageType defaultValue = 0>
TStorageType ug::Flag< TEnum, TStorageType, defaultValue >::get ( ) const
inline

◆ operator!=() [1/2]

template<class TEnum , class TStorageType = unsigned int, TStorageType defaultValue = 0>
bool ug::Flag< TEnum, TStorageType, defaultValue >::operator!= ( const Flag< TEnum, TStorageType, defaultValue > &  flag) const
inline

◆ operator!=() [2/2]

template<class TEnum , class TStorageType = unsigned int, TStorageType defaultValue = 0>
bool ug::Flag< TEnum, TStorageType, defaultValue >::operator!= ( TStorageType  val) const
inline

◆ operator&()

template<class TEnum , class TStorageType = unsigned int, TStorageType defaultValue = 0>
Flag ug::Flag< TEnum, TStorageType, defaultValue >::operator& ( const Flag< TEnum, TStorageType, defaultValue > &  flag) const
inline

◆ operator&=()

template<class TEnum , class TStorageType = unsigned int, TStorageType defaultValue = 0>
Flag ug::Flag< TEnum, TStorageType, defaultValue >::operator&= ( const Flag< TEnum, TStorageType, defaultValue > &  flag)
inline

◆ operator()()

template<class TEnum , class TStorageType = unsigned int, TStorageType defaultValue = 0>
TStorageType ug::Flag< TEnum, TStorageType, defaultValue >::operator() ( ) const
inline

◆ operator=() [1/2]

template<class TEnum , class TStorageType = unsigned int, TStorageType defaultValue = 0>
Flag ug::Flag< TEnum, TStorageType, defaultValue >::operator= ( const Flag< TEnum, TStorageType, defaultValue > &  flag)
inline

◆ operator=() [2/2]

template<class TEnum , class TStorageType = unsigned int, TStorageType defaultValue = 0>
Flag ug::Flag< TEnum, TStorageType, defaultValue >::operator= ( TStorageType  val)
inline

◆ operator==() [1/2]

template<class TEnum , class TStorageType = unsigned int, TStorageType defaultValue = 0>
bool ug::Flag< TEnum, TStorageType, defaultValue >::operator== ( const Flag< TEnum, TStorageType, defaultValue > &  flag) const
inline

◆ operator==() [2/2]

template<class TEnum , class TStorageType = unsigned int, TStorageType defaultValue = 0>
bool ug::Flag< TEnum, TStorageType, defaultValue >::operator== ( TStorageType  val) const
inline

◆ operator|()

template<class TEnum , class TStorageType = unsigned int, TStorageType defaultValue = 0>
Flag ug::Flag< TEnum, TStorageType, defaultValue >::operator| ( const Flag< TEnum, TStorageType, defaultValue > &  flag) const
inline

◆ operator|=()

template<class TEnum , class TStorageType = unsigned int, TStorageType defaultValue = 0>
Flag ug::Flag< TEnum, TStorageType, defaultValue >::operator|= ( const Flag< TEnum, TStorageType, defaultValue > &  flag)
inline

◆ partially_contains() [1/2]

template<class TEnum , class TStorageType = unsigned int, TStorageType defaultValue = 0>
bool ug::Flag< TEnum, TStorageType, defaultValue >::partially_contains ( const Flag< TEnum, TStorageType, defaultValue > &  flag) const
inline

◆ partially_contains() [2/2]

◆ remove()

template<class TEnum , class TStorageType = unsigned int, TStorageType defaultValue = 0>
Flag& ug::Flag< TEnum, TStorageType, defaultValue >::remove ( TStorageType  flag)
inline

◆ set()

template<class TEnum , class TStorageType = unsigned int, TStorageType defaultValue = 0>
Flag& ug::Flag< TEnum, TStorageType, defaultValue >::set ( TStorageType  flag)
inline

Member Data Documentation

◆ m_value


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