GNU Radio 3.6.4.2 C++ API
gr_block Struct Reference

#include <gr_block.h>

Inheritance diagram for gr_block:
gr::blocks::delay gr::blocks::keep_m_in_n gr::blocks::keep_one_in_n gr::blocks::patterned_interleaver gr::blocks::stream_mux gr::filter::fractional_interpolator_cc gr::filter::fractional_interpolator_ff gr::filter::pfb_arb_resampler_ccf gr::filter::pfb_arb_resampler_fff gr::filter::pfb_channelizer_ccf 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_strobe gr_nop gr_ofdm_bpsk_demapper 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_test gr_vector_insert_b qtgui_sink_c qtgui_sink_f

Public Types

enum  { WORK_CALLED_PRODUCE = -2, WORK_DONE = -1 }
 Return options for the work call. More...
 
enum  tag_propagation_policy_t { TPP_DONT = 0, TPP_ALL_TO_ALL = 1, TPP_ONE_TO_ONE = 2 }
 
typedef std::deque< pmt::pmt_tmsg_queue_t
 
typedef std::map< pmt::pmt_t,
msg_queue_t,
pmt::pmt_comperator
msg_queue_map_t
 
typedef std::map< pmt::pmt_t,
msg_queue_t,
pmt::pmt_comperator >
::iterator 
msg_queue_map_itr
 
typedef boost::function< void(pmt::pmt_t)> msg_handler_t
 
typedef std::map< pmt::pmt_t,
msg_handler_t,
pmt::pmt_comperator
d_msg_handlers_t
 

Public Member Functions

 gr_block (void)
 
 gr_block (const std::string &name, gr_io_signature_sptr input_signature, gr_io_signature_sptr output_signature)
 
long unique_id (void) const
 
std::string name (void) const
 
virtual ~gr_block (void)
 
gr_io_signature_sptr input_signature (void) const
 
gr_io_signature_sptr output_signature (void) const
 
void set_input_signature (gr_io_signature_sptr sig)
 
void set_output_signature (gr_io_signature_sptr sig)
 
virtual bool check_topology (int ninputs, int noutputs)
 
virtual void forecast (int, std::vector< int > &)
 Overload me! I am the forecast. More...
 
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)
 compute output items from input items More...
 
virtual bool start (void)
 
virtual bool stop (void)
 
void consume_each (const int how_many_items)
 Call during work to consume items. More...
 
void consume (const size_t i, const int how_many_items)
 
void produce (const size_t o, const int how_many_items)
 
uint64_t nitems_read (const size_t which_input=0)
 Get absolute count of all items consumed on the given input port. More...
 
uint64_t nitems_written (const size_t which_output=0)
 Get absolute count of all items produced on the given output port. More...
 
void add_item_tag (const size_t which_output, const gr_tag_t &tag)
 
void add_item_tag (const size_t which_output, uint64_t abs_offset, const pmt::pmt_t &key, const pmt::pmt_t &value, const pmt::pmt_t &srcid=pmt::PMT_F)
 
void get_tags_in_range (std::vector< gr_tag_t > &tags, const size_t which_input, uint64_t abs_start, uint64_t abs_end, const pmt::pmt_t &key=pmt::pmt_t())
 
void set_alignment (const size_t alignment)
 
bool is_unaligned (void)
 
size_t fixed_rate_noutput_to_ninput (const size_t noutput_items)
 
size_t interpolation (void) const
 
void set_interpolation (const size_t)
 
size_t decimation (void) const
 
void set_decimation (const size_t)
 
int max_noutput_items (void) const
 
void set_max_noutput_items (int)
 
void unset_max_noutput_items (void)
 
bool is_set_max_noutput_items (void) const
 
unsigned history (void) const
 
void set_history (unsigned history)
 
void set_fixed_rate (const bool fixed_rate)
 
bool fixed_rate (void) const
 Get the fixed rate setting. More...
 
void set_relative_rate (const double relative_rate)
 
double relative_rate (void) const
 Get the relative rate setting. More...
 
