svcore  1.9
ModelTransformer Class Reference

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

#include <ModelTransformer.h>

Inheritance diagram for ModelTransformer:
Collaboration diagram for ModelTransformer:

List of all members.

Classes

class  Input

Public Types

typedef std::vector< Model * > Models
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 we want to get rid of the input model.
ModelgetInputModel ()
 Return the input model for the transform.
int getInputChannel ()
 Return the input channel spec for the transform.
Models getOutputModels ()
 Return the set of output models created by the transform or transforms.
Models detachOutputModels ()
 Return the set of output models, also detaching them from the transformer so that they will not be deleted when the transformer is.
virtual Models getAdditionalOutputModels ()
 Return any additional models that were created during processing.
virtual bool willHaveAdditionalOutputModels ()
 Return true if the current transform is one that may produce additional models (to be retrieved through getAdditionalOutputModels above).
virtual Models detachAdditionalOutputModels ()
 Return the set of additional models, also detaching them from the transformer.
QString getMessage () const
 Return a warning or error message.

Protected Member Functions

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

Protected Attributes

Transforms m_transforms
Input m_input
Models m_outputs
bool m_detached
bool m_detachedAdd
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 38 of file ModelTransformer.h.


Member Typedef Documentation

typedef std::vector<Model *> ModelTransformer::Models

Definition at line 43 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 ( Input  input,
const Transform transform 
) [protected]

Definition at line 18 of file ModelTransformer.cpp.

References m_transforms.

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

Definition at line 27 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 we want to get rid of the input model.

Caller should still wait() and/or delete the transform before assuming its input and output models are no longer required.

Definition at line 68 of file ModelTransformer.h.

References m_abandoned.

Referenced by ModelTransformerFactory::modelAboutToBeDeleted(), and FeatureExtractionModelTransformer::setCompletion().

Return the input channel spec for the transform.

Definition at line 78 of file ModelTransformer.h.

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

Return the set of output models 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.

Definition at line 86 of file ModelTransformer.h.

References m_outputs.

Referenced by detachOutputModels(), ModelTransformerFactory::modelAboutToBeDeleted(), and ~ModelTransformer().

Return the set of output models, also detaching them from the transformer so that they will not be deleted when the transformer is.

The caller takes ownership of the models.

Definition at line 93 of file ModelTransformer.h.

References getOutputModels(), and m_detached.

Referenced by ModelTransformerFactory::transformMultiple().

virtual Models ModelTransformer::getAdditionalOutputModels ( ) [inline, virtual]

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 105 of file ModelTransformer.h.

Referenced by detachAdditionalOutputModels(), and ~ModelTransformer().

virtual bool ModelTransformer::willHaveAdditionalOutputModels ( ) [inline, virtual]

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 112 of file ModelTransformer.h.

Referenced by ModelTransformerFactory::transformerFinished().

Return the set of additional models, also detaching them from the transformer.

The caller takes ownership of the models.

Definition at line 118 of file ModelTransformer.h.

References getAdditionalOutputModels(), and m_detachedAdd.

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 129 of file ModelTransformer.h.

References m_message.

Referenced by ModelTransformerFactory::transformMultiple().


Member Data Documentation

bool ModelTransformer::m_detached [protected]

Definition at line 138 of file ModelTransformer.h.

Referenced by detachOutputModels(), and ~ModelTransformer().

Definition at line 139 of file ModelTransformer.h.

Referenced by detachAdditionalOutputModels(), and ~ModelTransformer().


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