GNU Radio C++ API Reference: gr::buffer_reader Class Reference

| GNU Radio C++ API Reference 3.10.12.0 The Free & Open Software Radio Ecosystem |

Loading...
Searching...
No Matches
gr::buffer_reader Class Reference
Implementation Details

How we keep track of the readers of a gr::buffer. More...

`#include <gnuradio/buffer_reader.h>`

## Public Member Functions
virtual | ~buffer_reader ()
void | declare_sample_delay (unsigned delay)
unsigned | sample_delay () const
virtual int | items_available () const
| Return number of items available for reading.
buffer_sptr | buffer () const
| Return buffer this reader reads from.
int | max_possible_items_available () const
| Return maximum number of items that could ever be available for reading. This is used as a sanity check in the scheduler to avoid looping forever.
const void * | read_pointer ()
| return pointer to read buffer.
void | update_read_pointer (int nitems)
void | set_done (bool done)
bool | done () const
gr::thread::mutex * | mutex ()
uint64_t | nitems_read () const
void | reset_nitem_counter ()
size_t | get_sizeof_item ()
block_sptr | link () const
| Return the block that reads via this reader.
void | get_tags_in_range (std::vector< tag_t > &v, uint64_t abs_start, uint64_t abs_end, long id)
| Given a [start,end), returns a vector all tags in the range.
virtual bool | input_blkd_cb_ready (int items_required) const
| Returns true when the current thread is ready to call the callback, false otherwise. Delegate calls to buffer class's input_blkd_cb_ready(). Note if input_blocked_callback is overridden then this function should also be overridden.
virtual bool | input_blocked_callback (int items_required, int items_avail)
| Callback function that the scheduler will call when it determines that the input is blocked. Delegate calls to buffer class's input_blocked_callback(). Override this function if needed.
unsigned int | get_read_index () const
uint64_t | get_abs_read_offset () const

## Protected Member Functions
| buffer_reader (buffer_sptr buffer, unsigned int read_index, block_sptr link)
| constructor is private. Use gr::buffer::add_reader to create instances

## Protected Attributes
buffer_sptr | d_buffer
unsigned int | d_read_index
uint64_t | d_abs_read_offset
std::weak_ptr< block > | d_link
unsigned | d_attr_delay

## Friends
class | buffer
class | buffer_double_mapped
class | buffer_single_mapped
class | buffer_reader_sm
GR_RUNTIME_API buffer_reader_sptr | buffer_add_reader (buffer_sptr buf, int nzero_preload, block_sptr link=block_sptr(), int delay=0)
| Create a new gr::buffer_reader and attach it to buffer `buf`.

## Detailed Description

How we keep track of the readers of a gr::buffer.

## Constructor & Destructor Documentation

## ◆ ~buffer_reader()

virtual gr::buffer_reader::~buffer_reader | ( |  | ) |
| virtual

## ◆ buffer_reader()

gr::buffer_reader::buffer_reader | ( | buffer_sptr | buffer,
|  | unsigned int | read_index,
|  | block_sptr | link )
| protected

constructor is private. Use gr::buffer::add_reader to create instances

References buffer, and link().

## Member Function Documentation

## ◆ buffer()

buffer_sptr gr::buffer_reader::buffer | ( |  | ) | const
| inline

Return buffer this reader reads from.

References d_buffer.

## ◆ declare_sample_delay()

void gr::buffer_reader::declare_sample_delay | ( | unsigned | delay | ) |

Declares the sample delay for this reader.

See gr::block::declare_sample_delay for details.

Parameters

  delay | The new sample delay

## ◆ done()

bool gr::buffer_reader::done | ( |  | ) | const
| inline

References d_buffer.

Referenced by set_done().

## ◆ get_abs_read_offset()

uint64_t gr::buffer_reader::get_abs_read_offset | ( |  | ) | const
| inline

References d_abs_read_offset.

## ◆ get_read_index()

unsigned int gr::buffer_reader::get_read_index | ( |  | ) | const
| inline

References d_read_index.

## ◆ get_sizeof_item()

size_t gr::buffer_reader::get_sizeof_item | ( |  | ) |
| inline

References d_buffer.

## ◆ get_tags_in_range()

void gr::buffer_reader::get_tags_in_range | ( | std::vector< tag_t > & | v,
|  | uint64_t | abs_start,
|  | uint64_t | abs_end,
|  | long | id )

Given a [start,end), returns a vector all tags in the range.

Get a vector of tags in given range. Range of counts is from start to end-1.

Tags are tuples of: (item count, source id, key, value)

Parameters

  v | a vector reference to return tags into
  abs_start | a uint64 count of the start of the range of interest
  abs_end | a uint64 count of the end of the range of interest
  id | the unique ID of the block to make sure already deleted tags are not returned

