|
modm API documentation
|
#include <modm/architecture/interface/register.hpp>
Public Typedefs | |
| typedef Enum | EnumType |
| The enum type. | |
| typedef T | UnderlyingType |
| The integer type internally used to represent the register. | |
Public Member Functions | |
| constexpr | operator bool () const |
| constexpr bool | operator! () const |
Returns true if value is zero. | |
| constexpr FlagsOperators | operator~ () const |
| bitwise negation | |
| constexpr FlagsOperators | operator& (FlagsOperators const &o) const |
| bitwise AND with multiple bits | |
| constexpr FlagsOperators | operator^ (FlagsOperators const &o) const |
| bitwise XOR with multiple bits | |
| constexpr FlagsOperators | operator| (FlagsOperators const &o) const |
| bitwise OR with multiple bits | |
| FlagsOperators & | operator&= (FlagsOperators const &o) |
| bitwise AND with multiple bits | |
| FlagsOperators & | operator^= (FlagsOperators const &o) |
| bitwise XOR with multiple bits | |
| FlagsOperators & | operator|= (FlagsOperators const &o) |
| bitwise OR with multiple bits | |
| FlagsOperators & | operator&= (Enum const &flag) |
| bitwise AND with a single bit | |
| FlagsOperators & | operator^= (Enum const &flag) |
| bitwise XOR with a single bit | |
| FlagsOperators & | operator|= (Enum const &flag) |
| bitwise OR with a single bit | |
| constexpr | Flags () |
default constructor initializes value to zero | |
| constexpr | Flags (Enum flag) |
| constructs itself out of a strongly-typed enum | |
| constexpr | Flags (FlagsOperators< Enum, T > const &flag) |
| constexpr | Flags (UnderlyingType flag) |
| When explicitly called, this class constructs itself out of the underlying type. | |
| constexpr | Flags (Register< T > const &o) |
| When explicitly called, this class constructs itself out of the superclass. | |
| constexpr | Flags (Flags const &o) = default |
| Copy constructor. | |
| constexpr | Flags (Flags &&o) = default |
| Move constructor. | |
| Flags & | operator= (Flags const &o) = default |
| Copy assignment. | |
| Flags & | operator= (Flags &&o) = default |
| Move assignment. | |
| void | set (Enum const &flag) |
| Sets a single bit. | |
| void | set (Flags const &o) |
| Sets multiple bits. | |
| void | reset (Enum const &flag) |
| Clears a single bit. | |
| void | reset (Flags const &o) |
| Clears multiple bits. | |
| void | toggle (Enum const &flag) |
| Toggles a single bit. | |
| void | toggle (Flags const &o) |
| Toggles multiple bits. | |
| void | update (Enum const &flag, bool valueToCompare) |
Sets a single bit, when valueToCompare is true, clears it otherwise. | |
| void | update (Flags const &o, bool valueToCompare) |
Sets multiple bits, when valueToCompare is true, clears them otherwise. | |
| constexpr bool | all (Enum const &flag) const |
Returns true if bit is set. | |
| constexpr bool | any (Enum const &flag) const |
Returns true if bit is set. | |
| constexpr bool | none (Enum const &flag) const |
Returns true if bit is not set. | |
| constexpr bool | all (Flags const &o) const |
Returns true if all of the passed bits are set. | |
| constexpr bool | any (Flags const &o) const |
Returns true if any of the passed bits are set. | |
| constexpr bool | none (Flags const &o) const |
Returns true if none of the passed bits are set. | |
Static Public Member Functions | |
| static constexpr FlagsOperators | mask () |
| returns the mask of the integer type | |
Public Attributes | |
| UnderlyingType | value |
| The underlying integer value. | |
Class for operating on a register.
This class extends the FlagsOperators base class by adding constructor overloading and convenience functions between a strongly-typed enum and itself.
This class makes heavy use of constexpr, so that as many values and operation can take place at compile time for efficiency.
Unfortunately, you cannot typedef this class directly, you must use the MODM_FLAGS macro, which add the required external operator overloads for Enum OP Enum. The macro MODM_FLAGS8(Enum) expands as follows:
The MODM_FLAGS macro by default only works in a class or struct, as this is the primary use-case in modm. To use it outside of a struct, use this:
| Enum | a strongly-typed enum containing the bit masks |
| T | the underlying integer type to be for internal representation |
|
inheritedinlineexplicitconstexpr |
Returns true if value is non-zero
The compiler will allow implicit conversions to bool in the following contexts: