eLooM for STM32 application  v3.3.0
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions
ManagedTaskMap.h File Reference

This class implements a map between a managed task Instance and it's parameters. More...

#include "services/AManagedTask.h"
+ Include dependency graph for ManagedTaskMap.h:

Go to the source code of this file.

Data Structures

struct  _MTMapValue
 
struct  _MTMapElement
 
struct  _MTMap
 

Macros

#define MTM_NULL_KEY   (0U)
 
#define MTME_IS_EMPTY(p_element)   (((p_element)->value.p_mtask_obj == NULL) && ((p_element)->key == MTM_NULL_KEY))
 

Typedefs

typedef struct _MTMapValue MTMapValue_t
 
typedef struct _MTMapElement MTMapElement_t
 
typedef struct _MTMap MTMap_t
 

Functions

static sys_error_code_t MTMap_Init (MTMap_t *_this, MTMapElement_t *p_elements, uint16_t size)
 
static MTMapValue_tMTMap_FindByKey (MTMap_t *_this, uint32_t key)
 
static MTMapElement_tMTMap_AddElement (MTMap_t *_this, uint32_t key, AManagedTask *p_instance)
 
static bool MTMap_RemoveElement (MTMap_t *_this, uint32_t key)
 
static bool MTMap_IsInitialized (MTMap_t *_this)
 
static bool MTMap_GetElementCount (const MTMap_t *const _this)
 

Detailed Description

This class implements a map between a managed task Instance and it's parameters.

Author
SRA - GPM

The map is a collection of pairs (key, value) named element, where:

Attention

Copyright (c) 2023 STMicroelectronics. All rights reserved.

This software is licensed under terms that can be found in the LICENSE file in the root directory of this software component. If no LICENSE file comes with this software, it is provided AS-IS.

Macro Definition Documentation

◆ MTM_NULL_KEY

#define MTM_NULL_KEY   (0U)

reserved key value to specify an invalid key.

◆ MTME_IS_EMPTY

#define MTME_IS_EMPTY (   p_element)    (((p_element)->value.p_mtask_obj == NULL) && ((p_element)->key == MTM_NULL_KEY))

Check if an MTMapElement_t is empty. The element in the map are not allocated and released dynamically, but rather the element are marked as empty.

Typedef Documentation

◆ MTMap_t

typedef struct _MTMap MTMap_t

This map is implemented as an array of size elements.

◆ MTMapElement_t

typedef struct _MTMapElement MTMapElement_t

Specifies the element of the map. It is the pair (key, value)

◆ MTMapValue_t

typedef struct _MTMapValue MTMapValue_t

Specifies the value of the elements stored in the map.

Function Documentation

◆ MTMap_AddElement()

static MTMapElement_t * MTMap_AddElement ( MTMap_t _this,
uint32_t  key,
AManagedTask p_instance 
)
inlinestatic

Add a new pair (key, IDriver) to the map. The pair (key, IDriver) is namebd element. If the key is already present to the map then the element is not added and the method return NULL. If the element is already present in the map then the method return the element.

Parameters
_this[IN] pointer to a valid MTMap_t object.
key[IN] unique ID for the element.
[IN]p_instance specifies the IDriver instance of the element's value.
Returns
a pointer the the new added element (key, value) if success, or NULL if the element cannot be added into the map.

◆ MTMap_FindByKey()

static MTMapValue_t * MTMap_FindByKey ( MTMap_t _this,
uint32_t  key 
)
inlinestatic

Searches the map for an element with a the corresponding key

Parameters
_this[IN] pointer to a valid MTMap_t object.
key[IN] key to be searched.
Returns
The corresponding MTMapElement_t if found, NULL otherwise.

◆ MTMap_GetElementCount()

static bool MTMap_GetElementCount ( const MTMap_t *const  _this)
inlinestatic

Get the number of element (key, value) present in the map.

Parameters
_this[IN] pointer to a valid MTMap_t object.
Returns
the number of element (key, value) present in the map.

◆ MTMap_Init()

static sys_error_code_t MTMap_Init ( MTMap_t _this,
MTMapElement_t p_elements,
uint16_t  size 
)
inlinestatic

Initialize the Driver map.

Parameters
_this[IN] pointer to a valid MTMap_t object.
p_elements[IN] pointer to a valid MTMapElement_t array.
size[IN] number of elements in the array
Returns
SYS_NO_ERROR_CODE if success, an error code otherwise.

◆ MTMap_IsInitialized()

static bool MTMap_IsInitialized ( MTMap_t _this)
inlinestatic

Check if the map has been initialized. If a map is not initialized, any call to the map API has unknown effect. To initialize a map use the method MTMap_Init().

Parameters
_this[IN] pointer to a valid MTMap_t object.
Returns
true if the map has been initialized, false otherwise.

◆ MTMap_RemoveElement()

static bool MTMap_RemoveElement ( MTMap_t _this,
uint32_t  key 
)
inlinestatic

Remove the element with the specific key from the map. The element is marked as removed, and no memory de-allocation is done.

Parameters
_this[IN] pointer to a valid MTMap_t object.
key[IN] unique ID for the element.
Returns
true if the element as been removed from the map, false if the element is not in the map.