GNU Radio 3.6.5 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:
gr_msg_accepter gruel::msg_accepter gr_block gr_hier_block2 atsc_bit_timing_loop atsc_field_sync_demux digital_clock_recovery_mm_cc digital_clock_recovery_mm_ff digital_constellation_decoder_cb digital_constellation_receiver_cb digital_mpsk_receiver_cc digital_ofdm_chanest_vcvc digital_ofdm_frame_acquisition digital_ofdm_insert_preamble digital_ofdm_sampler digital_pfb_clock_sync_ccf digital_pfb_clock_sync_fff digital_simple_correlator digital_simple_framer gr::analog::ctcss_squelch_ff gr::analog::pwr_squelch_cc gr::analog::pwr_squelch_ff gr::analog::squelch_base_cc gr::analog::squelch_base_ff gr::blocks::copy gr::blocks::delay gr::blocks::keep_m_in_n gr::blocks::keep_one_in_n gr::blocks::message_debug gr::blocks::message_strobe gr::blocks::nop gr::blocks::packed_to_unpacked_bb gr::blocks::packed_to_unpacked_ii gr::blocks::packed_to_unpacked_ss gr::blocks::patterned_interleaver gr::blocks::skiphead gr::blocks::socket_pdu gr::blocks::stream_mux gr::blocks::tuntap_pdu gr::blocks::unpacked_to_packed_bb gr::blocks::unpacked_to_packed_ii gr::blocks::unpacked_to_packed_ss gr::blocks::vector_insert_b gr::blocks::vector_insert_c gr::blocks::vector_insert_f gr::blocks::vector_insert_i gr::blocks::vector_insert_s gr::digital::header_payload_demux gr::filter::fractional_interpolator_cc gr::filter::fractional_interpolator_ff gr::filter::fractional_resampler_cc gr::filter::fractional_resampler_ff gr::filter::pfb_arb_resampler_ccf gr::filter::pfb_arb_resampler_fff gr::filter::pfb_channelizer_ccf gr::filter::rational_resampler_base_ccc gr::filter::rational_resampler_base_ccf gr::filter::rational_resampler_base_fcc gr::filter::rational_resampler_base_fff gr::filter::rational_resampler_base_fsf gr::filter::rational_resampler_base_scc gr_align_on_samplenumbers_ss gr_block_gateway gr_copy gr_delay gr_fractional_interpolator_cc gr_fractional_interpolator_ff gr_keep_m_in_n gr_keep_one_in_n gr_message_debug gr_message_strobe gr_nop gr_ofdm_bpsk_demapper gr_packed_to_unpacked_bb gr_packed_to_unpacked_ii gr_packed_to_unpacked_ss gr_pfb_arb_resampler_ccf gr_pfb_arb_resampler_fff gr_pfb_channelizer_ccf gr_pfb_clock_sync_ccf gr_pfb_clock_sync_fff gr_random_pdu gr_rational_resampler_base_ccc gr_rational_resampler_base_ccf gr_rational_resampler_base_fcc gr_rational_resampler_base_fff gr_rational_resampler_base_fsf gr_rational_resampler_base_scc gr_simple_correlator gr_simple_framer gr_skiphead gr_squelch_base_cc gr_squelch_base_ff gr_stream_mux gr_sync_block gr_tagged_stream_block gr_test gr_unpacked_to_packed_bb gr_unpacked_to_packed_ii gr_unpacked_to_packed_ss gr_vector_insert_b noaa_hrpt_deframer pager_flex_sync qtgui_sink_c qtgui_sink_f trellis_constellation_metrics_cf trellis_metrics_c trellis_metrics_f trellis_metrics_i trellis_metrics_s trellis_pccc_decoder_b trellis_pccc_decoder_combined_cb trellis_pccc_decoder_combined_ci trellis_pccc_decoder_combined_cs trellis_pccc_decoder_combined_fb trellis_pccc_decoder_combined_fi trellis_pccc_decoder_combined_fs trellis_pccc_decoder_i trellis_pccc_decoder_s trellis_sccc_decoder_b trellis_sccc_decoder_combined_cb trellis_sccc_decoder_combined_ci trellis_sccc_decoder_combined_cs trellis_sccc_decoder_combined_fb trellis_sccc_decoder_combined_fi trellis_sccc_decoder_combined_fs trellis_sccc_decoder_i trellis_sccc_decoder_s trellis_siso_combined_f trellis_siso_f trellis_viterbi_b trellis_viterbi_combined_cb trellis_viterbi_combined_ci trellis_viterbi_combined_cs trellis_viterbi_combined_fb trellis_viterbi_combined_fi trellis_viterbi_combined_fs trellis_viterbi_combined_ib trellis_viterbi_combined_ii trellis_viterbi_combined_is trellis_viterbi_combined_sb trellis_viterbi_combined_si trellis_viterbi_combined_ss trellis_viterbi_i trellis_viterbi_s digital_cpmmod_bc digital_ofdm_sync_sc_cfb fcd_source_c gr::filter::channel_model gr_channel_model gr_top_block

