Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

gr_block_detail.h

Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2004 Free Software Foundation, Inc.
00004  * 
00005  * This file is part of GNU Radio
00006  * 
00007  * GNU Radio is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2, or (at your option)
00010  * any later version.
00011  * 
00012  * GNU Radio is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more detail.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with GNU Radio; see the file COPYING.  If not, write to
00019  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00020  * Boston, MA 02111-1307, USA.
00021  */
00022 
00023 #ifndef INCLUDED_GR_BLOCK_DETAIL_H
00024 #define INCLUDED_GR_BLOCK_DETAIL_H
00025 
00026 #include <gr_runtime.h>
00027 #include <stdexcept>
00028 
00038 class gr_block_detail {
00039  public:
00040   ~gr_block_detail ();
00041 
00042   int ninputs () const { return d_ninputs; }
00043   int noutputs () const { return d_noutputs; }
00044   bool sink_p () const { return d_noutputs == 0; }
00045   bool source_p () const { return d_ninputs == 0; }
00046 
00047   void set_done (bool done);
00048   bool done () const { return d_done; }
00049 
00050   void set_input (unsigned int which, gr_buffer_reader_sptr reader);
00051   gr_buffer_reader_sptr input (unsigned int which)
00052   {
00053     if (which >= d_ninputs)
00054       throw std::invalid_argument ("gr_block_detail::input");
00055     return d_input[which];
00056   }
00057 
00058   void set_output (unsigned int which, gr_buffer_sptr buffer);
00059   gr_buffer_sptr output (unsigned int which)
00060   {
00061     if (which >= d_noutputs)
00062       throw std::invalid_argument ("gr_block_detail::output");
00063     return d_output[which];
00064   }
00065 
00069   void consume (int which_input, int how_many_items);
00070 
00074   void consume_each (int how_many_items);
00075 
00076   void produce_each (int how_many_items);
00077 
00078   // ----------------------------------------------------------------------------
00079 
00080  private:
00081   unsigned int                      d_ninputs;
00082   unsigned int                      d_noutputs;
00083   std::vector<gr_buffer_reader_sptr> d_input;
00084   std::vector<gr_buffer_sptr>       d_output;
00085   bool                              d_done;
00086     
00087   gr_block_detail (unsigned int ninputs, unsigned int noutputs);
00088 
00089   friend gr_block_detail_sptr 
00090   gr_make_block_detail (unsigned int ninputs, unsigned int noutputs);
00091 };
00092 
00093 gr_block_detail_sptr
00094 gr_make_block_detail (unsigned int ninputs, unsigned int noutputs);
00095 
00096 long
00097 gr_block_detail_ncurrently_allocated ();
00098 
00099 #endif /* INCLUDED_GR_BLOCK_DETAIL_H */

Generated on Sat Jul 8 17:04:51 2006 for GNU Radio 2.x by  doxygen 1.4.1