void set_output_multiple (const size_t multiple)
 
size_t output_multiple (void) const
 Get the output multiple setting. More...
 
tag_propagation_policy_t tag_propagation_policy (void)
 
void set_tag_propagation_policy (tag_propagation_policy_t p)
 
void set_max_output_buffer (long)
 
void set_max_output_buffer (int, long)
 
long max_output_buffer (size_t)
 
void set_min_output_buffer (long)
 
void set_min_output_buffer (int, long)
 
long min_output_buffer (size_t)
 
std::string symbol_name () const
 
bool alias_set ()
 
std::string alias ()
 
pmt::pmt_t alias_pmt ()
 
void set_block_alias (std::string name)
 
template<typename T >
void set_msg_handler (pmt::pmt_t which_port, T msg_handler)
 
void message_port_register_in (pmt::pmt_t)
 
void message_port_register_out (pmt::pmt_t)
 
void message_port_pub (pmt::pmt_t, pmt::pmt_t)
 
void message_port_sub (pmt::pmt_t, pmt::pmt_t)
 
void message_port_unsub (pmt::pmt_t, pmt::pmt_t)
 
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. More...
 
pmt::pmt_t message_ports_out ()
 Get output message port names. More...
 
bool empty_p (pmt::pmt_t which_port)
 is the queue empty? More...
 
bool empty_p ()
 
void insert_tail (pmt::pmt_t, pmt::pmt_t)
 
pmt::pmt_t delete_head_nowait (pmt::pmt_t)
 
pmt::pmt_t delete_head_blocking (pmt::pmt_t)
 
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)
 
bool has_msg_handler (pmt::pmt_t which_port)
 Tests if there is a handler attached to port which_port. More...
 
virtual void dispatch_msg (pmt::pmt_t which_port, pmt::pmt_t msg)
 
void set_processor_affinity (const std::vector< int > &mask)
 Set the thread's affinity to processor core n. More...
 
void unset_processor_affinity ()
 Remove processor affinity to a specific core. More...
 
std::vector< int > processor_affinity ()
 Get the current processor affinity. More...
 
void work (const InputItems &, const OutputItems &)
 implements work -> calls general work More...
 
void notify_topology (const size_t, const size_t)
 notifications of new topological commits More...
 
void notify_active (void)
 start notification More...
 
void notify_inactive (void)
 stop notification More...
 
virtual void propagate_tags (const size_t, const gras::TagIter &)
 implements tag_propagation_policy() More...
 
void _update_input_reserve (void)
 
gras::BufferQueueSptr input_buffer_allocator (const size_t, const gras::SBufferConfig &)
 
gras::BufferQueueSptr output_buffer_allocator (const size_t, const gras::SBufferConfig &)
 

Public Attributes

long _unique_id
 
std::string _name
 
std::string d_symbol_alias
 
std::string d_symbol_name
 
msg_queue_map_t msg_queue
 
pmt::pmt_t message_subscribers
 
d_msg_handlers_t d_msg_handlers
 
gruel::mutex d_setlock
 
std::vector< int > d_affinity
 
gr_vector_int _work_ninput_items
 
gr_vector_int _fcast_ninput_items
 
size_t _num_outputs
 
ptrdiff_t _work_io_ptr_mask
 
size_t _output_multiple_items
 
double _relative_rate
 
bool _enable_fixed_rate
 
size_t _input_history_items
 
tag_propagation_policy_t _tag_prop_policy
 
size_t _interp
 
size_t _decim
 
gr_io_signature_sptr _in_sig
 
gr_io_signature_sptr _out_sig
 

Member Typedef Documentation

typedef boost::function<void(pmt::pmt_t)> gr_block::msg_handler_t
typedef std::deque<pmt::pmt_t> gr_block::msg_queue_t

Member Enumeration Documentation

anonymous enum

Return options for the work call.

Enumerator
WORK_CALLED_PRODUCE 
WORK_DONE 
Enumerator
TPP_DONT 
TPP_ALL_TO_ALL 
TPP_ONE_TO_ONE 

Constructor & Destructor Documentation

gr_block::gr_block ( void  )
gr_block::gr_block ( const std::string &  name,
gr_io_signature_sptr  input_signature,
gr_io_signature_sptr  output_signature 
)
virtual gr_block::~gr_block ( void  )
virtual

Member Function Documentation

void gr_block::_update_input_reserve ( void  )
void gr_block::add_item_tag ( const size_t  which_output,
const gr_tag_t tag 
)
void gr_block::add_item_tag ( const size_t  which_output,
uint64_t  abs_offset,
const pmt::pmt_t key,
const pmt::pmt_t value,
const pmt::pmt_t srcid = pmt::PMT_F 
)
std::string gr_block::alias ( )
inline
pmt::pmt_t gr_block::alias_pmt ( )
inline

References pmt::pmt_intern().

bool gr_block::alias_set ( )
inline
GRAS_FORCE_INLINE void gr_block::consume ( const size_t  i,
const int  how_many_items 
)
GRAS_FORCE_INLINE void gr_block::consume_each ( const int  how_many_items)

Call during work to consume items.

Referenced by gr_sync_block::general_work(), and gr_block_gateway::gr_block__consume_each().

GRAS_FORCE_INLINE size_t gr_block::decimation ( void  ) const

References _decim.

Referenced by gr_sync_block::general_work().

pmt::pmt_t gr_block::delete_head_blocking ( pmt::pmt_t  )
inline
Returns
returns pmt at head of queue or pmt_t() if empty.

References pmt::PMT_NIL.

pmt::pmt_t gr_block::delete_head_nowait ( pmt::pmt_t  )
inline
Returns
returns pmt at head of queue or pmt_t() if empty.

References pmt::PMT_NIL.

virtual void gr_block::dispatch_msg ( pmt::pmt_t  which_port,
pmt::pmt_t  msg 
)
inlinevirtual

Reimplemented in gr_block_gateway.

Referenced by gr_block_gateway::dispatch_msg().

bool gr_block::empty_p ( pmt::pmt_t  which_port)
inline

is the queue empty?

bool gr_block::empty_p ( )
inline
void gr_block::erase_msg ( pmt::pmt_t  which_port,
msg_queue_t::iterator  it 
)
inline
bool gr_block::fixed_rate ( void  ) const

Get the fixed rate setting.

Referenced by gr_block_gateway::gr_block__fixed_rate().

size_t gr_block::fixed_rate_noutput_to_ninput ( const size_t  noutput_items)
virtual void gr_block::forecast ( int  ,
std::vector< int > &   
)
virtual

Overload me! I am the forecast.

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 
)
virtual

compute output items from input items

Parameters
noutput_itemsnumber of output items to write on each output stream
ninput_itemsnumber of input items available on each input stream
input_itemsvector of pointers to the input items, one entry per input stream
output_itemsvector 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.

Reimplemented in gr_pfb_clock_sync_ccf, gr_pfb_clock_sync_fff, gr_pfb_channelizer_ccf, gr_pfb_arb_resampler_ccf, gr_pfb_arb_resampler_fff, qtgui_sink_c, qtgui_sink_f, gr_simple_correlator, gr_align_on_samplenumbers_ss, gr_stream_mux, 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::filter::pfb_arb_resampler_ccf_impl, gr::filter::pfb_arb_resampler_fff_impl, gr_ofdm_bpsk_demapper, gr_test, gr::filter::pfb_channelizer_ccf_impl, gr_copy, gr_keep_m_in_n, gr_delay, gr_skiphead, gr_keep_one_in_n, gr_squelch_base_cc, gr_squelch_base_ff, gr_nop, gr_simple_framer, gr_vector_insert_b, gr::blocks::delay_impl, gr::filter::fractional_interpolator_cc_impl, gr::filter::fractional_interpolator_ff_impl, gr_fractional_interpolator_cc, gr_fractional_interpolator_ff, gr::blocks::stream_mux_impl, gr::blocks::keep_m_in_n_impl, gr::blocks::keep_one_in_n_impl, gr_sync_block, and gr::blocks::patterned_interleaver_impl.

