From a5fe0b071d7041f0539804cd16ada27d920bc96d Mon Sep 17 00:00:00 2001 From: Aaron Rossetto Date: Wed, 22 Jul 2020 12:51:21 -0500 Subject: rfnoc: Support instance overrides in set_properties() This commit adds an enhancement to node_t::set_properties() in which the instance argument provided to the function (which normally applies to all properties in the key/value list) can be overridden on a per-property basis using a special syntax. If the key consists of the property name followed by a colon (':') and then a number, the number following the colon is used to determine which instance of the property this set pertains to, and the value passed via the instance parameter is ignored for that property. For example, in the following call: node->set_properties("dog=10,cat:2=5,bird:0=0.5", 1) instance 1 of node's 'dog' property is set to 10, the 1 coming from the instance parameter, instance 2 of the node's 'cat' property is set to 5 due to the override syntax provided in the string, and instance 0 of the node's 'bird' property is set to 0.5 due to its override. If the name/instance pair is malformed, e.g. 'value:=10' or 'value:foobar=10', a runtime error is thrown. --- host/tests/rfnoc_property_test.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'host/tests/rfnoc_property_test.cpp') diff --git a/host/tests/rfnoc_property_test.cpp b/host/tests/rfnoc_property_test.cpp index eb22424b1..d1a8ba981 100644 --- a/host/tests/rfnoc_property_test.cpp +++ b/host/tests/rfnoc_property_test.cpp @@ -65,6 +65,19 @@ BOOST_AUTO_TEST_CASE(test_get_set) BOOST_CHECK(prop_i.is_dirty()); } +BOOST_AUTO_TEST_CASE(test_valid_names) +{ + bool value_error_caught = false; + try { + property_t prop_i{"int_prop:0", 10, {res_source_info::USER, 0}}; + } catch(const uhd::value_error& e) { + value_error_caught = true; + } catch(...) { + } + + BOOST_CHECK(value_error_caught); +} + BOOST_AUTO_TEST_CASE(test_lock) { prop_accessor_t prop_accessor; -- cgit v1.2.3