Go to the documentation of this file.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
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 class gr_test : public gr_block {
00054
00055 public:
00056
00057 ~gr_test (){}
00058
00059 int general_work (int noutput_items,
00060 gr_vector_int &ninput_items,
00061 gr_vector_const_void_star &input_items,
00062 gr_vector_void_star &output_items);
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077 void forecast (int noutput_items,
00078 gr_vector_int &ninput_items_required)
00079 {
00080 unsigned ninputs = ninput_items_required.size ();
00081 for (unsigned i = 0; i < ninputs; i++)
00082 ninput_items_required[i] = (int)((double)noutput_items / relative_rate()) + (int)history();
00083 }
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093 void set_check_topology (bool check_topology){ d_check_topology=check_topology;}
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108 bool check_topology (int ninputs, int noutputs) { return d_check_topology;}
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122 int fixed_rate_ninput_to_noutput(int ninput) { return (int)((double)ninput/relative_rate()); }
00123
00124
00125
00126
00127
00128 int fixed_rate_noutput_to_ninput(int noutput) { return (int)((double)noutput*relative_rate()); }
00129
00130
00131
00132
00133
00134 void set_fixed_rate_public(bool fixed_rate){ set_fixed_rate(fixed_rate);}
00135
00136
00137
00138
00139
00140
00141 void set_consume_type (gr_consume_type_t cons_type) { d_consume_type=cons_type;}
00142
00143
00144
00145
00146
00147
00148 void set_consume_limit (unsigned int limit) { d_min_consume=limit; d_max_consume=limit;}
00149
00150
00151
00152
00153
00154
00155 void set_produce_type (gr_produce_type_t prod_type) { d_produce_type=prod_type;}
00156
00157
00158
00159
00160
00161
00162 void set_produce_limit (unsigned int limit) { d_min_produce=limit; d_max_produce=limit;}
00163
00164
00165
00166
00167
00168 protected:
00169 unsigned int d_sizeof_input_item;
00170 unsigned int d_sizeof_output_item;
00171 bool d_check_topology;
00172 char d_temp;
00173 gr_consume_type_t d_consume_type;
00174 int d_min_consume;
00175 int d_max_consume;
00176 gr_produce_type_t d_produce_type;
00177 int d_min_produce;
00178 int d_max_produce;
00179 gr_test (const std::string &name,int min_inputs, int max_inputs, unsigned int sizeof_input_item,
00180 int min_outputs, int max_outputs, unsigned int sizeof_output_item,
00181 unsigned int history,unsigned int output_multiple,double relative_rate,
00182 bool fixed_rate,gr_consume_type_t cons_type, gr_produce_type_t prod_type);
00183
00184
00185
00186 friend gr_test_sptr gr_make_test (const std::string &name,int min_inputs, int max_inputs, unsigned int sizeof_input_item,
00187 int min_outputs, int max_outputs, unsigned int sizeof_output_item,
00188 unsigned int history,unsigned int output_multiple,double relative_rate,
00189 bool fixed_rate,gr_consume_type_t cons_type, gr_produce_type_t prod_type);
00190 };
00191
00192
00193
00194 #endif