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

gr_test.h

Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2006 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_TEST_H
00024 #define INCLUDED_GR_TEST_H
00025 
00026 #include <gr_block.h>
00027 #include <string>
00028 #include "gr_test_types.h"
00029 
00030 class gr_test;
00031 typedef boost::shared_ptr<gr_test> gr_test_sptr;
00032 
00033 // public constructor
00034 gr_test_sptr gr_make_test (const std::string &name=std::string("gr_test"),
00035         int min_inputs=1, int max_inputs=1, unsigned int sizeof_input_item=1,
00036         int min_outputs=1, int max_outputs=1, unsigned int sizeof_output_item=1,
00037         unsigned int history=1,unsigned int output_multiple=1,double relative_rate=1.0,
00038         bool fixed_rate=true,gr_consume_type_t cons_type=CONSUME_NOUTPUT_ITEMS, gr_produce_type_t prod_type=PRODUCE_NOUTPUT_ITEMS);
00039 
00058 class gr_test : public gr_block {
00059 
00060  public:
00061   
00062   ~gr_test (){}
00063   
00064 int general_work (int noutput_items,
00065                             gr_vector_int &ninput_items,
00066                             gr_vector_const_void_star &input_items,
00067                             gr_vector_void_star &output_items);
00068   // ----------------------------------------------------------------
00069   //            override these to define your behavior
00070   // ----------------------------------------------------------------
00071 
00082    void forecast (int noutput_items,
00083                          gr_vector_int &ninput_items_required)
00084    {
00085      unsigned ninputs = ninput_items_required.size ();
00086      for (unsigned i = 0; i < ninputs; i++)
00087        ninput_items_required[i] = (int)((double)noutput_items / relative_rate()) + (int)history();
00088    }
00089 
00090 
00098    void set_check_topology (bool check_topology){ d_check_topology=check_topology;}
00099 
00113   bool check_topology (int ninputs, int noutputs) { return d_check_topology;}
00114 
00115   // ----------------------------------------------------------------
00116   /*
00117    * The following two methods provide special case info to the
00118    * scheduler in the event that a block has a fixed input to output
00119    * ratio.  gr_sync_block, gr_sync_decimator and gr_sync_interpolator
00120    * override these.  If you're fixed rate, subclass one of those.
00121    */
00127   int fixed_rate_ninput_to_noutput(int ninput) { return (int)((double)ninput/relative_rate()); }
00128 
00133   int fixed_rate_noutput_to_ninput(int noutput)  { return (int)((double)noutput*relative_rate()); }
00134 
00139   void set_fixed_rate_public(bool fixed_rate){ set_fixed_rate(fixed_rate);}
00140 
00146   void set_consume_type (gr_consume_type_t cons_type) { d_consume_type=cons_type;}
00147 
00153   void set_consume_limit (unsigned int limit) { d_min_consume=limit; d_max_consume=limit;}
00154 
00160   void set_produce_type (gr_produce_type_t prod_type) { d_produce_type=prod_type;}
00161 
00167   void set_produce_limit (unsigned int limit) { d_min_produce=limit; d_max_produce=limit;}
00168 
00169   // ----------------------------------------------------------------------------
00170 
00171 
00172   
00173  protected:
00174   unsigned int d_sizeof_input_item;
00175   unsigned int d_sizeof_output_item;
00176   bool d_check_topology;
00177   char d_temp;
00178   gr_consume_type_t d_consume_type;
00179   int d_min_consume;
00180   int d_max_consume;
00181   gr_produce_type_t d_produce_type;
00182   int d_min_produce;
00183   int d_max_produce;
00184   gr_test (const std::string &name,int min_inputs, int max_inputs, unsigned int sizeof_input_item,
00185                                    int min_outputs, int max_outputs, unsigned int sizeof_output_item,
00186                                    unsigned int history,unsigned int output_multiple,double relative_rate,
00187                                    bool fixed_rate,gr_consume_type_t cons_type, gr_produce_type_t prod_type);
00188 
00189 
00190 
00191   friend gr_test_sptr gr_make_test (const std::string &name,int min_inputs, int max_inputs, unsigned int sizeof_input_item,
00192                                    int min_outputs, int max_outputs, unsigned int sizeof_output_item,
00193                                    unsigned int history,unsigned int output_multiple,double relative_rate,
00194                                    bool fixed_rate,gr_consume_type_t cons_type, gr_produce_type_t prod_type);
00195 };
00196 
00197 
00198 
00199 #endif /* INCLUDED_GR_TEST_H */

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