00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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
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
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
00118
00119
00120
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