From dbca54be2480a9ea1e84dd4b73349fd07fcaafe9 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Thu, 4 Jul 2019 00:13:00 -0700 Subject: rfnoc: node: Make register_property() unlock RW access --- host/include/uhd/rfnoc/node.hpp | 11 ++++++++++- host/lib/rfnoc/node.cpp | 5 ++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/host/include/uhd/rfnoc/node.hpp b/host/include/uhd/rfnoc/node.hpp index 04b3d863f..eaeea20af 100644 --- a/host/include/uhd/rfnoc/node.hpp +++ b/host/include/uhd/rfnoc/node.hpp @@ -181,6 +181,15 @@ protected: using prop_ptrs_t = std::unordered_set; /*! Register a property for this block + * + * This is typically called from the constructor. It is possible to register + * properties later, but then the node must take care of serialization. + * + * This has the intentional side-effect of setting the access mode to RW for + * the property. The idea is that after registering a property, the node + * might need some time to settle on the default value. The access mode will + * either be reset after the constructor is finished, or the next time + * properties are resolved. * * \param prop A reference to the property * \param clean_callback A callback that gets executed whenever this property @@ -454,7 +463,7 @@ private: */ void resolve_all(); - /*! Mark all properties as clean + /*! Mark all properties as clean and read-only * * When dirty properties have a clean-callback registered, that will also * get triggered. diff --git a/host/lib/rfnoc/node.cpp b/host/lib/rfnoc/node.cpp index cdb69e158..d97588bab 100644 --- a/host/lib/rfnoc/node.cpp +++ b/host/lib/rfnoc/node.cpp @@ -94,6 +94,8 @@ void node_t::register_property(property_base_t* prop, resolve_callback_t&& clean if (clean_callback) { _clean_cb_registry[prop] = std::move(clean_callback); } + + prop_accessor_t{}.set_access(prop, property_base_t::RW); } void node_t::add_property_resolver( @@ -353,7 +355,7 @@ void node_t::init_props() } } - // 4) Mark properties as clean + // 4) Mark properties as clean and read-only clean_props(); } @@ -429,6 +431,7 @@ void node_t::clean_props() _clean_cb_registry.at(prop)(); } prop_accessor.mark_clean(*prop); + prop_accessor.set_access(prop, property_base_t::RO); } } } -- cgit v1.2.3