libsdr  0.1.0
A simple SDR library
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
sdr::BlockingSource Class Referenceabstract

Iterface of a blocking source. More...

#include <node.hh>

Inheritance diagram for sdr::BlockingSource:
sdr::Source

Public Member Functions

 BlockingSource (bool parallel=false, bool connect_idle=true, bool stop_queue_on_eos=false)
 Constructor. More...
 
virtual ~BlockingSource ()
 Destructor. More...
 
virtual void next ()=0
 This method gets called either by the Queue on idle events or by a thread to read more data from the input stream. More...
 
bool isActive () const
 Returns true if the source is active. More...
 
virtual void start ()
 This function starts the input stream. More...
 
virtual void stop ()
 This function stops the input stream. More...
 
- Public Member Functions inherited from sdr::Source
 Source ()
 Constructor. More...
 
virtual ~Source ()
 Destructor. More...
 
virtual void send (const RawBuffer &buffer, bool allow_overwrite=false)
 Sends the given buffer to all connected sinks. More...
 
void connect (SinkBase *sink, bool direct=false)
 Connect this source to a sink. More...
 
void disconnect (SinkBase *sink)
 Disconnect a sink again. More...
 
virtual void setConfig (const Config &config)
 Stores the configuration and propergates it if the configuration has been changed. More...
 
virtual double sampleRate () const
 Returns the configured sample rate or 0 otherwise. More...
 
virtual Config::Type type () const
 Returns the configured source type or Config::Type_UNDEFINED otherwise. More...
 
template<class T >
void addEOS (T *instance, void(T::*function)())
 Adds a callback to the end-of-stream signal of the source. More...
 

Protected Member Functions

void _parallel_main ()
 The parallel main loop. More...
 
void _nonvirt_idle_cb ()
 The non-virtual idle callback. More...
 
- Protected Member Functions inherited from sdr::Source
void signalEOS ()
 Signals the EOS. More...
 
void propagateConfig (const Config &config)
 Propagates the given configuration to all connected sinks. More...
 

Protected Attributes

bool _is_active
 If true, the source is active. More...
 
bool _is_parallel
 If true, the surce is processed in parallel. More...
 
pthread_t _thread
 The thread of the source. More...
 
- Protected Attributes inherited from sdr::Source
Config _config
 Holds the source configuration, this can be updated by calling setConfig. More...
 
std::map< SinkBase *, bool > _sinks
 The connected sinks. More...
 
std::list< DelegateInterface * > _eos
 The connected EOS singal handlers. More...
 

Detailed Description

Iterface of a blocking source.

Blocking sources are usually input sources that wait for data from a device or file. Please note, a proper input source that reads data from a file should emmit the eos signal using the signalEOS method. This can be used to stop the Queue loop once the input can not provide data anymore.

Constructor & Destructor Documentation

BlockingSource::BlockingSource ( bool  parallel = false,
bool  connect_idle = true,
bool  stop_queue_on_eos = false 
)

Constructor.

Parameters
parallelSpecifies whether the source is waiting in a separate thread for new data.
connect_idleSpecifies wheter the input source next() method should be connected to the idle signal of the Queue.
stop_queue_on_eosSignals the that the Queue should be stopped once the EOS is reached. Use this flag only if this source is the only source in the data stream.
BlockingSource::~BlockingSource ( )
virtual

Destructor.

Member Function Documentation

void BlockingSource::_nonvirt_idle_cb ( )
protected

The non-virtual idle callback.

void BlockingSource::_parallel_main ( )
protected

The parallel main loop.

bool sdr::BlockingSource::isActive ( ) const
inline

Returns true if the source is active.

virtual void sdr::BlockingSource::next ( )
pure virtual

This method gets called either by the Queue on idle events or by a thread to read more data from the input stream.

The next function should be blocking in order to avoid busy waiting on incomming data.

void BlockingSource::start ( )
virtual

This function starts the input stream.

void BlockingSource::stop ( )
virtual

This function stops the input stream.

Member Data Documentation

bool sdr::BlockingSource::_is_active
protected

If true, the source is active.

bool sdr::BlockingSource::_is_parallel
protected

If true, the surce is processed in parallel.

pthread_t sdr::BlockingSource::_thread
protected

The thread of the source.


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