Dataflow Runtime API
3.1.1.0
|
A template to create a type safe flags type from an enum. More...
#include <Imt.Base.Core.Util/Flags.h>
Public Member Functions | |
Flags (void) | |
Default constructor. More... | |
Flags (const typename EnumType::Id flag) | |
User defined constructor. More... | |
Flags (const BaseType flags) | |
User defined constructor. More... | |
Flags (const Flags &other) | |
Copy constructor. More... | |
virtual | ~Flags (void) |
Destructor. More... | |
void | set (const typename EnumType::Id flag) |
Sets the given flag. More... | |
void | clear (const typename EnumType::Id flag) |
Clears the given flag. More... | |
bool | isSet (const typename EnumType::Id flag) const |
Checks whether the given flag is set. More... | |
const BaseType & | toInteger (void) const |
Returns the base type. More... | |
Flags | combine (const Flags &other) const |
Combines the flags with another instance. More... | |
Flags | intersect (const Flags &other) const |
Intersects the flags with another instance. More... | |
Flags & | operator= (const Flags &other) |
Assignment operator. More... | |
bool | operator== (const Flags< EnumType, BaseType > &other) const |
Compare for equality operator. More... | |
bool | operator!= (const Flags< EnumType, BaseType > &other) const |
Compare for equality operator. More... | |
A template to create a type safe flags type from an enum.
EnumType | A struct that contains the flags and provides the following features: MIN The lowest possible flag (equals to 0). MAX The highest possible flag (equals to COUNT - 1). COUNT A constant that contains the number of flags in the struct. Id The actual enum with the flags. The enumerators must range from MIN to MAX |
BaseType | An unsigned integer type that is large enough to fit the enum type |
Example for a well formed enum struct to pass as EnumType:
struct MyFlagEnum { enum Id { Bit1, _unused_Bit2, Bit3 };
static const uint32_t MIN = 0U; static const uint32_t MAX = static_cast<uint32_t>(Bit3); static const uint32_t COUNT = MAX + 1U; };
imt::base::core::util::Flags< EnumType, BaseType >::Flags | ( | void | ) |
Default constructor.
Creates an instance with no flag set.
|
explicit |
User defined constructor.
Creates an instance with the given flag set.
flag | Flag. |
|
explicit |
imt::base::core::util::Flags< EnumType, BaseType >::Flags | ( | const Flags< EnumType, BaseType > & | other | ) |
Copy constructor.
other | Other Flags object to copy. |
|
virtual |
Destructor.
void imt::base::core::util::Flags< EnumType, BaseType >::clear | ( | const typename EnumType::Id | flag | ) |
Clears the given flag.
flag | Flag to clear. |
Flags< EnumType, BaseType > imt::base::core::util::Flags< EnumType, BaseType >::combine | ( | const Flags< EnumType, BaseType > & | other | ) | const |
Combines the flags with another instance.
This will return a flags instance that has all flags set which are set in any of the given instances.
other | Other flags to combine with. |
Flags< EnumType, BaseType > imt::base::core::util::Flags< EnumType, BaseType >::intersect | ( | const Flags< EnumType, BaseType > & | other | ) | const |
Intersects the flags with another instance.
This will return a flags instance that has all flags set which are set in both of the given instances.
other | Other flags to intersect with. |
bool imt::base::core::util::Flags< EnumType, BaseType >::isSet | ( | const typename EnumType::Id | flag | ) | const |
Checks whether the given flag is set.
flag | Flag to check. |
bool imt::base::core::util::Flags< EnumType, BaseType >::operator!= | ( | const Flags< EnumType, BaseType > & | other | ) | const |
Compare for equality operator.
Will return true if at least one flags is not the same in both instances.
other | Other flags to compare with. |
Flags< EnumType, BaseType > & imt::base::core::util::Flags< EnumType, BaseType >::operator= | ( | const Flags< EnumType, BaseType > & | other | ) |
Assignment operator.
other | Other flags to assign. |
bool imt::base::core::util::Flags< EnumType, BaseType >::operator== | ( | const Flags< EnumType, BaseType > & | other | ) | const |
Compare for equality operator.
Will return true if exactly the same flags are set in both instances.
other | Other flags to compare with. |
void imt::base::core::util::Flags< EnumType, BaseType >::set | ( | const typename EnumType::Id | flag | ) |
Sets the given flag.
flag | Flag to set. |
const BaseType & imt::base::core::util::Flags< EnumType, BaseType >::toInteger | ( | void | ) | const |
Returns the base type.