aboutsummaryrefslogtreecommitdiffstats
path: root/host/include
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2019-05-31 21:18:15 -0700
committerMartin Braun <martin.braun@ettus.com>2019-11-26 11:49:18 -0800
commit15c058015f56cfcd0e42cf6779a6e6ef6e0da911 (patch)
tree82a4c9311fea7c2eafab371e00bfef00e05596b8 /host/include
parent73171698b55133aaeab461781476b02c4416da8f (diff)
downloaduhd-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/include')
-rw-r--r--host/include/uhd/rfnoc/actions.hpp26
1 files changed, 20 insertions, 6 deletions
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 <uhd/config.hpp>
+#include <uhd/rfnoc/defaults.hpp>
+#include <uhd/types/stream_cmd.hpp>
#include <string>
#include <vector>
#include <memory>
@@ -24,6 +26,8 @@ namespace uhd { namespace rfnoc {
struct UHD_API action_info
{
public:
+ virtual ~action_info() {}
+
using sptr = std::shared_ptr<action_info>;
//! A unique counter for this action
const size_t id;
@@ -34,16 +38,26 @@ public:
std::vector<uint8_t> payload;
//! Factory function
- static sptr make(const std::string& key="")
- {
- //return std::make_shared<action_info>(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<stream_cmd_action_info>;
+
+ 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 */