Loading...
Searching...
No Matches
gr::top_block Class Reference
GNU Radio C++ Signal Processing Blocks » Top Block and Hierarchical Block Base Classes

Top-level hierarchical block representing a flowgraph. More...

`#include <gnuradio/top_block.h>`

## Public Member Functions

| ~top_block () override
void | run (int max_noutput_items=100000000)
| The simple interface to running a flowgraph.
void | start (int max_noutput_items=100000000)
void | stop ()
void | wait ()
void | lock () override
void | unlock () override
std::string | edge_list ()
std::string | msg_edge_list ()
void | dump ()
int | max_noutput_items ()
| Get the number of max noutput_items in the flowgraph.
void | set_max_noutput_items (int nmax)
| Set the maximum number of noutput_items in the flowgraph.
top_block_sptr | to_top_block ()
void | setup_rpc () override
| Set up the RPC registered variables.
Public Member Functions inherited from gr::hier_block2
| ~hier_block2 () override
opaque_self | self ()
| Return an object, representing the current block, which can be passed to connect.
void | connect (basic_block_sptr block)
| Add a stand-alone (possibly hierarchical) block to internal graph.
void | connect (basic_block_sptr src, int src_port, basic_block_sptr dst, int dst_port)
| Add gr-blocks or hierarchical blocks to internal graph and wire together.
void | msg_connect (basic_block_sptr src, pmt::pmt_t srcport, basic_block_sptr dst, pmt::pmt_t dstport)
| Add gr-blocks or hierarchical blocks to internal graph and wire together.
void | msg_connect (basic_block_sptr src, std::string srcport, basic_block_sptr dst, std::string dstport)
void | msg_disconnect (basic_block_sptr src, pmt::pmt_t srcport, basic_block_sptr dst, pmt::pmt_t dstport)
void | msg_disconnect (basic_block_sptr src, std::string srcport, basic_block_sptr dst, std::string dstport)
void | disconnect (basic_block_sptr block)
| Remove a gr-block or hierarchical block from the internal flowgraph.
void | disconnect (basic_block_sptr src, int src_port, basic_block_sptr dst, int dst_port)
| Disconnect a pair of gr-blocks or hierarchical blocks in internal flowgraph.
void | disconnect_all ()
| Disconnect all connections in the internal flowgraph.
int | max_output_buffer (size_t port=0)
| Returns max buffer size (itemcount) on output port `i`.
void | set_max_output_buffer (int max_output_buffer)
| Sets max buffer size (itemcount) on all output ports.
void | set_max_output_buffer (size_t port, int max_output_buffer)
| Sets max buffer size (itemcount) on output port `port`.
int | min_output_buffer (size_t port=0)
| Returns min buffer size (itemcount) on output port `i`.
void | set_min_output_buffer (int min_output_buffer)
| Sets min buffer size (itemcount) on all output ports.
void | set_min_output_buffer (size_t port, int min_output_buffer)
| Sets min buffer size (itemcount) on output port `port`.
flat_flowgraph_sptr | flatten () const
hier_block2_sptr | to_hier_block2 ()
bool | has_msg_port (pmt::pmt_t which_port) override
bool | message_port_is_hier (pmt::pmt_t port_id) override
bool | message_port_is_hier_in (pmt::pmt_t port_id) override
bool | message_port_is_hier_out (pmt::pmt_t port_id) override
void | message_port_register_hier_in (pmt::pmt_t port_id)
void | message_port_register_hier_out (pmt::pmt_t port_id)
void | set_processor_affinity (const std::vector< int > &mask) override
| Set the affinity of all blocks in hier_block2 to processor core `n`.
void | unset_processor_affinity () override
| Remove processor affinity for all blocks in hier_block2.
std::vector< int > | processor_affinity () override
| Get the current processor affinity.
void | set_log_level (const std::string &level) override
| Set the logger's output level.
std::string | log_level () override
| Get the logger's output level.
bool | all_min_output_buffer_p (void)
| Get if all block min buffers should be set.
bool | all_max_output_buffer_p (void)
| Get if all block max buffers should be set.
Public Member Functions inherited from gr::basic_block
pmt::pmt_t | message_subscribers (pmt::pmt_t port)
| ~basic_block () override
long | unique_id () const
long | symbolic_id () const
std::string | name () const
std::string | symbol_name () const
std::string | identifier () const
gr::io_signature::sptr | input_signature () const
gr::io_signature::sptr | output_signature () const
basic_block_sptr | to_basic_block ()
bool | alias_set () const
std::string | alias () const
pmt::pmt_t | alias_pmt () const
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)
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 ()
bool | empty_handled_p (pmt::pmt_t which_port)
| are all msg ports with handlers empty?
bool | empty_handled_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)
msg_queue_t::iterator | get_iterator (pmt::pmt_t which_port)
void | erase_msg (pmt::pmt_t which_port, msg_queue_t::iterator it)
const msg_queue_map_t & | get_msg_map (void) const
void | add_rpc_variable (rpcbasic_sptr s)
| Add an RPC variable (get or set).
bool | is_rpc_set ()
| Ask if this block has been registered to the RPC.
void | rpc_set ()
| When the block is registered with the RPC, set this.
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.
Public Member Functions inherited from gr::msg_accepter
| msg_accepter ()
| ~msg_accepter () override
void | post (pmt::pmt_t which_port, pmt::pmt_t msg) override
| send `msg` to `msg_accepter` on port `which_port`
Public Member Functions inherited from gr::messages::msg_accepter
| msg_accepter ()