msg_queue_t::iterator gr_block::get_iterator ( pmt::pmt_t  which_port)
inline
void gr_block::get_tags_in_range ( std::vector< gr_tag_t > &  tags,
const size_t  which_input,
uint64_t  abs_start,
uint64_t  abs_end,
const pmt::pmt_t key = pmt::pmt_t() 
)
bool gr_block::has_msg_handler ( pmt::pmt_t  which_port)
inline

Tests if there is a handler attached to port which_port.

virtual bool gr_block::has_msg_port ( pmt::pmt_t  which_port)
inlinevirtual
gras::BufferQueueSptr gr_block::input_buffer_allocator ( const size_t  ,
const gras::SBufferConfig &   
)
gr_io_signature_sptr gr_block::input_signature ( void  ) const
void gr_block::insert_tail ( pmt::pmt_t  ,
pmt::pmt_t   
)
inline
GRAS_FORCE_INLINE size_t gr_block::interpolation ( void  ) const

References _interp.

Referenced by gr_sync_block::general_work().

bool gr_block::is_set_max_noutput_items ( void  ) const
GRAS_FORCE_INLINE bool gr_block::is_unaligned ( void  )

References _work_io_ptr_mask.

int gr_block::max_noutput_items ( void  ) const
long gr_block::max_output_buffer ( size_t  )
inline
virtual bool gr_block::message_port_is_hier ( pmt::pmt_t  port_id)
inlinevirtual

References void().

virtual bool gr_block::message_port_is_hier_in ( pmt::pmt_t  port_id)
inlinevirtual

References void().

virtual bool gr_block::message_port_is_hier_out ( pmt::pmt_t  port_id)
inlinevirtual

References void().

void gr_block::message_port_pub ( pmt::pmt_t  ,
pmt::pmt_t   
)
inline
void gr_block::message_port_register_in ( pmt::pmt_t  )
inline
void gr_block::message_port_register_out ( pmt::pmt_t  )
inline
void gr_block::message_port_sub ( pmt::pmt_t  ,
pmt::pmt_t   
)
inline
void gr_block::message_port_unsub ( pmt::pmt_t  ,
pmt::pmt_t   
)
inline
pmt::pmt_t gr_block::message_ports_in ( )
inline

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.

References pmt::PMT_NIL.

Referenced by gr_block_gateway::gr_block__message_ports_in().

pmt::pmt_t gr_block::message_ports_out ( )
inline

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.

References pmt::PMT_NIL.

Referenced by gr_block_gateway::gr_block__message_ports_out().

long gr_block::min_output_buffer ( size_t  )
inline
std::string gr_block::name ( void  ) const
inline
GRAS_FORCE_INLINE uint64_t gr_block::nitems_read ( const size_t  which_input = 0)

Get absolute count of all items consumed on the given input port.

Referenced by gr_block_gateway::gr_block__nitems_read().

GRAS_FORCE_INLINE uint64_t gr_block::nitems_written ( const size_t  which_output = 0)

Get absolute count of all items produced on the given output port.

Referenced by gr_block_gateway::gr_block__nitems_written().

void gr_block::notify_active ( void  )

start notification

void gr_block::notify_inactive ( void  )

stop notification

void gr_block::notify_topology ( const size_t  ,
const size_t   
)

notifications of new topological commits

gras::BufferQueueSptr gr_block::output_buffer_allocator ( const size_t  ,
const gras::SBufferConfig &   
)
size_t gr_block::output_multiple ( void  ) const

Get the output multiple setting.

Referenced by gr_block_gateway::gr_block__output_multiple().

gr_io_signature_sptr gr_block::output_signature ( void  ) const
std::vector<int> gr_block::processor_affinity ( )
inline

Get the current processor affinity.

