Skip to content

Commit b0f6836

Browse files
silabs-borislrzr
authored andcommitted
uic: zpc: UIC-3488: Use multimap for resolver_function_map
This allows us to have same attribute bound to different resolver function (cherry picked from commit 96aca76524a0f8704d2c2d73b6743470479e22be) Forwarded: #11 Signed-off-by: Philippe Coval <philippe.coval@silabs.com>
1 parent 9db1540 commit b0f6836

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

applications/zpc/components/zwave_command_classes/test/helpers/zwave_resolver_function_helper.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,29 +42,34 @@ sl_status_t zwave_resolver_function_helper::register_resolver_functions(
4242
std::string message;
4343
std::string node_name = attribute_store_get_type_name(node_type);
4444

45-
if (attributes_binding.find(node_type) != attributes_binding.end()) {
46-
const auto func = attributes_binding.at(node_type);
45+
if (attributes_binding.count(node_type) == 0)
46+
{
47+
return SL_STATUS_OK;
48+
}
49+
auto funcs = attributes_binding.equal_range(node_type);
4750

48-
if (func.get_func_id == 0) {
51+
for (auto &func = funcs.first; func != funcs.second; ++func)
52+
{
53+
if (func->second.get_func_id == 0) {
4954
message = "GET function should not be defined for " + node_name
5055
+ ". Did you forget to add it to the binding attribute ?";
5156
TEST_ASSERT_NULL_MESSAGE(get_func, message.c_str());
5257
} else {
5358
message = "SET function should be defined for " + node_name
5459
+ ". Did you forget to remove it to the binding attribute ?";
5560
TEST_ASSERT_NOT_NULL_MESSAGE(get_func, message.c_str());
56-
resolver_functions[func.get_func_id] = get_func;
61+
resolver_functions[func->second.get_func_id] = get_func;
5762
}
5863

59-
if (func.set_func_id == 0) {
64+
if (func->second.set_func_id == 0) {
6065
message = "SET function should not be defined for " + node_name
6166
+ ". Did you forget to add it to the binding attribute ?";
6267
TEST_ASSERT_NULL_MESSAGE(set_func, message.c_str());
6368
} else {
6469
message = "SET function should be defined for " + node_name
6570
+ ". Did you forget to remove it to the binding attribute ?";
6671
TEST_ASSERT_NOT_NULL_MESSAGE(set_func, message.c_str());
67-
resolver_functions[func.set_func_id] = set_func;
72+
resolver_functions[func->second.set_func_id] = set_func;
6873
}
6974
}
7075

applications/zpc/components/zwave_command_classes/test/helpers/zwave_resolver_function_helper.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ struct zwave_functions {
6464
* @endcode
6565
*
6666
*/
67-
using resolver_function_map = std::map<attribute_store_type_t, zwave_functions>;
67+
using resolver_function_map = std::multimap<attribute_store_type_t, zwave_functions>;
6868

6969
/**
7070
* @brief Helper class to manage resolver functions

0 commit comments

Comments
 (0)