diff options
author | Martin Braun <martin.braun@kit.edu> | 2013-03-17 02:27:01 +0100 |
---|---|---|
committer | Martin Braun <martin.braun@kit.edu> | 2013-03-17 15:54:28 +0100 |
commit | 60a457d53dc8e4e102f65831ccaf1ef4a683fd9d (patch) | |
tree | 41910ae7231c5fbfe6295d136105d020cbfe1ecd /gr-utils | |
parent | 046f442fe430a7f8d9b7c1d48422e72aeeeeab13 (diff) |
modtool: added tagged_stream block as an option
Diffstat (limited to 'gr-utils')
-rw-r--r-- | gr-utils/python/modtool/code_generator.py | 1 | ||||
-rw-r--r-- | gr-utils/python/modtool/modtool_add.py | 4 | ||||
-rw-r--r-- | gr-utils/python/modtool/templates.py | 71 |
3 files changed, 55 insertions, 21 deletions
diff --git a/gr-utils/python/modtool/code_generator.py b/gr-utils/python/modtool/code_generator.py index 525b3d1e9a..fbe9aa92c2 100644 --- a/gr-utils/python/modtool/code_generator.py +++ b/gr-utils/python/modtool/code_generator.py @@ -37,6 +37,7 @@ class GRMTemplate(Cheetah.Template.Template): 'decimator': 'gr_sync_decimator', 'interpolator': 'gr_sync_interpolator', 'general': 'gr_block', + 'tagged_stream': 'gr_tagged_stream_block', 'hier': 'gr_hier_block2', 'noblock': ''} searchList['str_to_fancyc_comment'] = str_to_fancyc_comment diff --git a/gr-utils/python/modtool/modtool_add.py b/gr-utils/python/modtool/modtool_add.py index e1d61cf0fb..81103e460d 100644 --- a/gr-utils/python/modtool/modtool_add.py +++ b/gr-utils/python/modtool/modtool_add.py @@ -37,7 +37,7 @@ class ModToolAdd(ModTool): name = 'add' aliases = ('insert',) _block_types = ('sink', 'source', 'sync', 'decimator', 'interpolator', - 'general', 'hier', 'noblock') + 'general', 'tagged_stream', 'hier', 'noblock') def __init__(self): ModTool.__init__(self) self._add_cc_qa = False @@ -208,7 +208,7 @@ class ModToolAdd(ModTool): fname_h = self._info['blockname'] + '.h' fname_cc = self._info['blockname'] + '.cc' if self._info['blocktype'] in ('source', 'sink', 'sync', 'decimator', - 'interpolator', 'general', 'hier'): + 'interpolator', 'general', 'hier', 'tagged_stream'): fname_cc = self._info['blockname'] + '_impl.cc' self._write_tpl('block_impl_h', 'lib', self._info['blockname'] + '_impl.h') self._write_tpl('block_impl_cpp', 'lib', fname_cc) diff --git a/gr-utils/python/modtool/templates.py b/gr-utils/python/modtool/templates.py index 87eb9f470c..289903348d 100644 --- a/gr-utils/python/modtool/templates.py +++ b/gr-utils/python/modtool/templates.py @@ -57,25 +57,34 @@ namespace gr { class ${blockname}_impl : public ${blockname} { - private: + private: // Nothing to declare in this block. - public: +#if $blocktype == 'tagged_stream' + protected: + int calculate_output_stream_length(const gr_vector_int &ninput_items); + +#end if + public: ${blockname}_impl(${strip_default_values($arglist)}); ~${blockname}_impl(); + // Where all the action really happens #if $blocktype == 'general' void forecast (int noutput_items, gr_vector_int &ninput_items_required); - // Where all the action really happens int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); +#else if $blocktype == 'tagged_stream' + int work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); #else if $blocktype == 'hier' #silent pass #else - // Where all the action really happens int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); @@ -125,6 +134,8 @@ namespace gr { #set $decimation = ', <+decimation+>' #else if $blocktype == 'interpolator' #set $decimation = ', <+interpolation+>' +#else if $blocktype == 'tagged_stream' +#set $decimation = ', <+len_tag_key+>' #else #set $decimation = '' #end if @@ -186,6 +197,28 @@ namespace gr { // Tell runtime system how many output items we produced. return noutput_items; } +#else if $blocktype == 'tagged_stream' + int + ${blockname}_impl::calculate_output_stream_length(const gr_vector_int &ninput_items) + { + int noutput_items = /* <+set this+> */; + return noutput_items ; + } + + int + ${blockname}_impl::work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const float *in = (const float *) input_items[0]; + float *out = (float *) output_items[0]; + + // Do <+signal processing+> + + // Tell runtime system how many output items we produced. + return noutput_items; + } #else if $blocktype == 'hier' #silent pass #else @@ -230,9 +263,9 @@ namespace gr { */ class ${modname.upper()}_API $blockname { - ${blockname}(${arglist}); - ~${blockname}(); - private: + ${blockname}(${arglist}); + ~${blockname}(); + private: }; #else /*! @@ -242,18 +275,18 @@ namespace gr { */ class ${modname.upper()}_API ${blockname} : virtual public $grblocktype { - public: - typedef boost::shared_ptr<${blockname}> sptr; - - /*! - * \\brief Return a shared_ptr to a new instance of ${modname}::${blockname}. - * - * To avoid accidental use of raw pointers, ${modname}::${blockname}'s - * constructor is in a private implementation - * class. ${modname}::${blockname}::make is the public interface for - * creating new instances. - */ - static sptr make($arglist); + public: + typedef boost::shared_ptr<${blockname}> sptr; + + /*! + * \\brief Return a shared_ptr to a new instance of ${modname}::${blockname}. + * + * To avoid accidental use of raw pointers, ${modname}::${blockname}'s + * constructor is in a private implementation + * class. ${modname}::${blockname}::make is the public interface for + * creating new instances. + */ + static sptr make($arglist); }; #end if |