Elm
2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
#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 |
@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:
T | Integer type to store the flag bits (default o t::uint32). |
|
inline |
|
inline |
Get the value of flag represented by the index.
Referenced by Flags< T >::operator()(), and Flags< T >::operator[]().
|
inline |
Set to false the flag corresponding to the index.
i | Index of the flag to clear. |
Referenced by AbstractBlockAllocatorWithGC::collectGarbage(), and AbstractBlockAllocatorWithGC::setAsync().
|
inline |
References Flags< T >::bit().
|
inline |
References Flags< T >::bit().
|
inline |
Set to true the flag corresponding to the index.
i | Index of the flag to set. |
Referenced by AbstractBlockAllocatorWithGC::allocate(), and AbstractBlockAllocatorWithGC::setSync().