From c3327801ca43f3fdeca669e3aff470ce05e439a0 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Wed, 26 Jan 2022 09:52:48 +0100 Subject: rfnoc: Add post_init() method to noc_block_base This method allows running a fixed set of rules to check the internal consistency of a block. This may be necessary, because blocks authors may incorrectly implement a certain design rule, and we want the ability to not start an RFNoC graph with blocks that have rule violations which we can write checks for. --- host/lib/rfnoc/rfnoc_graph.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'host/lib/rfnoc/rfnoc_graph.cpp') diff --git a/host/lib/rfnoc/rfnoc_graph.cpp b/host/lib/rfnoc/rfnoc_graph.cpp index 35a5cb28c..0d0e03043 100644 --- a/host/lib/rfnoc/rfnoc_graph.cpp +++ b/host/lib/rfnoc/rfnoc_graph.cpp @@ -58,8 +58,25 @@ struct route_info_t graph_edge_t src_static_edge; graph_edge_t dst_static_edge; }; + } // namespace +// Define an attorney to limit access to noc_block_base internals +class rfnoc_graph_impl; +namespace uhd { namespace rfnoc { + +class block_initializer +{ + static void post_init(noc_block_base::sptr block) + { + block->post_init(); + } + friend rfnoc_graph_impl; +}; + +}} // namespace uhd::rfnoc + + class rfnoc_graph_impl : public rfnoc_graph { public: @@ -731,6 +748,7 @@ private: try { _block_registry->register_block( block_factory_info.factory_fn(std::move(make_args_uptr))); + block_initializer::post_init(_block_registry->get_block(block_id)); } catch (...) { UHD_LOG_ERROR( LOG_ID, "Error during initialization of block " << block_id << "!"); -- cgit v1.2.3