GNU Radio 2.x: gr_block class Reference

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

# gr_block Class Reference
[Signal Processing Blocks]

`#include <gr_block.h>`

Inheritance diagram for gr_block:

[legend]
Collaboration diagram for gr_block:

[legend]
List of all members.

## Detailed Description

The abstract base class for all signal processing blocks.

Blocks have a set of input streams and output streams. The input_signature and output_signature define the number of input streams and output streams respectively, and the type of the data items in each stream.

Although blocks may consume data on each input stream at a different rate, all outputs streams must produce data at the same rate. That rate may be different from any of the input rates.

User derived blocks override two methods, forecast and general_work, to implement their signal processing behavior. forecast is called by the system scheduler to determine how many items are required on each input stream in order to produce a given number of output items.

general_work is called to perform the signal processing in the block. It reads the input items and writes the output items.

## Public Member Functions
virtual | ~gr_block ()
std::string | name () const
gr_io_signature_sptr | input_signature () const
gr_io_signature_sptr | output_signature () const
long | unique_id () const
virtual void | forecast (int noutput_items, gr_vector_int &ninput_items_required)
| Estimate input requirements given output request.
virtual int | general_work (int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)=0
| compute output items from input items
virtual bool | check_topology (int ninputs, int noutputs)
| Confirm that ninputs and noutputs is an acceptable combination.
void | set_output_multiple (int multiple)
| Constrain the noutput_items argument passed to forecast and general_work.
int | output_multiple () const
void | consume (int which_input, int how_many_items)
| Tell the scheduler `how_many_items` of input stream `which_input` were consumed.
void | consume_each (int how_many_items)
| Tell the scheduler `how_many_items` were consumed on each input stream.
void | set_relative_rate (double relative_rate)
| Set the approximate output rate / input rate.
double | relative_rate () const
| return the approximate output rate / input rate
gr_block_detail_sptr | detail () const
void | set_detail (gr_block_detail_sptr detail)
## Protected Member Functions
| gr_block (const std::string &name, gr_io_signature_sptr input_signature, gr_io_signature_sptr output_signature)

## Constructor & Destructor Documentation

gr_block::~gr_block | ( |  | ) | `[virtual]`

gr_block::gr_block | ( | const std::string & | name,
|  | gr_io_signature_sptr | input_signature,
|  | gr_io_signature_sptr | output_signature
| ) | `[protected]`

## Member Function Documentation

bool gr_block::check_topology | ( | int | ninputs,
|  | int | noutputs
| ) | `[virtual]`

  | Confirm that ninputs and noutputs is an acceptable combination. Parameters:
  ninputs | number of input streams connected
  noutputs | number of output streams connected
Returns: true if this is a valid configuration for this block. This function is called by the runtime system whenever the topology changes. Most classes do not need to override this. This check is in addition to the constraints specified by the input and output gr_io_signatures. Reimplemented in gr_oscope_sink_f.

void gr_block::consume | ( | int | which_input,
|  | int | how_many_items
| ) |

| Tell the scheduler `how_many_items` of input stream `which_input` were consumed.

void gr_block::consume_each | ( | int | how_many_items | ) |

| Tell the scheduler `how_many_items` were consumed on each input stream.

gr_block_detail_sptr gr_block::detail | ( |  | ) | const`[inline]`

void gr_block::forecast | ( | int | noutput_items,
|  | gr_vector_int & | ninput_items_required
| ) | `[virtual]`

| Estimate input requirements given output request. Given a request to product noutput_items, estimate the number of data items required on each input stream. The estimate doesn't have to be exact, but should be close. Reimplemented in gr_sync_block, gr_sync_decimator, and gr_sync_interpolator.

virtual int gr_block::general_work | ( | int | noutput_items,
|  | gr_vector_int & | ninput_items,
|  | gr_vector_const_void_star & | input_items,
|  | gr_vector_void_star & | output_items
| ) | `[pure virtual]`

  | compute output items from input items Parameters:
  noutput_items | number of output items to write on each output stream
  ninput_items | number of input items available on each input stream
  input_items | vector of pointers to the input items, one entry per input stream
  output_items | vector of pointers to the output items, one entry per output stream
Returns: number of items actually written to each output stream, or -1 on EOF. It is OK to return a value less than noutput_items. -1 <= return value <= noutput_items general_work must call consume or consume_each to indicate how many items were consumed on each input stream. Implemented in gr_keep_one_in_n, gr_nop, gr_simple_correlator, gr_simple_framer, gr_sync_block, gr_sync_decimator, and gr_sync_interpolator.

gr_io_signature_sptr gr_block::input_signature | ( |  | ) | const`[inline]`

std::string gr_block::name | ( |  | ) | const`[inline]`

int gr_block::output_multiple | ( |  | ) | const`[inline]`

gr_io_signature_sptr gr_block::output_signature | ( |  | ) | const`[inline]`

double gr_block::relative_rate | ( |  | ) | const`[inline]`

| return the approximate output rate / input rate

void gr_block::set_detail | ( | gr_block_detail_sptr | detail | ) | `[inline]`

void gr_block::set_output_multiple | ( | int | multiple | ) |

  | Constrain the noutput_items argument passed to forecast and general_work. set_output_multiple causes the scheduler to ensure that the noutput_items argument passed to forecast and general_work will be an integer multiple of Parameters:
  multiple | The default value of output multiple is 1.

void gr_block::set_relative_rate | ( | double | relative_rate | ) |

| Set the approximate output rate / input rate. Provide a hint to the buffer allocator and scheduler. The default relative_rate is 1.0 decimators have relative_rates < 1.0 interpolators have relative_rates > 1.0

long gr_block::unique_id | ( |  | ) | const`[inline]`

The documentation for this class was generated from the following files:

- gr_block.h
- gr_block.cc