HARDT - The Ham Radio DSP Toolkit
Public Member Functions | Static Public Member Functions | List of all members
HCustomWriter< T > Class Template Reference

#include <hcustomwriter.h>

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

Public Member Functions

 HCustomWriter (std::function< int(T *, size_t)> customWriteFunc)
 
 HCustomWriter (std::function< int(T *, size_t)> customWriteFunc, HWriterConsumer< T > *consumer)
 
int Write (T *src, size_t blocksize)
 
bool Start ()
 
bool Stop ()
 
bool Command (HCommand *command)
 
- Public Member Functions inherited from HWriter< T >
virtual ~HWriter ()=default
 
HWriter< T > * Writer ()
 
- Public Member Functions inherited from HObject
 HObject ()
 

Static Public Member Functions

static HCustomWriter< T > * Create (int(*customWriteFunc)(T *, size_t blocksize))
 
static HCustomWriter< T > * Create (int(*customWriteFunc)(T *, size_t blocksize), HWriterConsumer< T > *consumer)
 
template<typename F >
static HCustomWriter< T > * Create (F *customWriterObject, int(F::*customWriteFunc)(T *, size_t blocksize))
 
template<typename F >
static HCustomWriter< T > * Create (F *customWriterObject, int(F::*customWriteFunc)(T *, size_t blocksize), HWriterConsumer< T > *consumer)
 

Detailed Description

template<class T>
class HCustomWriter< T >

Provide a HWriter interface by wrapping a call to a function defined by your code.

You must provide a std::function<T> object initialized with a function with the signature 'int func(T* src, size_t blocksize)' where T is the base integer type in use.

The easiest way to create a customwriter is to use one of the factory methods Create(). They can either take a function pointer to a static (or global) function, or a function pointer to a member function in a given object.

When used as a writer, each call to Write() will the call your local 'function()' with the input sample buffer and the number of input samples. Your custom writer function must return the number of samples written (or consumed).

Examples
saq.cpp.

Constructor & Destructor Documentation

◆ HCustomWriter() [1/2]

template<class T >
HCustomWriter< T >::HCustomWriter ( std::function< int(T *, size_t)>  customWriteFunc)
inline

Construct a HCustomWriter that wraps a function "int func(T* data, size_t size){}" by use of std::function

◆ HCustomWriter() [2/2]

template<class T >
HCustomWriter< T >::HCustomWriter ( std::function< int(T *, size_t)>  customWriteFunc,
HWriterConsumer< T > *  consumer 
)
inline

Construct a new HCustomWriter that wraps a function "int func(T* data, size_t size){}" by use of std::function and registers with an upstream writer

Member Function Documentation

◆ Command()

template<class T >
bool HCustomWriter< T >::Command ( HCommand command)
inlinevirtual

Receive, handle and propagate command

Returns: True if the command was executed correctly False otherwise. Errors is written to the error log

Implements HWriter< T >.

◆ Create() [1/4]

template<class T >
template<typename F >
static HCustomWriter<T>* HCustomWriter< T >::Create ( F *  customWriterObject,
int(F::*)(T *, size_t blocksize)  customWriteFunc 
)
inlinestatic

Factory function to create a new HCustomWriter by wrapping a member function function "int F::func(T* data, size_t size){}"

◆ Create() [2/4]

template<class T >
template<typename F >
static HCustomWriter<T>* HCustomWriter< T >::Create ( F *  customWriterObject,
int(F::*)(T *, size_t blocksize)  customWriteFunc,
HWriterConsumer< T > *  consumer 
)
inlinestatic

Factory function to create a new HCustomWriter by wrapping a member function function "int F::func(T* data, size_t size){}" and register with an upstream writer

◆ Create() [3/4]

template<class T >
static HCustomWriter<T>* HCustomWriter< T >::Create ( int(*)(T *, size_t blocksize)  customWriteFunc)
inlinestatic

Factory function to create a new HCustomWriter by wrapping a static function "int func(T* data, size_t size){}"

Examples
saq.cpp.

◆ Create() [4/4]

template<class T >
static HCustomWriter<T>* HCustomWriter< T >::Create ( int(*)(T *, size_t blocksize)  customWriteFunc,
HWriterConsumer< T > *  consumer 
)
inlinestatic

Factory function to create a new HCustomWriter by wrapping a static function "int func(T* data, size_t size){}" and register with an upstream writer

◆ Start()

template<class T >
bool HCustomWriter< T >::Start ( )
inlinevirtual

Initialize before first write

Reimplemented from HWriter< T >.

◆ Stop()

template<class T >
bool HCustomWriter< T >::Stop ( )
inlinevirtual

Cleanup after last write

Reimplemented from HWriter< T >.

◆ Write()

template<class T >
int HCustomWriter< T >::Write ( T *  src,
size_t  blocksize 
)
inlinevirtual

Write a block of data

Implements HWriter< T >.


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