From 2a1966462484cf1cb25ea7802cc0d9a8e80096c9 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 21 Oct 2012 15:53:11 -0700 Subject: getting API read for PMCs Moved tags API stuff into gr block, specifically the get tags filters. The block class now has a simplified interface for dealing with input and output tags. Dummy typedefs for PMCs Tag class now uses PMCs --- include/gnuradio/block.hpp | 31 +++++++------------------------ include/gnuradio/gr_block.h | 20 ++++++++++++++++++++ include/gnuradio/gr_tags.h | 23 ++++++++++++++++++++++- include/gnuradio/tags.hpp | 35 ++++++++++++++++++++--------------- 4 files changed, 69 insertions(+), 40 deletions(-) (limited to 'include') diff --git a/include/gnuradio/block.hpp b/include/gnuradio/block.hpp index 23274b1..bcce34a 100644 --- a/include/gnuradio/block.hpp +++ b/include/gnuradio/block.hpp @@ -22,6 +22,7 @@ #include #include #include +#include //iterator range namespace gnuradio { @@ -214,32 +215,14 @@ struct GRAS_API Block : Element void set_tag_propagation_policy(tag_propagation_policy_t p); - void add_item_tag( - const size_t which_output, const Tag &tag - ); - - void add_item_tag( - const size_t which_output, - uint64_t abs_offset, - const pmt::pmt_t &key, - const pmt::pmt_t &value, - const pmt::pmt_t &srcid=pmt::PMT_F - ); + //! Send a tag to the downstream on the given output port + void post_output_tag(const size_t which_output, const Tag &tag); - void get_tags_in_range( - std::vector &tags, - const size_t which_input, - uint64_t abs_start, - uint64_t abs_end - ); + //! Iterator return type get_input_tags - stl and boost compliant + typedef boost::iterator_range::const_iterator> TagIter; - void get_tags_in_range( - std::vector &tags, - const size_t which_input, - uint64_t abs_start, - uint64_t abs_end, - const pmt::pmt_t &key - ); + //! Get an iterator of item tags for the given input + TagIter get_input_tags(const size_t which_input = 0); /******************************************************************* * Work related routines from basic block diff --git a/include/gnuradio/gr_block.h b/include/gnuradio/gr_block.h index 7328dd1..8e0c40e 100644 --- a/include/gnuradio/gr_block.h +++ b/include/gnuradio/gr_block.h @@ -80,6 +80,26 @@ struct GRAS_API gr_block : gnuradio::Block gr_vector_void_star &output_items ); + void add_item_tag( + const size_t which_output, const gr_tag_t &tag + ); + + void add_item_tag( + const size_t which_output, + uint64_t abs_offset, + const pmt::pmt_t &key, + const pmt::pmt_t &value, + const pmt::pmt_t &srcid=pmt::PMT_F + ); + + void get_tags_in_range( + std::vector &tags, + const size_t which_input, + uint64_t abs_start, + uint64_t abs_end, + const pmt::pmt_t &key = pmt::pmt_t() + ); + unsigned history(void) const; void set_history(unsigned history); diff --git a/include/gnuradio/gr_tags.h b/include/gnuradio/gr_tags.h index e4c9508..cb268da 100644 --- a/include/gnuradio/gr_tags.h +++ b/include/gnuradio/gr_tags.h @@ -19,6 +19,27 @@ #include -typedef gnuradio::Tag gr_tag_t; +struct GRAS_API gr_tag_t +{ + + //! the item \p tag occurred at (as a uint64_t) + uint64_t offset; + + //! the key of \p tag (as a PMT symbol) + pmt::pmt_t key; + + //! the value of \p tag (as a PMT) + pmt::pmt_t value; + + //! the source ID of \p tag (as a PMT) + pmt::pmt_t srcid; + + //! Comparison function to test which tag, \p x or \p y, came first in time + static inline bool offset_compare( + const gr_tag_t &x, const gr_tag_t &y + ){ + return x.offset < y.offset; + } +}; #endif /*INCLUDED_GR_TAGS_H*/ diff --git a/include/gnuradio/tags.hpp b/include/gnuradio/tags.hpp index d8414d8..c8eafba 100644 --- a/include/gnuradio/tags.hpp +++ b/include/gnuradio/tags.hpp @@ -18,34 +18,39 @@ #define INCLUDED_GNURADIO_TAGS_HPP #include +#include + +//TODO -- this is a stub for the PMC libray #include +typedef pmt::pmt_t PMC; +typedef pmt::pmt_t PMCC; namespace gnuradio { -struct GRAS_API Tag +struct GRAS_API Tag : boost::less_than_comparable { + //! Make an empty tag with null members + Tag(void); - //! the item \p tag occurred at (as a uint64_t) - uint64_t offset; + //! Make a tag from parameters to initialize the members + Tag(const uint64_t &offset, const PMCC &key, const PMCC &value, const PMCC &srcid = PMCC()); - //! the key of \p tag (as a PMT symbol) - pmt::pmt_t key; + //! the absolute item count associated with this tag + uint64_t offset; - //! the value of \p tag (as a PMT) - pmt::pmt_t value; + //! A symbolic name identifying the type of tag + PMCC key; - //! the source ID of \p tag (as a PMT) - pmt::pmt_t srcid; + //! The value of this tag -> the sample metadata + PMCC value; - //! Comparison function to test which tag, \p x or \p y, came first in time - static inline bool offset_compare( - const Tag &x, const Tag &y - ){ - return x.offset < y.offset; - } + //! The optional source ID -> something unique + PMCC srcid; }; +GRAS_API bool operator<(const Tag &lhs, const Tag &rhs); + } //namespace gnuradio #endif /*INCLUDED_GNURADIO_TAGS_HPP*/ -- cgit From cd42f1c9d373639880503ee97c041d1f0dcd974f Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 27 Oct 2012 19:36:47 -0700 Subject: added support for the real PMC type (stub removed) need to create conversions still... --- include/gnuradio/gr_tags.h | 3 ++- include/gnuradio/tags.hpp | 9 +++------ 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/gnuradio/gr_tags.h b/include/gnuradio/gr_tags.h index cb268da..ca45170 100644 --- a/include/gnuradio/gr_tags.h +++ b/include/gnuradio/gr_tags.h @@ -17,7 +17,8 @@ #ifndef INCLUDED_GR_TAGS_H #define INCLUDED_GR_TAGS_H -#include +#include +#include struct GRAS_API gr_tag_t { diff --git a/include/gnuradio/tags.hpp b/include/gnuradio/tags.hpp index c8eafba..bc83709 100644 --- a/include/gnuradio/tags.hpp +++ b/include/gnuradio/tags.hpp @@ -19,11 +19,8 @@ #include #include - -//TODO -- this is a stub for the PMC libray -#include -typedef pmt::pmt_t PMC; -typedef pmt::pmt_t PMCC; +#include +#include namespace gnuradio { @@ -37,7 +34,7 @@ struct GRAS_API Tag : boost::less_than_comparable Tag(const uint64_t &offset, const PMCC &key, const PMCC &value, const PMCC &srcid = PMCC()); //! the absolute item count associated with this tag - uint64_t offset; + boost::uint64_t offset; //! A symbolic name identifying the type of tag PMCC key; -- cgit