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/include/uhd/rfnoc/actions.hpp | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'host/include') diff --git a/host/include/uhd/rfnoc/actions.hpp b/host/include/uhd/rfnoc/actions.hpp index ac454827c..611cb787c 100644 --- a/host/include/uhd/rfnoc/actions.hpp +++ b/host/include/uhd/rfnoc/actions.hpp @@ -8,6 +8,8 @@ #define INCLUDED_LIBUHD_RFNOC_ACTIONS_HPP #include +#include +#include #include #include #include @@ -24,6 +26,8 @@ namespace uhd { namespace rfnoc { struct UHD_API action_info { public: + virtual ~action_info() {} + using sptr = std::shared_ptr; //! A unique counter for this action const size_t id; @@ -34,16 +38,26 @@ public: std::vector payload; //! Factory function - static sptr make(const std::string& key="") - { - //return std::make_shared(key); - return sptr(new action_info(key)); - } + static sptr make(const std::string& key=""); -private: +protected: action_info(const std::string& key); }; +struct UHD_API stream_cmd_action_info : public action_info +{ +public: + using sptr = std::shared_ptr; + + uhd::stream_cmd_t stream_cmd; + + //! Factory function + static sptr make(const uhd::stream_cmd_t::stream_mode_t stream_mode); + +private: + stream_cmd_action_info(const uhd::stream_cmd_t::stream_mode_t stream_mode); +}; + }} /* namespace uhd::rfnoc */ #endif /* INCLUDED_LIBUHD_RFNOC_ACTIONS_HPP */ -- cgit v1.2.3