Module for writing and reading flags that are associated with keys.
More...
|
uint16_t | sdk_mapped_flags_first_key_index_get (sdk_mapped_flags_t flags) |
| Function for getting the first index at which the flag is true in the provided collection. More...
|
|
void | sdk_mapped_flags_update_by_key (uint16_t *p_keys, sdk_mapped_flags_t *p_flags, uint16_t key, bool value) |
| Function for updating the state of a flag. More...
|
|
void | sdk_mapped_flags_bulk_update_by_key (uint16_t *p_keys, sdk_mapped_flags_t *p_flags, uint32_t n_flag_collections, uint16_t key, bool value) |
| Function for updating the state of the same flag in multiple flag collections. More...
|
|
bool | sdk_mapped_flags_get_by_key (uint16_t *p_keys, sdk_mapped_flags_t flags, uint16_t key) |
| Function for getting the state of a specific flag. More...
|
|
bool | sdk_mapped_flags_get_by_key_w_idx (uint16_t *p_keys, sdk_mapped_flags_t flags, uint16_t key, uint8_t *p_index) |
| Function for getting the state of a specific flag. More...
|
|
sdk_mapped_flags_key_list_t | sdk_mapped_flags_key_list_get (uint16_t *p_keys, sdk_mapped_flags_t flags) |
| Function for getting a list of all keys that have a specific flag set to true. More...
|
|
uint32_t | sdk_mapped_flags_n_flags_set (sdk_mapped_flags_t flags) |
| Function for getting the number of keys that have a specific flag set to true. More...
|
|
static __INLINE bool | sdk_mapped_flags_any_set (sdk_mapped_flags_t flags) |
| Function for querying whether any flags in the collection are set. More...
|
|
Module for writing and reading flags that are associated with keys.
The flags are represented as bits in a bitmap called a flag collection. The keys are uint16_t. Each flag collection contains all flags of the same type, one flag for each key.
The mapped flags module does not keep the flag states, nor the list of keys. These are provided in the API calls. A key's index in the key list determines which bit in the flag collection is associated with it. This module does not ever edit the key list, and does not edit flags except in function calls that take the flag collection as a pointer.
#define SDK_MAPPED_FLAGS_INVALID_INDEX 0xFFFF |
A flag index guaranteed to be invalid.
#define SDK_MAPPED_FLAGS_N_KEYS 32 |
The number of keys to keep flags for. This is also the number of flags in a flag collection. If changing this value, you might also need change the width of the sdk_mapped_flags_t type.
#define SDK_MAPPED_FLAGS_N_KEYS_PER_BYTE 8 |
The number of flags that fit in one byte.
The bitmap to hold flags. Each flag is one bit, and each bit represents the flag state associated with one key.
Function for querying whether any flags in the collection are set.
- Parameters
-
[in] | flags | The flag collection to query. |
- Return values
-
true | If one or more flags are set to true. |
false | Otherwise. |
void sdk_mapped_flags_bulk_update_by_key |
( |
uint16_t * |
p_keys, |
|
|
sdk_mapped_flags_t * |
p_flags, |
|
|
uint32_t |
n_flag_collections, |
|
|
uint16_t |
key, |
|
|
bool |
value |
|
) |
| |
Function for updating the state of the same flag in multiple flag collections.
The key and value are the same for all flag collections in the p_flags array.
- Parameters
-
[in] | p_keys | The list of associated keys (assumed to have a length of SDK_MAPPED_FLAGS_N_KEYS). |
[out] | p_flags | The flag collections to modify. |
[out] | n_flag_collections | The number of flag collections in p_flags. |
[in] | key | The key to modify the flag of. |
[in] | value | The state to set the flag to. |
Function for getting the first index at which the flag is true in the provided collection.
- Parameters
-
[in] | flags | The flag collection to search for a flag set to true. |
- Returns
- The first index that has its flag set to true. If none were found, the function returns SDK_MAPPED_FLAGS_INVALID_INDEX.
bool sdk_mapped_flags_get_by_key |
( |
uint16_t * |
p_keys, |
|
|
sdk_mapped_flags_t |
flags, |
|
|
uint16_t |
key |
|
) |
| |
Function for getting the state of a specific flag.
- Parameters
-
[in] | p_keys | The list of associated keys (assumed to have a length of SDK_MAPPED_FLAGS_N_KEYS). |
[in] | flags | The flag collection to read from. |
[in] | key | The key to get the flag for. |
- Returns
- The state of the flag.
bool sdk_mapped_flags_get_by_key_w_idx |
( |
uint16_t * |
p_keys, |
|
|
sdk_mapped_flags_t |
flags, |
|
|
uint16_t |
key, |
|
|
uint8_t * |
p_index |
|
) |
| |
Function for getting the state of a specific flag.
- Parameters
-
[in] | p_keys | The list of associated keys (assumed to have a length of SDK_MAPPED_FLAGS_N_KEYS). |
[in] | flags | The flag collection from which to read. |
[in] | key | The key for which to get the flag. |
[out] | p_index | If not NULL, the index of the key. |
- Returns
- The state of the flag.
Function for getting a list of all keys that have a specific flag set to true.
- Parameters
-
[in] | p_keys | The list of associated keys (assumed to have a length of SDK_MAPPED_FLAGS_N_KEYS). |
[in] | flags | The flag collection to search. |
- Returns
- The list of keys.
Function for getting the number of keys that have a specific flag set to true.
- Parameters
-
[in] | flags | The flag collection to search. |
- Returns
- The number of keys.
void sdk_mapped_flags_update_by_key |
( |
uint16_t * |
p_keys, |
|
|
sdk_mapped_flags_t * |
p_flags, |
|
|
uint16_t |
key, |
|
|
bool |
value |
|
) |
| |
Function for updating the state of a flag.
- Parameters
-
[in] | p_keys | The list of associated keys (assumed to have a length of SDK_MAPPED_FLAGS_N_KEYS). |
[out] | p_flags | The flag collection to modify. |
[in] | key | The key to modify the flag of. |
[in] | value | The state to set the flag to. |