From 15c058015f56cfcd0e42cf6779a6e6ef6e0da911 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Fri, 31 May 2019 21:18:15 -0700 Subject: rfnoc: Use RTTI "serialization" for stream commands A small modification to rfnoc::action_info makes it polymorphic, and instead of serializing data structures into a string, this allows creating custom action objects and identifying them via RTTI. The stream command action object is a good example for how to use this, so all the usages of stream command action objects were converted to this scheme. --- host/lib/rfnoc/actions.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'host/lib/rfnoc/actions.cpp') diff --git a/host/lib/rfnoc/actions.cpp b/host/lib/rfnoc/actions.cpp index 1f5f0f2f7..428a1fcb2 100644 --- a/host/lib/rfnoc/actions.cpp +++ b/host/lib/rfnoc/actions.cpp @@ -19,3 +19,27 @@ action_info::action_info(const std::string& key_) : id(action_counter++), key(ke // nop } +//! Factory function +action_info::sptr action_info::make(const std::string& key) +{ + if (key == ACTION_KEY_STREAM_CMD) { + return stream_cmd_action_info::make( + uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS); + } + //return std::make_shared(key); + return sptr(new action_info(key)); +} + +stream_cmd_action_info::stream_cmd_action_info( + const uhd::stream_cmd_t::stream_mode_t stream_mode) + : action_info(ACTION_KEY_STREAM_CMD), stream_cmd(stream_mode) +{ + // nop +} + +stream_cmd_action_info::sptr stream_cmd_action_info::make( + const uhd::stream_cmd_t::stream_mode_t stream_mode) +{ + //return std::make_shared(ACTION_KEY_STREAM_CMD); + return sptr(new stream_cmd_action_info(stream_mode)); +} -- cgit v1.2.3