List of all members.

Public Member Functions

virtual ~gr_basic_block ()
long unique_id () const
long symbolic_id () const
std::string name () const
std::string symbol_name () const
gr_io_signature_sptr input_signature () const
gr_io_signature_sptr output_signature () const
gr_basic_block_sptr to_basic_block ()
bool alias_set ()
std::string alias ()
pmt::pmt_t alias_pmt ()
void set_block_alias (std::string name)
void message_port_register_in (pmt::pmt_t port_id)
void message_port_register_out (pmt::pmt_t port_id)
void message_port_pub (pmt::pmt_t port_id, pmt::pmt_t msg)
void message_port_sub (pmt::pmt_t port_id, pmt::pmt_t target)
void message_port_unsub (pmt::pmt_t port_id, pmt::pmt_t target)
virtual bool message_port_is_hier (pmt::pmt_t port_id)
virtual bool message_port_is_hier_in (pmt::pmt_t port_id)
virtual bool message_port_is_hier_out (pmt::pmt_t port_id)
pmt::pmt_t message_ports_in ()
 Get input message port names.
pmt::pmt_t message_ports_out ()
 Get output message port names.
void _post (pmt::pmt_t which_port, pmt::pmt_t msg)
bool empty_p (pmt::pmt_t which_port)
 is the queue empty?
bool empty_p ()
size_t nmsgs (pmt::pmt_t which_port)
 How many messages in the queue?
void insert_tail (pmt::pmt_t which_port, pmt::pmt_t msg)
pmt::pmt_t delete_head_nowait (pmt::pmt_t which_port)
pmt::pmt_t delete_head_blocking (pmt::pmt_t which_port)
msg_queue_t::iterator get_iterator (pmt::pmt_t which_port)
void erase_msg (pmt::pmt_t which_port, msg_queue_t::iterator it)
virtual bool has_msg_port (pmt::pmt_t which_port)
virtual bool check_topology (int ninputs, int noutputs)
 Confirm that ninputs and noutputs is an acceptable combination.
