13#ifndef __MESHX_ELEMENT_FACTORY_HPP__
14#define __MESHX_ELEMENT_FACTORY_HPP__
32template <
typename ElementType,
typename ContextType>
35 uint16_t requested_cnt,
42 if (requested_cnt > max_cnt)
45 "%s: requested count %d exceeds compile-time max %d. Capping.",
46 log_name, requested_cnt, max_cnt);
47 requested_cnt = max_cnt;
50 for (uint16_t i = 0; i < requested_cnt; i++)
55 auto *el =
new (std::nothrow) ElementType(abs_idx);
58 MESHX_LOGE(module_id,
"%s [%d]: allocation failed", log_name, abs_idx);
63 err = el->initialize();
66 MESHX_LOGE(module_id,
"%s [%d]: initialization failed: 0x%x", log_name, abs_idx, err);
74 MESHX_LOGI(module_id,
"%s [%d]: Registering Element with SIG=%d, VEN=%d models",
75 log_name, abs_idx, el->get_no_of_sig_models(), el->get_no_of_ven_models());
80 el->get_sig_plat_model_array(),
81 el->get_ven_plat_model_array(),
82 el->get_no_of_sig_models(),
83 el->get_no_of_ven_models());
87 MESHX_LOGE(module_id,
"%s [%d]: composition registration failed: 0x%x",
88 log_name, abs_idx, err);
meshx_err_t meshx_plat_add_element_to_composition(uint16_t index, meshx_ptr_t p_element_list, meshx_ptr_t p_sig_models, meshx_ptr_t p_ven_models, uint8_t sig_cnt, uint8_t ven_cnt)
Adds an element to the BLE Mesh composition.
struct dev_struct dev_struct_t
Structure representing the device composition and elements.
MeshX Element class and interface declaration This file contains the meshXElement class and its inter...
meshx_err_t meshx_element_factory_helper(dev_struct_t *pdev, uint16_t requested_cnt, uint16_t max_cnt, module_id_t module_id, const char *log_name)
Helper function to create and register mesh elements.
Definition meshx_element_factory.hpp:33
meshx_err_t
MeshX Error Codes.
Definition meshx_err.h:43
@ MESHX_NO_MEM
Definition meshx_err.h:48
#define MESHX_LOGW(module_id, format,...)
Definition meshx_log.h:120
#define MESHX_LOGI(module_id, format,...)
Definition meshx_log.h:126
#define MESHX_LOGE(module_id, format,...)
Definition meshx_log.h:114
**This function is called by the parent element when a state change request *is received It validates the request and returns a result to the element not the model layer **return * MESHX_SUCCESS
Definition meshx_model_level.cpp:385
module_id_t
Enumeration of module IDs.
Definition module_id.h:27
size_t element_idx
Definition meshx_common.h:71
MESHX_ELEMENT * elements
Definition meshx_common.h:73