Added reset method to gr_head and gr_vector_sink. This allows graphs
authoreb <eb@221aa14e-8319-0410-a670-987f0aec2ac5>
Sat, 15 Aug 2009 18:32:56 +0000 (18:32 +0000)
committereb <eb@221aa14e-8319-0410-a670-987f0aec2ac5>
Sat, 15 Aug 2009 18:32:56 +0000 (18:32 +0000)
containing these blocks to be run more than once with user control
over when the reset of the counter and sink occurs.

git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@11599 221aa14e-8319-0410-a670-987f0aec2ac5

gnuradio-core/src/lib/general/gr_head.cc
gnuradio-core/src/lib/general/gr_head.h
gnuradio-core/src/lib/general/gr_head.i
gnuradio-core/src/lib/gengen/gr_vector_sink_X.h.t
gnuradio-core/src/lib/gengen/gr_vector_sink_X.i.t

index 94a00cc68df2bfc38f57d9278506201252521934..01035ffcdac02ad0ef15641921b2f7850d564221 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2004 Free Software Foundation, Inc.
+ * Copyright 2004,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -35,10 +35,10 @@ gr_head::gr_head (size_t sizeof_stream_item, int nitems)
 {
 }
 
-gr_block_sptr
+gr_head_sptr
 gr_make_head (size_t sizeof_stream_item, int nitems)
 {
-  return gr_block_sptr (new gr_head (sizeof_stream_item, nitems));
+  return gnuradio::get_initial_sptr(new gr_head (sizeof_stream_item, nitems));
 }
 
 int
index cd97d63994c0333b958ce6515248449d45376936..430d5f8b9644df8ff7b5d06d98bdc3f88a15994c 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2004 Free Software Foundation, Inc.
+ * Copyright 2004,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -26,6 +26,9 @@
 #include <gr_sync_block.h>
 #include <stddef.h>                    // size_t
 
+class gr_head;
+typedef boost::shared_ptr<gr_head> gr_head_sptr;
+
 /*!
  * \brief copies the first N items to the output then signals done
  * \ingroup slicedice_blk
@@ -35,7 +38,7 @@
 
 class gr_head : public gr_sync_block
 {
-  friend gr_block_sptr gr_make_head (size_t sizeof_stream_item, int nitems);
+  friend gr_head_sptr gr_make_head (size_t sizeof_stream_item, int nitems);
   gr_head (size_t sizeof_stream_item, int nitems);
 
   int  d_nitems;
@@ -45,9 +48,11 @@ class gr_head : public gr_sync_block
   int work (int noutput_items,
                 gr_vector_const_void_star &input_items,
                 gr_vector_void_star &output_items);
+
+  void reset() { d_ncopied_items = 0; }
 };
 
-gr_block_sptr
+gr_head_sptr
 gr_make_head (size_t sizeof_stream_item, int nitems);
 
 
index 324bb08ecbd1b2e7f6b0bb072b336f1cbadda3df..2a88b885f010dd041b69d48f58daf5a7e6bfcd0e 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2004 Free Software Foundation, Inc.
+ * Copyright 2004,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
  * Boston, MA 02110-1301, USA.
  */
 
-%ignore gr_head;
+GR_SWIG_BLOCK_MAGIC(gr,head);
+
+gr_head_sptr gr_make_head(size_t sizeof_stream_item, int nitems);
+
 class gr_head : public gr_block {
-  friend gr_block_sptr gr_make_head (size_t sizeof_stream_item, int nitems);
-  gr_head (size_t sizeof_stream_item, int nitems);
+  gr_head();
+public:
+  void reset();
 };
 
-%rename(head) gr_make_head;
-gr_block_sptr gr_make_head (size_t sizeof_stream_item, int nitems);
index b5fdf88fda24be741f5b59a2cd199f1da4831f44..7ba5ee9e93903fe04fce7d55136fb1696a79f7f2 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2004,2008 Free Software Foundation, Inc.
+ * Copyright 2004,2008,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -50,7 +50,8 @@ class @NAME@ : public gr_sync_block {
                    gr_vector_const_void_star &input_items,
                    gr_vector_void_star &output_items);
 
-  void clear() {d_data.clear();}
+  void reset() {d_data.clear();}
+  void clear() {reset(); }             // deprecated
   std::vector<@TYPE@> data () const;
 };
 
index 22d6faa1aa73bb8789e1a9d131bb20b1002b9ff7..a49276a995662a1633531c5ce5e099834642b524 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2004,2008 Free Software Foundation, Inc.
+ * Copyright 2004,2008,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -32,7 +32,8 @@ class @NAME@ : public gr_sync_block {
   @NAME@ (int vlen);
 
  public:
-  void clear() {d_data.clear();}
+  void clear();                        // deprecated
+  void reset();
   std::vector<@TYPE@> data () const;
 };