A ModelTransformer turns one data model into another. More...

#include <ModelTransformer.h>

Inheritance diagram for ModelTransformer:
Inheritance graph
Collaboration diagram for ModelTransformer:
Collaboration graph

Classes

class  Input
 

Public Types

typedef std::vector< ModelIdModels
 
enum  Type { RTThread, NonRTThread }
 

Public Slots

void start ()
 

Public Member Functions

virtual ~ModelTransformer ()
 
void abandon ()
 Hint to the processing thread that it should give up, for example because the process is going to exit or the model/document context is being replaced. More...
 
bool isAbandoned () const
 Return true if the processing thread is being or has been abandoned, i.e. More...
 
ModelId getInputModel ()
 Return the input model for the transform. More...
 
int getInputChannel ()
 Return the input channel spec for the transform. More...
 
Models getOutputModels ()
 Return the set of output model IDs created by the transform or transforms. More...
 
virtual Models getAdditionalOutputModels ()
 Return any additional models that were created during processing. More...
 
virtual bool willHaveAdditionalOutputModels ()
 Return true if the current transform is one that may produce additional models (to be retrieved through getAdditionalOutputModels above). More...
 
QString getMessage () const
 Return a warning or error message. More...
 

Protected Member Functions

 ModelTransformer (Input input, const Transform &transform)
 
 ModelTransformer (Input input, const Transforms &transforms)
 
virtual void awaitOutputModels ()=0
 
void run () override=0
 

Protected Attributes

Transforms m_transforms
 
Input m_input
 
Models m_outputs
 
bool m_abandoned
 
QString m_message
 

Detailed Description

A ModelTransformer turns one data model into another.

Typically in this application, a ModelTransformer might have a DenseTimeValueModel as its input (e.g. an audio waveform) and a SparseOneDimensionalModel (e.g. detected beats) as its output.

The ModelTransformer typically runs in the background, as a separate thread populating the output model. The model is available to the user of the ModelTransformer immediately, but may be initially empty until the background thread has populated it.

Definition at line 37 of file ModelTransformer.h.

Member Typedef Documentation

typedef std::vector<ModelId> ModelTransformer::Models

Definition at line 42 of file ModelTransformer.h.

Member Enumeration Documentation

enum Thread::Type
inherited
Enumerator
RTThread 
NonRTThread 

Definition at line 29 of file Thread.h.

Constructor & Destructor Documentation

ModelTransformer::~ModelTransformer ( )
virtual

Definition at line 32 of file ModelTransformer.cpp.

References m_abandoned.

ModelTransformer::ModelTransformer ( Input  input,
const Transform transform 
)
protected

Definition at line 18 of file ModelTransformer.cpp.

References m_transforms.

Referenced by getMessage().

ModelTransformer::ModelTransformer ( Input  input,
const Transforms transforms 
)
protected

Definition at line 25 of file ModelTransformer.cpp.

Member Function Documentation

void ModelTransformer::abandon ( )
inline

Hint to the processing thread that it should give up, for example because the process is going to exit or the model/document context is being replaced.

Caller should still wait() to be sure that processing has ended.

Definition at line 66 of file ModelTransformer.h.

References m_abandoned.

Referenced by FeatureExtractionModelTransformer::addFeature(), RealTimeEffectModelTransformer::run(), and FeatureExtractionModelTransformer::run().

bool ModelTransformer::isAbandoned ( ) const
inline

Return true if the processing thread is being or has been abandoned, i.e.

if abandon() has been called.

Definition at line 72 of file ModelTransformer.h.

References m_abandoned.

Referenced by ModelTransformerFactory::transformerFinished().

int ModelTransformer::getInputChannel ( )
inline

Return the input channel spec for the transform.

Definition at line 82 of file ModelTransformer.h.

References ModelTransformer::Input::getChannel(), and m_input.

Models ModelTransformer::getOutputModels ( )
inline

Return the set of output model IDs created by the transform or transforms.

Returns an empty list if any transform could not be initialised; an error message may be available via getMessage() in this situation. The returned models have been added to ModelById.

Definition at line 91 of file ModelTransformer.h.

References awaitOutputModels(), and m_outputs.

Referenced by ModelTransformerFactory::transformMultiple().

virtual Models ModelTransformer::getAdditionalOutputModels ( )
inlinevirtual

Return any additional models that were created during processing.

This might happen if, for example, a transform was configured to split a multi-bin output into separate single-bin models as it processed. These should not be queried until after the transform has completed.

Reimplemented in FeatureExtractionModelTransformer.

Definition at line 103 of file ModelTransformer.h.

Referenced by ModelTransformerFactory::transformerFinished().

virtual bool ModelTransformer::willHaveAdditionalOutputModels ( )
inlinevirtual

Return true if the current transform is one that may produce additional models (to be retrieved through getAdditionalOutputModels above).

Reimplemented in FeatureExtractionModelTransformer.

Definition at line 110 of file ModelTransformer.h.

Referenced by ModelTransformerFactory::transformerFinished().

QString ModelTransformer::getMessage ( ) const
inline

Return a warning or error message.

If getOutputModel returned a null pointer, this should contain a fatal error message for the transformer; otherwise it may contain a warning to show to the user about e.g. suboptimal block size or whatever.

Definition at line 118 of file ModelTransformer.h.

References awaitOutputModels(), m_message, and ModelTransformer().

Referenced by ModelTransformerFactory::transformerFinished(), and ModelTransformerFactory::transformMultiple().

virtual void ModelTransformer::awaitOutputModels ( )
protectedpure virtual

Member Data Documentation


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