summaryrefslogtreecommitdiff
path: root/gr-utils/python/modtool/templates.py
diff options
context:
space:
mode:
authorBen Reynwar <ben@reynwar.net>2013-04-02 23:04:08 -0700
committerBen Reynwar <ben@reynwar.net>2013-04-02 23:04:08 -0700
commitc6dbde23b256a41b3d92cb4ad6b63287095d53c7 (patch)
tree71db12ea2e1667770c22568dcdf5e0857d5f1e59 /gr-utils/python/modtool/templates.py
parent22b70d0889ef3c51e27a31ee18d153093a55cbb8 (diff)
parent98758cbfa9a2aff714952d19e773bc370dfa2185 (diff)
Merged next into uninstalled import branch.
Diffstat (limited to 'gr-utils/python/modtool/templates.py')
-rw-r--r--gr-utils/python/modtool/templates.py79
1 files changed, 56 insertions, 23 deletions
diff --git a/gr-utils/python/modtool/templates.py b/gr-utils/python/modtool/templates.py
index 706017cc21..4f4469951c 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
@@ -275,7 +308,7 @@ ${str_to_python_comment($license)}
#if $blocktype in ('sync', 'sink', 'source')
#set $parenttype = 'gr.sync_block'
#else
-#set $parenttype = {'hier': 'gr.hier_block2', 'interpolator': 'gr.interp_block', 'decimator': 'gr.decim_block', 'general': 'gr.block'}[$blocktype]
+#set $parenttype = {'hier': 'gr.hier_block2', 'interpolator': 'gr.interp_block', 'decimator': 'gr.decim_block', 'general': 'gr.basic_block'}[$blocktype]
#end if
#if $blocktype != 'hier'
import numpy
@@ -338,7 +371,7 @@ class ${blockname}(${parenttype}):
def general_work(self, input_items, output_items):
output_items[0][:] = input_items[0]
- consume(0, len(input_items[0])
+ consume(0, len(input_items[0]))
\#self.consume_each(len(input_items[0]))
return len(output_items[0])
#stop
@@ -473,7 +506,7 @@ Templates['grc_xml'] = '''<?xml version="1.0"?>
* optional (set to 1 for optional inputs) -->
<sink>
<name>in</name>
- <type><!-- e.g. int, real, complex, byte, short, xxx_vector, ...--></type>
+ <type><!-- e.g. int, float, complex, byte, short, xxx_vector, ...--></type>
</sink>
<!-- Make one 'source' node per output. Sub-nodes:
@@ -483,7 +516,7 @@ Templates['grc_xml'] = '''<?xml version="1.0"?>
* optional (set to 1 for optional inputs) -->
<source>
<name>out</name>
- <type><!-- e.g. int, real, complex, byte, short, xxx_vector, ...--></type>
+ <type><!-- e.g. int, float, complex, byte, short, xxx_vector, ...--></type>
</source>
</block>
'''