GNU Radio 3.4.0 C++ API
gr_basic_block Class Reference

The abstract base class for all signal processing blocks.Basic blocks are the bare abstraction of an entity that has a name, a set of inputs and outputs, and a message queue. These are never instantiated directly; rather, this is the abstract parent class of both gr_hier_block, which is a recursive container, and gr_block, which implements actual signal processing functions. More...

#include <gr_basic_block.h>

Inheritance diagram for gr_basic_block:

List of all members.

Public Member Functions

virtual ~gr_basic_block ()
long unique_id () const
std::string name () const
gr_io_signature_sptr input_signature () const
gr_io_signature_sptr output_signature () const
gr_basic_block_sptr to_basic_block ()
virtual bool check_topology (int ninputs, int noutputs)
 Confirm that ninputs and noutputs is an acceptable combination.
template<typename T >
void set_msg_handler (T msg_handler)
 Set the callback that is fired when messages are available.

Protected Types

enum  vcolor { WHITE, GREY, BLACK }

Protected Member Functions

 gr_basic_block (void)
 gr_basic_block (const std::string &name, gr_io_signature_sptr input_signature, gr_io_signature_sptr output_signature)
 Protected constructor prevents instantiation by non-derived classes.
void set_input_signature (gr_io_signature_sptr iosig)
 may only be called during constructor
void set_output_signature (gr_io_signature_sptr iosig)
 may only be called during constructor
void set_color (vcolor color)
 Allow the flowgraph to set for sorting and partitioning.
vcolor color () const

Protected Attributes

std::string d_name
gr_io_signature_sptr d_input_signature
gr_io_signature_sptr d_output_signature
long d_unique_id
vcolor d_color

Friends

class gr_flowgraph
class gr_flat_flowgraph
class gr_tpb_thread_body

Detailed Description

The abstract base class for all signal processing blocks.

Basic blocks are the bare abstraction of an entity that has a name, a set of inputs and outputs, and a message queue. These are never instantiated directly; rather, this is the abstract parent class of both gr_hier_block, which is a recursive container, and gr_block, which implements actual signal processing functions.


Member Enumeration Documentation

enum gr_basic_block::vcolor [protected]
Enumerator:
WHITE 
GREY 
BLACK 

Constructor & Destructor Documentation

gr_basic_block::gr_basic_block ( void  ) [inline, protected]
gr_basic_block::gr_basic_block ( const std::string &  name,
gr_io_signature_sptr  input_signature,
gr_io_signature_sptr  output_signature 
) [protected]

Protected constructor prevents instantiation by non-derived classes.

virtual gr_basic_block::~gr_basic_block ( ) [virtual]

Member Function Documentation

virtual bool gr_basic_block::check_topology ( int  ninputs,
int  noutputs 
) [inline, virtual]

Confirm that ninputs and noutputs is an acceptable combination.

Parameters:
ninputsnumber of input streams connected
noutputsnumber 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_pfb_clock_sync_ccf, gr_pfb_clock_sync_fff, gr_align_on_samplenumbers_ss, gr_copy, gr_deinterleave, gr_interleave, gr_kludge_copy, gr_test, gr_oscope_sink_f, audio_alsa_sink, audio_alsa_source, audio_jack_sink, audio_jack_source, audio_osx_source, audio_portaudio_sink, audio_portaudio_source, comedi_sink_s, and comedi_source_s.

vcolor gr_basic_block::color ( ) const [inline, protected]

References d_color.

Referenced by set_color().

gr_io_signature_sptr gr_basic_block::input_signature ( ) const [inline]

References d_input_signature.

std::string gr_basic_block::name ( ) const [inline]

References d_name.

gr_io_signature_sptr gr_basic_block::output_signature ( ) const [inline]

References d_output_signature.

void gr_basic_block::set_color ( vcolor  color) [inline, protected]

Allow the flowgraph to set for sorting and partitioning.

References color(), and d_color.

void gr_basic_block::set_input_signature ( gr_io_signature_sptr  iosig) [inline, protected]

may only be called during constructor

References d_input_signature.

template<typename T >
void gr_basic_block::set_msg_handler ( msg_handler) [inline]

Set the callback that is fired when messages are available.

msg_handler can be any kind of function pointer or function object that has the signature:

    void msg_handler(pmt::pmt msg);
 

(You may want to use boost::bind to massage your callable into the correct form. See gr_nop.{h,cc} for an example that sets up a class method as the callback.)

Blocks that desire to handle messages must call this method in their constructors to register the handler that will be invoked when messages are available.

If the block inherits from gr_block, the runtime system will ensure that msg_handler is called in a thread-safe manner, such that work and msg_handler will never be called concurrently. This allows msg_handler to update state variables without having to worry about thread-safety issues with work, general_work or another invocation of msg_handler.

If the block inherits from gr_hier_block2, the runtime system will ensure that no reentrant calls are made to msg_handler.

void gr_basic_block::set_output_signature ( gr_io_signature_sptr  iosig) [inline, protected]

may only be called during constructor

References d_output_signature.

gr_basic_block_sptr gr_basic_block::to_basic_block ( )
long gr_basic_block::unique_id ( ) const [inline]

References d_unique_id.


Friends And Related Function Documentation

friend class gr_flat_flowgraph [friend]
friend class gr_flowgraph [friend]
friend class gr_tpb_thread_body [friend]

Member Data Documentation

Referenced by color(), and set_color().

std::string gr_basic_block::d_name [protected]

Referenced by name().

long gr_basic_block::d_unique_id [protected]

Referenced by unique_id().


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