From 60a457d53dc8e4e102f65831ccaf1ef4a683fd9d Mon Sep 17 00:00:00 2001
From: Martin Braun <martin.braun@kit.edu>
Date: Sun, 17 Mar 2013 02:27:01 +0100
Subject: modtool: added tagged_stream block as an option

---
 gr-utils/python/modtool/templates.py | 71 ++++++++++++++++++++++++++----------
 1 file changed, 52 insertions(+), 19 deletions(-)

(limited to 'gr-utils/python/modtool/templates.py')

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
@@ -183,6 +194,28 @@ namespace gr {
         // each input stream.
         consume_each (noutput_items);
 
+        // 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;
     }
@@ -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
 
-- 
cgit v1.2.3