## Protected Member Functions

| top_block (const std::string &name, bool catch_exceptions=true)
Protected Member Functions inherited from gr::hier_block2
| hier_block2 ()
| hier_block2 (const std::string &name, gr::io_signature::sptr input_signature, gr::io_signature::sptr output_signature)
Protected Member Functions inherited from gr::basic_block
| 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.
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
virtual 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)
template<typename Derived>
std::shared_ptr< Derived > | shared_from_base ()
| This is meant to be called by derived classes (e.g. block) to get a shared pointer internally. This is needed because std::enable_shared_from_this doesn't seem to work with derived classes in an inheritance hierarchy.

## Additional Inherited Members

Public Types inherited from gr::hier_block2
typedef basic_block_sptr | opaque_self
| typedef for object returned from self().
Public Attributes inherited from gr::hier_block2
pmt::pmt_t | hier_message_ports_in
pmt::pmt_t | hier_message_ports_out
Protected Types inherited from gr::basic_block
enum | vcolor { WHITE , GREY , BLACK }
Protected Attributes inherited from gr::basic_block
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
gr::logger_ptr | d_logger
gr::logger_ptr | d_debug_logger
| Default logger.
msg_queue_map_t | msg_queue
| Verbose logger.
std::vector< rpcbasic_sptr > | d_rpc_vars
pmt::pmt_t | d_message_subscribers

## Detailed Description

Top-level hierarchical block representing a flowgraph.

## Constructor & Destructor Documentation

## top_block()

gr::top_block::top_block | ( | const std::string & | name,
|  | bool | catch_exceptions = true )

protected

References gr::basic_block::name().

## ~top_block()

gr::top_block::~top_block | ( |  | ) |

override

## Member Function Documentation

## dump()

void gr::top_block::dump | ( |  | ) |

Displays flattened flowgraph edges and block connectivity

## edge_list()

std::string gr::top_block::edge_list | ( |  | ) |

Returns a string that lists the edge connections in the flattened flowgraph.

## lock()

void gr::top_block::lock | ( |  | ) |

override virtual

Lock a flowgraph in preparation for reconfiguration. When an equal number of calls to lock() and unlock() have occurred, the flowgraph will be reconfigured.

N.B. lock() and unlock() may not be called from a flowgraph thread (E.g., block::work method) or deadlock will occur when reconfiguration happens.

Reimplemented from gr::hier_block2.

## max_noutput_items()

int gr::top_block::max_noutput_items | ( |  | ) |

Get the number of max noutput_items in the flowgraph.

Referenced by run(), and start().

## msg_edge_list()

std::string gr::top_block::msg_edge_list | ( |  | ) |

Returns a string that lists the msg edge connections in the flattened flowgraph.

## run()

void gr::top_block::run | ( | int | max_noutput_items = 100000000 | ) |

The simple interface to running a flowgraph.

Calls start() then wait(). Used to run a flowgraph that will stop on its own, or when another thread will call stop().

Parameters

  max_noutput_items | the maximum number of output items allowed for any block in the flowgraph. This passes through to the start function; see that function for more details.

References max_noutput_items().

## set_max_noutput_items()

void gr::top_block::set_max_noutput_items | ( | int | nmax | ) |

Set the maximum number of noutput_items in the flowgraph.

## setup_rpc()

void gr::top_block::setup_rpc | ( |  | ) |

override virtual

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 from gr::basic_block.

## start()

void gr::top_block::start | ( | int | max_noutput_items = 100000000 | ) |

Start the contained flowgraph. Creates one or more threads to execute the flow graph. Returns to the caller once the threads are created. Calling start() on a top_block that is already started IS an error.

Parameters

  max_noutput_items | the maximum number of output items allowed for any block in the flowgraph; the noutput_items can always be less than this, but this will cap it as a maximum. Use this to adjust the maximum latency a flowgraph can exhibit.

References max_noutput_items().

## stop()

void gr::top_block::stop | ( |  | ) |

Stop the running flowgraph. Notifies each thread created by the scheduler to shutdown, then returns to caller. Calling stop() on a top_block that is already stopped IS NOT an error.

## to_top_block()

top_block_sptr gr::top_block::to_top_block | ( |  | ) |

## unlock()

void gr::top_block::unlock | ( |  | ) |

override virtual

Unlock a flowgraph in preparation for reconfiguration. When an equal number of calls to lock() and unlock() have occurred, the flowgraph will be reconfigured.

N.B. lock() and unlock() may not be called from a flowgraph thread (E.g., block::work method) or deadlock will occur when reconfiguration happens.

Reimplemented from gr::hier_block2.

## wait()

void gr::top_block::wait | ( |  | ) |

Wait for a flowgraph to complete. Flowgraphs complete when either (1) all blocks indicate that they are done (typically only when using blocks.file_source, or blocks.head, or (2) after stop() has been called to request shutdown. Calling wait on a top_block that is not running IS NOT an error (wait returns w/o blocking).

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

- top_block.h