Essentia
2.1-beta6-dev
|
#include <accumulatoralgorithm.h>
Public Member Functions | |
AccumulatorAlgorithm () | |
AlgorithmStatus | process () |
void | reset () |
virtual void | consume ()=0 |
virtual void | finalProduce ()=0 |
void | declareInputStream (SinkBase &sink, const std::string &name, const std::string &desc, int preferredAcquireSize=4096) |
void | declareOutputResult (SourceBase &source, const std::string &name, const std::string &desc) |
Public Member Functions inherited from Algorithm | |
Algorithm () | |
virtual | ~Algorithm () |
SinkBase & | input (const std::string &name) |
SourceBase & | output (const std::string &name) |
SinkBase & | input (int idx) |
SourceBase & | output (int idx) |
const InputMap & | inputs () const |
const OutputMap & | outputs () const |
std::vector< std::string > | inputNames () const |
std::vector< std::string > | outputNames () const |
virtual void | shouldStop (bool stop) |
virtual bool | shouldStop () const |
void | disconnectAll () |
AlgorithmStatus | acquireData () |
void | releaseData () |
Public Member Functions inherited from Configurable | |
virtual | ~Configurable () |
const std::string & | name () const |
void | setName (const std::string &name) |
virtual void | declareParameters ()=0 |
virtual void | setParameters (const ParameterMap ¶ms) |
virtual void | configure (const ParameterMap ¶ms) |
virtual void | configure () |
const ParameterMap & | defaultParameters () const |
const Parameter & | parameter (const std::string &key) const |
Protected Member Functions | |
void | declareInput () |
void | declareOutput () |
Protected Member Functions inherited from Algorithm | |
void | declareInput (SinkBase &sink, const std::string &name, const std::string &desc) |
void | declareInput (SinkBase &sink, int n, const std::string &name, const std::string &desc) |
void | declareInput (SinkBase &sink, int acquireSize, int releaseSize, const std::string &name, const std::string &desc) |
void | declareOutput (SourceBase &source, const std::string &name, const std::string &desc) |
void | declareOutput (SourceBase &source, int n, const std::string &name, const std::string &desc) |
void | declareOutput (SourceBase &source, int acquireSize, int releaseSize, const std::string &name, const std::string &desc) |
Protected Member Functions inherited from Configurable | |
void | declareParameter (const std::string &name, const std::string &desc, const std::string &range, const Parameter &defaultValue) |
Protected Attributes | |
int | _preferredSize |
SinkBase * | _inputStream |
Protected Attributes inherited from Algorithm | |
bool | _shouldStop |
OutputMap | _outputs |
InputMap | _inputs |
int | nProcess |
Protected Attributes inherited from Configurable | |
std::string | _name |
ParameterMap | _params |
ParameterMap | _defaultParams |
Additional Inherited Members | |
Public Types inherited from Algorithm | |
typedef OrderedMap< SinkBase > | InputMap |
typedef OrderedMap< SourceBase > | OutputMap |
Public Attributes inherited from Algorithm | |
DescriptionMap | inputDescription |
DescriptionMap | outputDescription |
Public Attributes inherited from Configurable | |
DescriptionMap | parameterDescription |
DescriptionMap | parameterRange |
Static Public Attributes inherited from Algorithm | |
static const std::string | processingMode |
An AccumulatorAlgorithm is a special class of streaming algorithm that behaves in the following way:
By subclassing the AccumulatorAlgorithm class, you get all the buffering and data management done for you. In exchange, you just need to implement 2 methods:
You will also need to declare your input sink and output source using the specialized declareInputStream
and declareOutputResult
methods, instead of the standard declareInput
and declareOutput
ones.
As an example, please refer to the source code of the TCToTotal algorithm.
WARNING: declaring multiple input streams will result in undefined behavior. Multiple output results are fine, though.
WARNING: if you overload the reset() method, do not forget to call the base class implementation in it.
|
pure virtual |
|
protected |
void declareInputStream | ( | SinkBase & | sink, |
const std::string & | name, | ||
const std::string & | desc, | ||
int | preferredAcquireSize = 4096 |
||
) |
|
protected |
void declareOutputResult | ( | SourceBase & | source, |
const std::string & | name, | ||
const std::string & | desc | ||
) |
|
pure virtual |
|
virtual |
Implements Algorithm.
|
virtual |
This function will be called when doing batch computations between each file that is processed. That is, if your algorithm is some sort of state machine, it allows you to reset it to its original state to process another file without having to delete and reinstantiate it. This function should not be called directly. Use resetNetwork instead to reset a network of connected Algorithms.
Reimplemented from Algorithm.
|
protected |
|
protected |