## ◆ input_blkd_cb_ready()

virtual bool gr::buffer_reader::input_blkd_cb_ready | ( | int | items_required | ) | const
| inlinevirtual

Returns true when the current thread is ready to call the callback, false otherwise. Delegate calls to buffer class's input_blkd_cb_ready(). Note if input_blocked_callback is overridden then this function should also be overridden.

Reimplemented in gr::buffer_reader_sm.

## ◆ input_blocked_callback()

virtual bool gr::buffer_reader::input_blocked_callback | ( | int | items_required,
|  | int | items_avail )
| inlinevirtual

Callback function that the scheduler will call when it determines that the input is blocked. Delegate calls to buffer class's input_blocked_callback(). Override this function if needed.

Reimplemented in gr::buffer_reader_sm.

## ◆ items_available()

virtual int gr::buffer_reader::items_available | ( |  | ) | const
| virtual

Return number of items available for reading.

Reimplemented in gr::buffer_reader_sm.

## ◆ link()

block_sptr gr::buffer_reader::link | ( |  | ) | const
| inline

Return the block that reads via this reader.

References d_link.

Referenced by buffer_add_reader, gr::buffer_reader_sm::buffer_add_reader, and buffer_reader().

## ◆ max_possible_items_available()

int gr::buffer_reader::max_possible_items_available | ( |  | ) | const
| inline

Return maximum number of items that could ever be available for reading. This is used as a sanity check in the scheduler to avoid looping forever.

References d_buffer.

## ◆ mutex()

gr::thread::mutex * gr::buffer_reader::mutex | ( |  | ) |
| inline

References d_buffer.

## ◆ nitems_read()

uint64_t gr::buffer_reader::nitems_read | ( |  | ) | const
| inline

References d_abs_read_offset.

## ◆ read_pointer()

const void * gr::buffer_reader::read_pointer | ( |  | ) |

return pointer to read buffer.

The return value points to items_available() number of items

## ◆ reset_nitem_counter()

void gr::buffer_reader::reset_nitem_counter | ( |  | ) |
| inline

References d_abs_read_offset, and d_read_index.

## ◆ sample_delay()

unsigned gr::buffer_reader::sample_delay | ( |  | ) | const

Gets the sample delay for this reader.

See gr::block::sample_delay for details.

## ◆ set_done()

void gr::buffer_reader::set_done | ( | bool | done | ) |
| inline

References d_buffer, and done().

## ◆ update_read_pointer()

void gr::buffer_reader::update_read_pointer | ( | int | nitems | ) |

## Friends And Related Symbol Documentation

## ◆ buffer

friend class buffer
| friend

References buffer.

Referenced by buffer, and buffer_reader().

## ◆ buffer_add_reader

GR_RUNTIME_API buffer_reader_sptr buffer_add_reader | ( | buffer_sptr | buf,
|  | int | nzero_preload,
|  | block_sptr | link = block_sptr(),
|  | int | delay = 0 )
| friend

Create a new gr::buffer_reader and attach it to buffer `buf`.

Parameters

  buf | is the buffer the `gr::buffer_reader` reads from.
  nzero_preload | – number of zero items to "preload" into buffer.
  link | is the block that reads from the buffer using this gr::buffer_reader.
  delay | Optional setting to declare the buffer's sample delay.

References GR_RUNTIME_API, and link().

## ◆ buffer_double_mapped

friend class buffer_double_mapped
| friend

References buffer_double_mapped.

Referenced by buffer_double_mapped.

## ◆ buffer_reader_sm

friend class buffer_reader_sm
| friend

References buffer_reader_sm.

Referenced by buffer_reader_sm.

## ◆ buffer_single_mapped

friend class buffer_single_mapped
| friend

References buffer_single_mapped.

Referenced by buffer_single_mapped.

## Member Data Documentation

## ◆ d_abs_read_offset

uint64_t gr::buffer_reader::d_abs_read_offset
| protected

Referenced by get_abs_read_offset(), nitems_read(), and reset_nitem_counter().

## ◆ d_attr_delay

unsigned gr::buffer_reader::d_attr_delay
| protected

## ◆ d_buffer

buffer_sptr gr::buffer_reader::d_buffer
| protected

Referenced by buffer(), done(), get_sizeof_item(), max_possible_items_available(), mutex(), and set_done().

## ◆ d_link

std::weak_ptr<block> gr::buffer_reader::d_link
| protected

Referenced by link().

## ◆ d_read_index

unsigned int gr::buffer_reader::d_read_index
| protected

Referenced by get_read_index(), and reset_nitem_counter().

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

- buffer_reader.h