Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
Flags< T > Class Template Reference

#include <elm/util/Flags.h>

Public Member Functions

 Flags (T i=0)
 
bool bit (int i) const
 
void set (int i)
 
void clear (int i)
 
bool operator() (int i) const
 
bool operator[] (int i) const
 

Detailed Description

template<class T = t::uint32>
class elm::Flags< T >

@macro UNUSED Avoid "unused variable" warning when put after the identifier of the variable. Mainly useful when a for(auto x: ...) is used. @macro ELM_UNUSED See UNUSED.

Small class to manage flags of bit in a safe way.

The user has to assign an index to each flag bit and they are stored in this class as an integer of type type T. Then, they may be read, set or cleared safely with function of Flags.

Operator (index) and [index] can be used as shortcuts to Flags::bit().

A common use of this class with 3 flags, RED, GREEN, BLUE could be:

const int RED = 0, GREEN = 1, BLUE = 2;
Flags<> f;
f.set(RED);
f.clear(GREEN);
if(f(RED))
// do something
Parameters
TInteger type to store the flag bits (default o t::uint32).

Constructor & Destructor Documentation

◆ Flags()

Flags ( i = 0)
inline

Member Function Documentation

◆ bit()

bool bit ( int  i) const
inline

Get the value of flag represented by the index.

Returns
Flag value.

Referenced by Flags< T >::operator()(), and Flags< T >::operator[]().

◆ clear()

void clear ( int  i)
inline

Set to false the flag corresponding to the index.

Parameters
iIndex of the flag to clear.

Referenced by AbstractBlockAllocatorWithGC::collectGarbage(), and AbstractBlockAllocatorWithGC::setAsync().

◆ operator()()

bool operator() ( int  i) const
inline

References Flags< T >::bit().

◆ operator[]()

bool operator[] ( int  i) const
inline

References Flags< T >::bit().

◆ set()

void set ( int  i)
inline

Set to true the flag corresponding to the index.

Parameters
iIndex of the flag to set.

Referenced by AbstractBlockAllocatorWithGC::allocate(), and AbstractBlockAllocatorWithGC::setSync().


The documentation for this class was generated from the following files:
elm::io::GREEN
ANSICode GREEN
< ANSI code for red text
Definition: ansi.h:49
elm::io::BLUE
ANSICode BLUE
< ANSI code for yellow text
Definition: ansi.h:51
elm::io::RED
ANSICode RED
< ANSI code for black text
Definition: ansi.h:48