GRAS_FORCE_INLINE void gr_block::produce ( const size_t  o,
const int  how_many_items 
)
virtual void gr_block::propagate_tags ( const size_t  ,
const gras::TagIter &   
)
virtual
double gr_block::relative_rate ( void  ) const
void gr_block::set_alignment ( const size_t  alignment)
void gr_block::set_block_alias ( std::string  name)
inline

References name.

void gr_block::set_decimation ( const size_t  )
void gr_block::set_fixed_rate ( const bool  fixed_rate)

Enable fixed rate logic. When enabled, relative rate is assumed to be set, and forecast is automatically called. Also, consume will be called automatically.

Referenced by gr_block_gateway::gr_block__set_fixed_rate(), and gr_test::set_fixed_rate_public().

void gr_block::set_history ( unsigned  history)
void gr_block::set_input_signature ( gr_io_signature_sptr  sig)
void gr_block::set_interpolation ( const size_t  )
void gr_block::set_max_noutput_items ( int  )
void gr_block::set_max_output_buffer ( long  )
inline
void gr_block::set_max_output_buffer ( int  ,
long   
)
inline
void gr_block::set_min_output_buffer ( long  )
inline
void gr_block::set_min_output_buffer ( int  ,
long   
)
inline
template<typename T >
void gr_block::set_msg_handler ( pmt::pmt_t  which_port,
msg_handler 
)
inline
void gr_block::set_output_multiple ( const size_t  multiple)

The output multiple setting controls work output buffer sizes. Buffers will be number of items modulo rounted to the multiple.

Referenced by gr_block_gateway::gr_block__set_output_multiple().

void gr_block::set_output_signature ( gr_io_signature_sptr  sig)
void gr_block::set_processor_affinity ( const std::vector< int > &  mask)
inline

Set the thread's affinity to processor core n.

Parameters
maska vector of unsigned ints of the core numbers available to this block.
void gr_block::set_relative_rate ( const double  relative_rate)

The relative rate can be thought of as interpolation/decimation. In other words, relative rate is the ratio of output items to input items.

Referenced by gr_block_gateway::gr_block__set_relative_rate(), gr_pfb_arb_resampler_fff::set_rate(), and gr_pfb_arb_resampler_ccf::set_rate().

void gr_block::set_tag_propagation_policy ( tag_propagation_policy_t  p)
virtual bool gr_block::start ( void  )
virtual

Reimplemented in gr_random_pdu.

virtual bool gr_block::stop ( void  )
virtual
std::string gr_block::symbol_name ( ) const
inline
tag_propagation_policy_t gr_block::tag_propagation_policy ( void  )
long gr_block::unique_id ( void  ) const
inline
void gr_block::unset_max_noutput_items ( void  )
void gr_block::unset_processor_affinity ( )
inline

Remove processor affinity to a specific core.

void gr_block::work ( const InputItems &  ,
const OutputItems &   
)

implements work -> calls general work

Member Data Documentation

size_t gr_block::_decim

Referenced by decimation().

bool gr_block::_enable_fixed_rate
gr_vector_int gr_block::_fcast_ninput_items
gr_io_signature_sptr gr_block::_in_sig
size_t gr_block::_input_history_items
size_t gr_block::_interp

Referenced by interpolation().

std::string gr_block::_name
size_t gr_block::_num_outputs
gr_io_signature_sptr gr_block::_out_sig
size_t gr_block::_output_multiple_items
double gr_block::_relative_rate
tag_propagation_policy_t gr_block::_tag_prop_policy
long gr_block::_unique_id
ptrdiff_t gr_block::_work_io_ptr_mask

Referenced by is_unaligned().

gr_vector_int gr_block::_work_ninput_items
std::vector<int> gr_block::d_affinity
d_msg_handlers_t gr_block::d_msg_handlers
gruel::mutex gr_block::d_setlock

Used by block's setters and work functions to make setting/resetting of parameters thread-safe.

Used by calling gruel::scoped_lock l(d_setlock);

std::string gr_block::d_symbol_alias
std::string gr_block::d_symbol_name
pmt::pmt_t gr_block::message_subscribers
msg_queue_map_t gr_block::msg_queue

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