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

gr_block.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 details.
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_H
00024 #define INCLUDED_GR_BLOCK_H
00025 
00026 #include <gr_runtime.h>
00027 #include <string>
00028 
00052 class gr_block {
00053 
00054  public:
00055   
00056   virtual ~gr_block ();
00057   
00058   std::string name () const { return d_name; }
00059   gr_io_signature_sptr input_signature () const  { return d_input_signature; }
00060   gr_io_signature_sptr output_signature () const { return d_output_signature; }
00061   long unique_id () const { return d_unique_id; }
00062 
00063   // ----------------------------------------------------------------
00064   //            override these to define your behavior
00065   // ----------------------------------------------------------------
00066 
00074   virtual void forecast (int noutput_items, gr_vector_int &ninput_items_required);
00075 
00090   virtual int general_work (int noutput_items,
00091                             gr_vector_int &ninput_items,
00092                             gr_vector_const_void_star &input_items,
00093                             gr_vector_void_star &output_items) = 0;
00094 
00095 
00096   // ----------------------------------------------------------------
00097 
00105   void set_output_multiple (int multiple);
00106   int  output_multiple () const { return d_output_multiple; }
00107 
00111   void consume (int which_input, int how_many_items);
00112 
00116   void consume_each (int how_many_items);
00117 
00118   /*
00119    * \brief Set the approximate output rate / input rate
00120    *
00121    * Provide a hint to the buffer allocator and scheduler.
00122    * The default relative_rate is 1.0
00123    *
00124    * decimators have relative_rates < 1.0
00125    * interpolators have relative_rates > 1.0
00126    */
00127   void  set_relative_rate (double relative_rate);
00128 
00132   double relative_rate () const { return d_relative_rate; }
00133 
00134 
00135   // ----------------------------------------------------------------------------
00136 
00137  private:
00138 
00139   std::string           d_name;
00140   gr_io_signature_sptr  d_input_signature;
00141   gr_io_signature_sptr  d_output_signature;
00142   int                   d_output_multiple;
00143   double                d_relative_rate;        // approx output_rate / input_rate
00144   gr_block_detail_sptr  d_detail;               // implementation details
00145   long                  d_unique_id;            // convenient for debugging
00146   
00147  protected:
00148 
00149   gr_block (const std::string &name,
00150              gr_io_signature_sptr input_signature,
00151              gr_io_signature_sptr output_signature);
00152 
00153   // These are really only for internal use, but leaving them public avoids
00154   // having to work up an ever-varying list of friends
00155 
00156  public:
00157   gr_block_detail_sptr detail () const { return d_detail; }
00158   void set_detail (gr_block_detail_sptr detail) { d_detail = detail; }
00159 };
00160 
00161 long gr_block_ncurrently_allocated ();
00162 
00163 #endif /* INCLUDED_GR_BLOCK_H */

Generated on Mon Jul 12 15:00:42 2004 for GNU Radio 2.x by doxygen 1.3.3