diff options
author | eb <eb@221aa14e-8319-0410-a670-987f0aec2ac5> | 2009-08-15 18:32:56 +0000 |
---|---|---|
committer | eb <eb@221aa14e-8319-0410-a670-987f0aec2ac5> | 2009-08-15 18:32:56 +0000 |
commit | cdecd3aa94c0ed24312c869c27b3cbd01998004e (patch) | |
tree | 41cea512ed2f77b7ee861c85362b466aa4cdd703 /gnuradio-core/src/lib | |
parent | 1579bab2e5840e8f7e7918b7cabf250ca4fd259a (diff) |
Added reset method to gr_head and gr_vector_sink. This allows graphs
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
Diffstat (limited to 'gnuradio-core/src/lib')
-rw-r--r-- | gnuradio-core/src/lib/general/gr_head.cc | 6 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_head.h | 11 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_head.i | 14 | ||||
-rw-r--r-- | gnuradio-core/src/lib/gengen/gr_vector_sink_X.h.t | 5 | ||||
-rw-r--r-- | gnuradio-core/src/lib/gengen/gr_vector_sink_X.i.t | 5 |
5 files changed, 25 insertions, 16 deletions
diff --git a/gnuradio-core/src/lib/general/gr_head.cc b/gnuradio-core/src/lib/general/gr_head.cc index 94a00cc68d..01035ffcda 100644 --- a/gnuradio-core/src/lib/general/gr_head.cc +++ b/gnuradio-core/src/lib/general/gr_head.cc @@ -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 diff --git a/gnuradio-core/src/lib/general/gr_head.h b/gnuradio-core/src/lib/general/gr_head.h index cd97d63994..430d5f8b96 100644 --- a/gnuradio-core/src/lib/general/gr_head.h +++ b/gnuradio-core/src/lib/general/gr_head.h @@ -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); diff --git a/gnuradio-core/src/lib/general/gr_head.i b/gnuradio-core/src/lib/general/gr_head.i index 324bb08ecb..2a88b885f0 100644 --- a/gnuradio-core/src/lib/general/gr_head.i +++ b/gnuradio-core/src/lib/general/gr_head.i @@ -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 * @@ -20,11 +20,13 @@ * 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); diff --git a/gnuradio-core/src/lib/gengen/gr_vector_sink_X.h.t b/gnuradio-core/src/lib/gengen/gr_vector_sink_X.h.t index b5fdf88fda..7ba5ee9e93 100644 --- a/gnuradio-core/src/lib/gengen/gr_vector_sink_X.h.t +++ b/gnuradio-core/src/lib/gengen/gr_vector_sink_X.h.t @@ -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; }; diff --git a/gnuradio-core/src/lib/gengen/gr_vector_sink_X.i.t b/gnuradio-core/src/lib/gengen/gr_vector_sink_X.i.t index 22d6faa1aa..a49276a995 100644 --- a/gnuradio-core/src/lib/gengen/gr_vector_sink_X.i.t +++ b/gnuradio-core/src/lib/gengen/gr_vector_sink_X.i.t @@ -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; }; |