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

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

#include "drivers/IDriver.h"
#include "drivers/IDriver_vtbl.h"
+ Include dependency graph for HWDriverMap.h:

Go to the source code of this file.

Data Structures

struct  _HWDriverMapValue
 
struct  _HWDriverMapElement
 
struct  _HWDriverMap
 

Macros

#define HDM_NULL_KEY   (0U)
 
#define HDME_IS_EMPTY(p_element)   (((p_element)->value.p_driver_obj == NULL) && ((p_element)->key == HDM_NULL_KEY))
 

Typedefs

typedef struct _HWDriverMapValue HWDriverMapValue_t
 
typedef struct _HWDriverMapElement HWDriverMapElement_t
 
typedef struct _HWDriverMap HWDriverMap_t
 

Functions

static sys_error_code_t HWDriverMap_Init (HWDriverMap_t *_this, HWDriverMapElement_t *p_elements, uint16_t size)
 
static HWDriverMapValue_tHWDriverMap_FindByKey (HWDriverMap_t *_this, uint32_t key)
 
static HWDriverMapElement_tHWDriverMap_AddElement (HWDriverMap_t *_this, uint32_t key, IDriver *p_instance)
 
static bool HWDriverMap_RemoveElement (HWDriverMap_t *_this, uint32_t key)
 
static bool HWDriverMap_IsInitialized (HWDriverMap_t *_this)
 
static bool HWDriverMap_GetElementCount (const HWDriverMap_t *const _this)
 

Detailed Description

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

Author
SRA - GPM

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

Fig.1 - class diagram
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

◆ HDM_NULL_KEY

#define HDM_NULL_KEY   (0U)

reserved key value to specify an invalid key.

◆ HDME_IS_EMPTY

#define HDME_IS_EMPTY (   p_element)    (((p_element)->value.p_driver_obj == NULL) && ((p_element)->key == HDM_NULL_KEY))

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

Typedef Documentation

◆ HWDriverMap_t

typedef struct _HWDriverMap HWDriverMap_t

This map is implemented as an array of size elements.

◆ HWDriverMapElement_t

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

◆ HWDriverMapValue_t

Specifies the value of the elements stored in the map.

Function Documentation

◆ HWDriverMap_AddElement()

static HWDriverMapElement_t * HWDriverMap_AddElement ( HWDriverMap_t _this,
uint32_t  key,
IDriver 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 HWDriverMap_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.

◆ HWDriverMap_FindByKey()

static HWDriverMapValue_t * HWDriverMap_FindByKey ( HWDriverMap_t _this,
uint32_t  key 
)
inlinestatic

Searches the map for an element with a the corresponding key

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

◆ HWDriverMap_GetElementCount()

static bool HWDriverMap_GetElementCount ( const HWDriverMap_t *const  _this)
inlinestatic

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

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

◆ HWDriverMap_Init()

static sys_error_code_t HWDriverMap_Init ( HWDriverMap_t _this,
HWDriverMapElement_t p_elements,
uint16_t  size 
)
inlinestatic

Initialize the Driver map.

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

◆ HWDriverMap_IsInitialized()

static bool HWDriverMap_IsInitialized ( HWDriverMap_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 HWDriverMap_Init().

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

◆ HWDriverMap_RemoveElement()

static bool HWDriverMap_RemoveElement ( HWDriverMap_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 HWDriverMap_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.