OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
ot::Flags< T > Class Template Reference

This class is used to manage flags. Don't forget to add OT_ADD_FLAG_FUNCTIONS and the bottom of your header. The type should be an enumeration where every value represents a single bit in a 32/64 bit value. e.g: enum enumName { enumValue1 = 0x01, // 0001 enumValue2 = 0x02, // 0010 enumValue3 = 0x04, // 0100 ... };. More...

#include "Flags.h"

Public Member Functions

 Flags ()
 Data.
 
 Flags (T _initialData)
 Assignment constructor.
 
 Flags (const Flags< T > &_other)
 Copy constructor.
 
data (void) const
 Returns a copy of the data.
 
void set (T _data)
 Replace the current data.
 
void setFlag (T _flag)
 Set the provided flag.
 
void setFlag (T _flag, bool _flagIsSet)
 Set or remove the provided flag.
 
void removeFlag (T _flag)
 Remove the provided flag.
 
bool flagIsSet (T _flag) const
 Returns true if the provided flag is set.
 
 operator T (void) const
 Operator T is used to assign the Flags to a enum variable with the same type that is managed by Flags.
 
 operator bool (void) const
 Returns true if at least one flag is set (assuming 0 = no flags).
 
Flags< T > & operator= (T _flag)
 
Flags< T > & operator= (const Flags< T > &_other)
 
Flags< T > operator| (T _flag) const
 
Flags< T > operator| (const Flags< T > &_other) const
 
Flags< T > operator& (T _flag) const
 
Flags< T > operator& (const Flags< T > &_other) const
 
Flags< T > & operator|= (T _flag)
 
Flags< T > & operator|= (const Flags< T > &_other)
 
Flags< T > & operator&= (T _flag)
 
Flags< T > & operator&= (const Flags< T > &_other)
 
Flags< T > operator~ (void) const
 
bool operator== (T _flag) const
 
bool operator== (const Flags< T > &_other) const
 
bool operator!= (T _flag) const
 
bool operator!= (const Flags< T > &_other) const
 

Detailed Description

template<typename T>
class ot::Flags< T >

This class is used to manage flags. Don't forget to add OT_ADD_FLAG_FUNCTIONS and the bottom of your header. The type should be an enumeration where every value represents a single bit in a 32/64 bit value. e.g: enum enumName { enumValue1 = 0x01, // 0001 enumValue2 = 0x02, // 0010 enumValue3 = 0x04, // 0100 ... };.

Note
Note that only enumration types are allowed.

Constructor & Destructor Documentation

◆ Flags() [1/3]

template<typename T >
ot::Flags< T >::Flags ( )
inline

Data.

Default constructor. Initializes the data with 0.

◆ Flags() [2/3]

template<typename T >
ot::Flags< T >::Flags ( T _initialData)
inline

Assignment constructor.

Parameters
_initialDataInitial data.

◆ Flags() [3/3]

template<typename T >
ot::Flags< T >::Flags ( const Flags< T > & _other)
inline

Copy constructor.

Parameters
_otherOther flags.

Member Function Documentation

◆ data()

template<typename T >
T ot::Flags< T >::data ( void ) const
inline

Returns a copy of the data.

◆ flagIsSet()

template<typename T >
bool ot::Flags< T >::flagIsSet ( T _flag) const
inline

Returns true if the provided flag is set.

Parameters
_flagthe flag that should be checked

◆ operator bool()

template<typename T >
ot::Flags< T >::operator bool ( void ) const
inline

Returns true if at least one flag is set (assuming 0 = no flags).

◆ operator T()

template<typename T >
ot::Flags< T >::operator T ( void ) const
inline

Operator T is used to assign the Flags to a enum variable with the same type that is managed by Flags.

◆ operator!=() [1/2]

template<typename T >
bool ot::Flags< T >::operator!= ( const Flags< T > & _other) const
inline

◆ operator!=() [2/2]

template<typename T >
bool ot::Flags< T >::operator!= ( T _flag) const
inline

◆ operator&() [1/2]

template<typename T >
Flags< T > ot::Flags< T >::operator& ( const Flags< T > & _other) const
inline

◆ operator&() [2/2]

template<typename T >
Flags< T > ot::Flags< T >::operator& ( T _flag) const
inline

◆ operator&=() [1/2]

template<typename T >
Flags< T > & ot::Flags< T >::operator&= ( const Flags< T > & _other)
inline

◆ operator&=() [2/2]

template<typename T >
Flags< T > & ot::Flags< T >::operator&= ( T _flag)
inline

◆ operator=() [1/2]

template<typename T >
Flags< T > & ot::Flags< T >::operator= ( const Flags< T > & _other)
inline

◆ operator=() [2/2]

template<typename T >
Flags< T > & ot::Flags< T >::operator= ( T _flag)
inline

◆ operator==() [1/2]

template<typename T >
bool ot::Flags< T >::operator== ( const Flags< T > & _other) const
inline

◆ operator==() [2/2]

template<typename T >
bool ot::Flags< T >::operator== ( T _flag) const
inline

◆ operator|() [1/2]

template<typename T >
Flags< T > ot::Flags< T >::operator| ( const Flags< T > & _other) const
inline

◆ operator|() [2/2]

template<typename T >
Flags< T > ot::Flags< T >::operator| ( T _flag) const
inline

◆ operator|=() [1/2]

template<typename T >
Flags< T > & ot::Flags< T >::operator|= ( const Flags< T > & _other)
inline

◆ operator|=() [2/2]

template<typename T >
Flags< T > & ot::Flags< T >::operator|= ( T _flag)
inline

◆ operator~()

template<typename T >
Flags< T > ot::Flags< T >::operator~ ( void ) const
inline

◆ removeFlag()

template<typename T >
void ot::Flags< T >::removeFlag ( T _flag)
inline

Remove the provided flag.

Parameters
_flagThe flag to remove

◆ set()

template<typename T >
void ot::Flags< T >::set ( T _data)
inline

Replace the current data.

Parameters
_dataThe data that should be replaced with

◆ setFlag() [1/2]

template<typename T >
void ot::Flags< T >::setFlag ( T _flag)
inline

Set the provided flag.

Parameters
_flagThe flag to set

◆ setFlag() [2/2]

template<typename T >
void ot::Flags< T >::setFlag ( T _flag,
bool _flagIsSet )
inline

Set or remove the provided flag.

Parameters
_flagThe flag to set
_flagIsSetIf true the flag will be set, otherwise removed

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