Essentia  2.1-beta5-dev
Configurable Class Referenceabstract

#include <configurable.h>

Inheritance diagram for Configurable:
Algorithm Algorithm AccumulatorAlgorithm AlgorithmComposite Copy< TokenType > DevNull< TokenType > DiskWriter< T > FileOutput< TokenType, StorageType > PoolStorageBase RingBufferInput RingBufferOutput RingBufferVectorOutput StreamingAlgorithmWrapper VectorInput< TokenType, acquireSize > VectorOutput< TokenType, StorageType >

Public Member Functions

virtual ~Configurable ()
 
const std::string & name () const
 
void setName (const std::string &name)
 
virtual void declareParameters ()=0
 
virtual void setParameters (const ParameterMap &params)
 
virtual void configure (const ParameterMap &params)
 
virtual void configure ()
 
const ParameterMapdefaultParameters () const
 
const Parameterparameter (const std::string &key) const
 

Public Attributes

DescriptionMap parameterDescription
 
DescriptionMap parameterRange
 

Protected Member Functions

void declareParameter (const std::string &name, const std::string &desc, const std::string &range, const Parameter &defaultValue)
 

Protected Attributes

std::string _name
 
ParameterMap _params
 
ParameterMap _defaultParams
 

Detailed Description

A Configurable instance is an object that has a given name, and can be configured using a certain number of Parameters. These parameters have to be declared beforehand using the declareParameters method.

Whenever a Configurable instance gets reconfigured with new parameters, it will first save them internally and then call the configure() method. You should reimplement this method and do anything necessary for your object to be up-to-date and synchronized with the new parameters. These are accessible using the parameter() method.

Constructor & Destructor Documentation

◆ ~Configurable()

virtual ~Configurable ( )
inlinevirtual

Member Function Documentation

◆ configure() [1/2]

virtual void configure ( const ParameterMap params)
virtual

Set the given parameters as the current ones and reconfigure the object.

See also
setParameters

Reimplemented in StreamingAlgorithmWrapper.

Referenced by StreamingAlgorithmWrapper::configure().

◆ configure() [2/2]

virtual void configure ( )
inlinevirtual

This function will be automatically called after some parameters have been set. This is the place where you should write your specific code which needs to be called when configuring this object.

You can access the newly set parameters using the parameter() method.

Reimplemented in StreamingAlgorithmWrapper, FileOutput< TokenType, StorageType >, RingBufferInput, RingBufferOutput, and RingBufferVectorOutput.

◆ declareParameter()

void declareParameter ( const std::string &  name,
const std::string &  desc,
const std::string &  range,
const Parameter defaultValue 
)
protected

Use this method to declare the list of parameters that this algorithm in the declareParameters() method. If a Parameter doesn't have a default value, use its type instead, e.g.: Parameter::STRING, or Parameter::VECTOR_REAL, etc...

Referenced by RingBufferOutput::declareParameters(), RingBufferVectorOutput::declareParameters(), RingBufferInput::declareParameters(), and FileOutput< TokenType, StorageType >::declareParameters().

◆ declareParameters()

virtual void declareParameters ( )
pure virtual

Declare the parameters that this Configurable can accept. You have to implement this method in derived classes, even though you don't need any parameters. In that case, just define it as empty.

In this method you should only be calling the declareParameter method, once for each parameter, with optional default values.

Implemented in VectorInput< TokenType, acquireSize >, StreamingAlgorithmWrapper, PoolStorage< TokenType, StorageType >, FileOutput< TokenType, StorageType >, DiskWriter< T >, Copy< TokenType >, VectorOutput< TokenType, StorageType >, DevNull< TokenType >, RingBufferInput, RingBufferOutput, and RingBufferVectorOutput.

Referenced by StreamingAlgorithmWrapper::declareParameters().

◆ defaultParameters()

const ParameterMap& defaultParameters ( ) const
inline

Return a map filled with the parameters that have been declared, along with their default value if defined.

Referenced by StreamingAlgorithmWrapper::declareParameters().

◆ name()

◆ parameter()

const Parameter& parameter ( const std::string &  key) const
inline

Returns the parameter corresponding to the given name.

References AP, and P.

Referenced by FileOutput< TokenType, StorageType >::configure().

◆ setName()

◆ setParameters()

virtual void setParameters ( const ParameterMap params)
virtual

Set the given parameters as the current ones. Parameters which are not redefined will keep their old values, while this method will throw an EssentiaException if passing it an unknown parameter (i.e.: not declared using declareParameters() ). As a general rule, it is better to use the configure(const ParameterMap&) method, but in certain cases you may want to set parameters without reconfiguring the object.

Reimplemented in StreamingAlgorithmWrapper.

Referenced by StreamingAlgorithmWrapper::setParameters().

Member Data Documentation

◆ _defaultParams

ParameterMap _defaultParams
protected

◆ _name

◆ _params

◆ parameterDescription

◆ parameterRange


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