HARDT - The Ham Radio DSP Toolkit
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
HProcessor< T > Class Template Referenceabstract

#include <hprocessor.h>

Inheritance diagram for HProcessor< T >:
Inheritance graph
[legend]
Collaboration diagram for HProcessor< T >:
Collaboration graph
[legend]

Public Member Functions

int Read (T *dest, int blocksize)
 
int Write (T *src, int blocksize)
 
HReader< T > * GetReader ()
 
HWriter< T > * GetWriter ()
 
virtual void Run (long unsigned int blocks=0)
 
virtual void Halt ()
 
bool Command (H_COMMAND_CLASS commandClass, H_COMMAND_OPCODE commandOpcode, int32_t value)
 
bool Command (H_COMMAND_CLASS commandClass, H_COMMAND_OPCODE commandOpcode, int16_t length, void *content)
 
bool Command (H_COMMAND_CLASS commandClass, H_COMMAND_OPCODE commandOpcode, bool state)
 
virtual bool Command (H_COMMAND_CLASS commandClass, H_COMMAND_OPCODE commandOpcode, int16_t length, HCommandData data)=0
 
HMetricsGetMetrics ()
 
- Public Member Functions inherited from HWriterConsumer< T >
HWriterConsumer< T > * Consumer ()
 
- Public Member Functions inherited from HObject
 HObject ()
 

Protected Member Functions

 HProcessor (HWriter< T > *writer, HReader< T > *reader, size_t blocksize, bool *terminationToken)
 
 HProcessor (HReader< T > *reader, size_t blocksize, bool *terminationToken)
 
 ~HProcessor ()
 
void SetWriter (HWriter< T > *writer)
 

Protected Attributes

HWriter< T > * _writer
 
HReader< T > * _reader
 

Detailed Description

template<class T>
class HProcessor< T >

The processor makes a Hardt application tick, it reads from a given reader component and writes the data to a writer class.

This allows you to split your DSP chain into one or more readers, and one or more writers. Readers sort of 'pull' data from reader endpoints and writers 'push' data to writer endpoints (typical a HOutput type), but it can also be a HNullWriter if you dont need to have the output.

When you have created your readers and writers, then create a processor with the last reader and first writer and then call Run() on the processor.

A processor will stop when it receives a zero-length read or if you call the Halt() method, or the bool variable pointed to by the 'terminationToken' parameter of the constructor is set to true (especially usefull if you have multiple threads or does signal handling).

Constructor & Destructor Documentation

◆ HProcessor() [1/2]

template<class T >
HProcessor< T >::HProcessor ( HWriter< T > *  writer,
HReader< T > *  reader,
size_t  blocksize,
bool *  terminationToken 
)
protected

Construct a new HProcessor

Parameters
writerThe writer
readerThe reader
blocksizeNumber of samples to read and write per cycle
terminationTokenThe termination token. Set to true to halt the processor

◆ HProcessor() [2/2]

template<class T >
HProcessor< T >::HProcessor ( HReader< T > *  reader,
size_t  blocksize,
bool *  terminationToken 
)
protected

Construct a new HProcessor

Parameters
readerThe reader
blocksizeNumber of samples to read and write per cycle
terminationTokenThe termination token. Set to true to halt the processor

◆ ~HProcessor()

template<class T >
HProcessor< T >::~HProcessor
protected

Default destructor

Member Function Documentation

◆ Command() [1/4]

template<class T >
bool HProcessor< T >::Command ( H_COMMAND_CLASS  commandClass,
H_COMMAND_OPCODE  commandOpcode,
bool  state 
)
inline

Send a command to the reader and writer chain of this processor

Parameters
commandClassClass of command
commandOpcodeOpcode of command
stateBool value to send as the data
Returns
True if the command was executed, false otherwise

◆ Command() [2/4]

template<class T >
virtual bool HProcessor< T >::Command ( H_COMMAND_CLASS  commandClass,
H_COMMAND_OPCODE  commandOpcode,
int16_t  length,
HCommandData  data 
)
pure virtual

Send a command to the reader and writer chain of this processor

Parameters
commandClassClass of command
commandOpcodeOpcode of command
lengthThe command data length (zero for int and bool values)
dataThe command data to send
Returns
True if the command was executed, false otherwise

Implemented in HNetworkProcessor< T >, and HStreamProcessor< T >.

◆ Command() [3/4]

template<class T >
bool HProcessor< T >::Command ( H_COMMAND_CLASS  commandClass,
H_COMMAND_OPCODE  commandOpcode,
int16_t  length,
void *  content 
)
inline

Send a command to the reader and writer chain of this processor

Parameters
commandClassClass of command
commandOpcodeOpcode of command
lengthLength of the data pointed to by 'content'
contentvoid* to the data to send as the data
Returns
True if the command was executed, false otherwise

◆ Command() [4/4]

template<class T >
bool HProcessor< T >::Command ( H_COMMAND_CLASS  commandClass,
H_COMMAND_OPCODE  commandOpcode,
int32_t  value 
)
inline

Send a command to the reader and writer chain of this processor

Parameters
commandClassClass of command
commandOpcodeOpcode of command
valueinteger value to send as the data
Returns
True if the command was executed, false otherwise

◆ GetMetrics()

template<class T >
HMetrics* HProcessor< T >::GetMetrics ( )
inline

Get the metrics object

◆ GetReader()

template<class T >
HReader< T > * HProcessor< T >::GetReader

Get the associated reader

Returns
A HReader*

◆ GetWriter()

template<class T >
HWriter< T > * HProcessor< T >::GetWriter

Get the associated writer

Returns
A HWriter*

◆ Halt()

template<class T >
void HProcessor< T >::Halt
virtual

Stop processing.

If the reader and writer is not destroyed, processing can be resumed by calling Run() once agan after setting the terminationToken to false

Reimplemented in HNetworkProcessor< T >.

◆ Read()

template<class T >
int HProcessor< T >::Read ( T *  dest,
int  blocksize 
)

Read directly from the associated reader

Parameters
destDestination buffer
blocksizeNumber of samples to read
Returns
Number of blocks read

◆ Run()

template<class T >
void HProcessor< T >::Run ( long unsigned int  blocks = 0)
virtual

Read from the reader and write to the writer.

Processing stops when a zero-length read is received, halt() is called or the associated terminationToken is set to true.

Parameters
blocksNumber of blocks to read or zero to read untill stopped (or null-read)

Reimplemented in HNetworkProcessor< T >, and HStreamProcessor< T >.

◆ SetWriter()

template<class T >
void HProcessor< T >::SetWriter ( HWriter< T > *  writer)
inlineprotectedvirtual

Set the writer

Parameters
writerThe writer to use

Implements HWriterConsumer< T >.

◆ Write()

template<class T >
int HProcessor< T >::Write ( T *  src,
int  blocksize 
)

Write directly to the associated writer

Parameters
srcSource buffer
blocksizeNumber of samples to write
Returns
Number of blocks written

Member Data Documentation

◆ _reader

template<class T >
HReader<T>* HProcessor< T >::_reader
protected

The reader used by this processor

◆ _writer

template<class T >
HWriter<T>* HProcessor< T >::_writer
protected

The writer used by this processor


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