Class dsp::test::TestSource
-
class TestSource : public dsp::Source
Class that imitates a Source of data, useful as a test harness for pipelines.
Subclassed by dsp::test::GaussianNoiseSource, dsp::test::ImpulsiveNoiseSource, dsp::test::KnownDataSource
Public Functions
-
TestSource(unsigned niterations = 1)
Construct a new TestSource object.
- Parameters:
niterations – number of operation iterations to perform.
-
TestSource(const char *name, unsigned niterations = 1)
Construct a new TestSource object.
- Parameters:
name – the name of the source.
niterations – number of operation iterations to perform.
-
virtual ~TestSource() = default
Destroy the TestSource object.
-
virtual void operation()
increment the number of iterations performed.
-
virtual Source *clone() const
Return a default constructed clone of self.
- Returns:
Source* clone of this object.
-
inline virtual Observation *get_info() const
Get the const Observation attributes that describe the source.
-
inline virtual Observation *get_info()
Get the mutable Observation attributes that describe the source.
-
virtual void set_output(TimeSeries *_output)
Set the TimeSeries object that is used to provide output to callers of the get_output method.
Note: this timeseries must be configured with meta-data, resized and filled with data by the caller to this method.
- Parameters:
_output – TimeSeries that will be returned by get_output
-
inline virtual TimeSeries *get_output()
Get the TimeSeries object used to store output data.
-
inline virtual bool has_output() const
Return true if this object has a TimeSeries object to store output data.
-
inline virtual uint64_t get_total_samples() const
Get the total number of time samples available (return 0 if unknown).
-
inline virtual uint64_t get_current_sample() const
Get the current time sample offset from the start of data.
-
inline virtual double get_current_time() const
Get the current time offset from the start of data in seconds.
-
inline virtual void seek_time(double second)
Seek to the specified time in seconds.
An exception is thrown if unable to seek.
-
inline virtual void set_total_time(double _second)
Truncate the time series at the specified second.
An exception is thrown if unable to set total samples.
-
inline virtual bool end_of_data() const
Return true when the end of data has been reached.
-
inline virtual void restart()
Return to the start of data, if possible.
-
inline virtual void close()
Close / shutdown / free any resources, if applicable.
-
inline virtual void set_block_size(uint64_t _block_size)
Set the desired number of time samples per segment output by the source.
-
inline virtual uint64_t get_block_size() const
Get the number of time samples per segment output by the source.
This may not be the same as the number specified by set_block_size owing to the intrinsic resolution of the source
-
inline virtual void set_overlap(uint64_t _overlap)
Set the number of time samples by which segments of output TimeSeries data overlap.
-
inline virtual uint64_t get_overlap() const
Get the number of time samples by which segments of output TimeSeries data overlap.
-
inline virtual bool get_order_supported(TimeSeries::Order) const
Return true if the source supports the specified output order.
-
virtual void set_output_order(TimeSeries::Order _order)
Set the order of the dimensions in the output TimeSeries.
-
inline virtual bool get_device_supported(Memory*) const
Return true if the source can operate on the specified device.
Children of the pure-virtual Memory base class are used as a proxy for device type. For example: A) if a pointer to MemoryHost is passed and the Source supports operation on CPU (host), then this function should return true; B) if a pointer to MemoryCUDA is passed and the Source does not support operation on GPU (device), then this function should return false.
-
inline virtual void set_device(Memory *_device_memory)
Set the device on which the source will operate.
See get_device_supported for notes on use of Memory as a proxy for device type.
Share any resources that can/should be shared between threads.
-
inline virtual void set_context(ThreadContext *context)
Set the mutual exclusion and condition used to protect shared resources.
-
TestSource(unsigned niterations = 1)