template<typename T >
void set_msg_handler (pmt::pmt_t which_port, 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
bool has_msg_handler (pmt::pmt_t which_port)
 Tests if there is a handler attached to port which_port.
virtual void dispatch_msg (pmt::pmt_t which_port, pmt::pmt_t msg)

Protected Attributes

std::string d_name
gr_io_signature_sptr d_input_signature
gr_io_signature_sptr d_output_signature
long d_unique_id
long d_symbolic_id
std::string d_symbol_name
std::string d_symbol_alias
vcolor d_color
msg_queue_map_t msg_queue
pmt::pmt_t message_subscribers

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

void gr_basic_block::_post ( pmt::pmt_t  which_port,
pmt::pmt_t  msg 
)

Accept msg, place in queue, arrange for thread to be awakened if it's not already.

std::string gr_basic_block::alias ( ) [inline]
pmt::pmt_t gr_basic_block::alias_pmt ( ) [inline]

References pmt::pmt_intern().

bool gr_basic_block::alias_set ( ) [inline]
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, gr::blocks::copy_impl, gr::blocks::deinterleave_impl, gr::blocks::interleave_impl, comedi_sink_s, comedi_source_s, digital_pfb_clock_sync_ccf, digital_pfb_clock_sync_fff, gr_chunks_to_symbols_bc, gr_chunks_to_symbols_bf, gr_chunks_to_symbols_ic, gr_chunks_to_symbols_if, gr_chunks_to_symbols_sc, gr_chunks_to_symbols_sf, gr_packed_to_unpacked_bb, gr_packed_to_unpacked_ii, gr_packed_to_unpacked_ss, gr_unpacked_to_packed_bb, gr_unpacked_to_packed_ii, gr_unpacked_to_packed_ss, gr::blocks::packed_to_unpacked_bb_impl, gr::blocks::packed_to_unpacked_ii_impl, gr::blocks::packed_to_unpacked_ss_impl, gr::blocks::unpacked_to_packed_bb_impl, gr::blocks::unpacked_to_packed_ii_impl, gr::blocks::unpacked_to_packed_ss_impl, digital_chunks_to_symbols_bc, digital_chunks_to_symbols_bf, digital_chunks_to_symbols_ic, digital_chunks_to_symbols_if, digital_chunks_to_symbols_sc, and digital_chunks_to_symbols_sf.

References void().

Referenced by gr_test::set_check_topology().

vcolor gr_basic_block::color ( ) const [inline, protected]
pmt::pmt_t gr_basic_block::delete_head_blocking ( pmt::pmt_t  which_port)
Returns:
returns pmt at head of queue or pmt_t() if empty.
pmt::pmt_t gr_basic_block::delete_head_nowait ( pmt::pmt_t  which_port)
Returns:
returns pmt at head of queue or pmt_t() if empty.
virtual void gr_basic_block::dispatch_msg ( pmt::pmt_t  which_port,
pmt::pmt_t  msg 
) [inline, protected, virtual]

Reimplemented in gr_block_gateway.

Referenced by gr_block_gateway::dispatch_msg().

bool gr_basic_block::empty_p ( pmt::pmt_t  which_port) [inline]

is the queue empty?

bool gr_basic_block::empty_p ( ) [inline]
void gr_basic_block::erase_msg ( pmt::pmt_t  which_port,
msg_queue_t::iterator  it 
) [inline]
msg_queue_t::iterator gr_basic_block::get_iterator ( pmt::pmt_t  which_port) [inline]
bool gr_basic_block::has_msg_handler ( pmt::pmt_t  which_port) [inline, protected]

Tests if there is a handler attached to port which_port.

virtual bool gr_basic_block::has_msg_port ( pmt::pmt_t  which_port) [inline, virtual]

Reimplemented in gr_hier_block2.

References pmt::pmt_dict_has_key().

Referenced by gr_hier_block2::has_msg_port().

gr_io_signature_sptr gr_basic_block::input_signature ( ) const [inline]
void gr_basic_block::insert_tail ( pmt::pmt_t  which_port,
pmt::pmt_t  msg 
)
virtual bool gr_basic_block::message_port_is_hier ( pmt::pmt_t  port_id) [inline, virtual]

Reimplemented in gr_hier_block2.

References void().

Referenced by gr_hier_block2::has_msg_port().

virtual bool gr_basic_block::message_port_is_hier_in ( pmt::pmt_t  port_id) [inline, virtual]

Reimplemented in gr_hier_block2.

References void().

Referenced by gr_hier_block2::message_port_is_hier().

virtual bool gr_basic_block::message_port_is_hier_out ( pmt::pmt_t  port_id) [inline, virtual]

Reimplemented in gr_hier_block2.

References void().

Referenced by gr_hier_block2::message_port_is_hier().

void gr_basic_block::message_port_pub ( pmt::pmt_t  port_id,
pmt::pmt_t  msg 
)
void gr_basic_block::message_port_register_in ( pmt::pmt_t  port_id)
void gr_basic_block::message_port_register_out ( pmt::pmt_t  port_id)
void gr_basic_block::message_port_sub ( pmt::pmt_t  port_id,
pmt::pmt_t  target 
)
void gr_basic_block::message_port_unsub ( pmt::pmt_t  port_id,
pmt::pmt_t  target 
)
pmt::pmt_t gr_basic_block::message_ports_in ( )

Get input message port names.

Returns the available input message ports for a block. The return object is a PMT vector that is filled with PMT symbols.

Referenced by gr_block_gateway::gr_block__message_ports_in().

pmt::pmt_t gr_basic_block::message_ports_out ( )

Get output message port names.

Returns the available output message ports for a block. The return object is a PMT vector that is filled with PMT symbols.

Referenced by gr_block_gateway::gr_block__message_ports_out().

size_t gr_basic_block::nmsgs ( pmt::pmt_t  which_port) [inline]

How many messages in the queue?

gr_io_signature_sptr gr_basic_block::output_signature ( ) const [inline]
void gr_basic_block::set_block_alias ( std::string  name)
void gr_basic_block::set_color ( vcolor  color) [inline, protected]

Allow the flowgraph to set for sorting and partitioning.

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

may only be called during constructor

template<typename T >
void gr_basic_block::set_msg_handler ( pmt::pmt_t  which_port,
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

std::string gr_basic_block::symbol_name ( ) const [inline]
long gr_basic_block::symbolic_id ( ) const [inline]
gr_basic_block_sptr gr_basic_block::to_basic_block ( )
long gr_basic_block::unique_id ( ) const [inline]

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

std::string gr_basic_block::d_name [protected]
std::string gr_basic_block::d_symbol_alias [protected]
std::string gr_basic_block::d_symbol_name [protected]
long gr_basic_block::d_unique_id [protected]
msg_queue_map_t gr_basic_block::msg_queue [protected]

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