diff options
author | Martin Braun <martin.braun@ettus.com> | 2019-05-31 21:18:15 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2019-11-26 11:49:18 -0800 |
commit | 15c058015f56cfcd0e42cf6779a6e6ef6e0da911 (patch) | |
tree | 82a4c9311fea7c2eafab371e00bfef00e05596b8 /host/lib/rfnoc/actions.cpp | |
parent | 73171698b55133aaeab461781476b02c4416da8f (diff) | |
download | uhd-15c058015f56cfcd0e42cf6779a6e6ef6e0da911.tar.gz uhd-15c058015f56cfcd0e42cf6779a6e6ef6e0da911.tar.bz2 uhd-15c058015f56cfcd0e42cf6779a6e6ef6e0da911.zip |
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.
Diffstat (limited to 'host/lib/rfnoc/actions.cpp')
-rw-r--r-- | host/lib/rfnoc/actions.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
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<action_info>(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_info>(ACTION_KEY_STREAM_CMD); + return sptr(new stream_cmd_action_info(stream_mode)); +} |