GNU Radio 3.7.3 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 block, which implements actual signal processing functions. More...

#include <gnuradio/basic_block.h>

Inheritance diagram for gr::basic_block:

Public Member Functions

pmt::pmt_t message_subscribers (pmt::pmt_t port)
 
virtual ~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
 
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. More...
 
pmt::pmt_t message_ports_out ()
 Get output message port names. More...
 
void _post (pmt::pmt_t which_port, pmt::pmt_t msg)
 
bool empty_p (pmt::pmt_t which_port)
 is the queue empty? More...
 
bool empty_p ()
 
bool empty_handled_p (pmt::pmt_t which_port)
 are all msg ports with handlers empty? More...
 
bool empty_handled_p ()
 
size_t nmsgs (pmt::pmt_t which_port)
 How many messages in the queue? More...
 
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 void setup_rpc ()
 Set up the RPC registered variables. More...
 
bool is_rpc_set ()
 Ask if this block has been registered to the RPC. More...
 
void rpc_set ()
 When the block is registered with the RPC, set this. More...
 
virtual bool check_topology (int ninputs, int noutputs)
 Confirm that ninputs and noutputs is an acceptable combination. More...
 
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. More...
 
virtual void set_processor_affinity (const std::vector< int > &mask)
 
virtual void unset_processor_affinity ()
 
virtual std::vector< int > processor_affinity ()
 
- Public Member Functions inherited from gr::msg_accepter
 msg_accepter ()
 
 ~msg_accepter ()
 
void post (pmt::pmt_t which_port, pmt::pmt_t msg)
 send msg to msg_accepter on port which_port More...
 
- Public Member Functions inherited from gr::messages::msg_accepter
 msg_accepter ()
 

Protected Types

enum  vcolor { WHITE, GREY, BLACK }
 

Protected Member Functions

 basic_block (void)
 
 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. More...
 
void set_input_signature (gr::io_signature::sptr iosig)
 may only be called during constructor More...
 
void set_output_signature (gr::io_signature::sptr iosig)
 may only be called during constructor More...
 
void set_color (vcolor color)
 Allow the flowgraph to set for sorting and partitioning. More...
 
vcolor color () const
 
virtual 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)
 

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
 
bool d_rpc_set
 
msg_queue_map_t msg_queue
 
std::vector< boost::any > d_rpc_vars
 
pmt::pmt_t d_message_subscribers
 

Friends

class flowgraph
 
class flat_flowgraph
 
class 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 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::basic_block ( void  )
inlineprotected
gr::basic_block::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::~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::intern().

bool gr::basic_block::alias_set ( )
inline
virtual bool gr::basic_block::check_topology ( int  ninputs,
int  noutputs 
)
inlinevirtual

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.

References void().

vcolor gr::basic_block::color ( ) const
inlineprotected
pmt::pmt_t gr::basic_block::delete_head_blocking ( pmt::pmt_t  which_port)
Returns
returns pmt at head of queue or pmt::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::pmt_t() if empty.
virtual void gr::basic_block::dispatch_msg ( pmt::pmt_t  which_port,
pmt::pmt_t  msg 
)
inlineprotectedvirtual

Reimplemented in gr::block_gateway.

Referenced by gr::block_gateway::dispatch_msg().

bool gr::basic_block::empty_handled_p ( pmt::pmt_t  which_port)
inline

are all msg ports with handlers empty?

bool gr::basic_block::empty_handled_p ( )
inline
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
virtual bool gr::basic_block::has_msg_handler ( pmt::pmt_t  which_port)
inlineprotectedvirtual

Tests if there is a handler attached to port which_port.

Reimplemented in gr::block_gateway.

virtual bool gr::basic_block::has_msg_port ( pmt::pmt_t  which_port)
inlinevirtual

Reimplemented in gr::hier_block2.

References 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 
)
bool gr::basic_block::is_rpc_set ( )
inline

Ask if this block has been registered to the RPC.

We can only register a block once, so we use this to protect us from calling it multiple times.

virtual bool gr::basic_block::message_port_is_hier ( pmt::pmt_t  port_id)
inlinevirtual

Reimplemented in gr::hier_block2.

References void().

virtual bool gr::basic_block::message_port_is_hier_in ( pmt::pmt_t  port_id)
inlinevirtual

Reimplemented in gr::hier_block2.

References void().

virtual bool gr::basic_block::message_port_is_hier_out ( pmt::pmt_t  port_id)
inlinevirtual

Reimplemented in gr::hier_block2.

References void().

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::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::block__message_ports_out().

pmt::pmt_t gr::basic_block::message_subscribers ( pmt::pmt_t  port)
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
virtual std::vector<int> gr::basic_block::processor_affinity ( )
inlinevirtual

Reimplemented in gr::block, and gr::hier_block2.

void gr::basic_block::rpc_set ( )
inline

When the block is registered with the RPC, set this.

void gr::basic_block::set_block_alias ( std::string  name)
void gr::basic_block::set_color ( vcolor  color)
inlineprotected

Allow the flowgraph to set for sorting and partitioning.

void gr::basic_block::set_input_signature ( gr::io_signature::sptr  iosig)
inlineprotected

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::blocks::nop 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 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 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)
inlineprotected

may only be called during constructor

virtual void gr::basic_block::set_processor_affinity ( const std::vector< int > &  mask)
inlinevirtual

Reimplemented in gr::block, and gr::hier_block2.

virtual void gr::basic_block::setup_rpc ( )
inlinevirtual

Set up the RPC registered variables.

This must be overloaded by a block that wants to use controlport. This is where rpcbasic_register_{get,set} pointers are created, which then get wrapped as shared pointers (rpcbasic_sptr(...)) and stored using add_rpc_variable.

Reimplemented in gr::top_block, and gr::fft::ctrlport_probe_psd_impl.

std::string gr::basic_block::symbol_name ( ) const
inline
long gr::basic_block::symbolic_id ( ) const
inline
basic_block_sptr gr::basic_block::to_basic_block ( )
long gr::basic_block::unique_id ( ) const
inline
virtual void gr::basic_block::unset_processor_affinity ( )
inlinevirtual

Reimplemented in gr::block, and gr::hier_block2.

Friends And Related Function Documentation

friend class flat_flowgraph
friend
friend class flowgraph
friend
friend class tpb_thread_body
friend

Member Data Documentation

vcolor gr::basic_block::d_color
protected
gr::io_signature::sptr gr::basic_block::d_input_signature
protected
pmt::pmt_t gr::basic_block::d_message_subscribers
protected
std::string gr::basic_block::d_name
protected
gr::io_signature::sptr gr::basic_block::d_output_signature
protected
bool gr::basic_block::d_rpc_set
protected
std::vector<boost::any> gr::basic_block::d_rpc_vars
protected
std::string gr::basic_block::d_symbol_alias
protected
std::string gr::basic_block::d_symbol_name
protected
long gr::basic_block::d_symbolic_id
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: