blockfactory  0.8
A framework for wrapping algorithms for dataflow programming
blockfactory::core::BlockInformation Class Referenceabstract

Abstract class for storing generic core::Block properties. More...

#include <BlockInformation.h>

Inheritance diagram for blockfactory::core::BlockInformation:
[legend]

Detailed Description

Abstract class for storing generic core::Block properties.

core::BlockInformation provides an interface for handling implementation-specific properties such as input / output number, size and type, number of parameters, ...

A core::Block needs to know on what kind of data it operates, and retrieving this information is often specific on the framework on top of which blocks run. In order to allow using the same core::Block class from different frameworks (e.g. Simulink, C++, etc), different implementation of this interface can be developed to provide a transparent translation of such functionalities.

As an example, take the core::BlockInformation::parseParameters. In Simulink, parameters are read from the block masks and Matlab provides APIs for reading them. The mex::SimulinkBlockInformation implementation will use those APIs. However, if you want to call the same block class (which is just a wrapper of an algorithm) from a pure C++ main, parameters are read e.g. from an xml file. In this case, core::BlockInformation::parseParameters will parse the xml and fill the core::Parameters argument.

See also
core::Block, core::Parameters, core::Signal, core::Port

Public Member Functions

 BlockInformation ()=default
 
virtual ~BlockInformation ()=default
 
virtual bool getUniqueName (std::string &blockUniqueName) const =0
 Get the unique name of the block instance. More...
 
virtual bool optionFromKey (const std::string &key, double &option) const =0
 Convert a block option from its string identifier to a specific implementation. More...
 
virtual bool parseParameters (Parameters &parameters)=0
 Parse the core::Block parameters. More...
 
virtual bool addParameterMetadata (const ParameterMetadata &paramMD)=0
 Add a parameter metadata. More...
 
virtual bool setPortsInfo (const InputPortsInfo &inputPortsInfo, const OutputPortsInfo &outputPortsInfo)=0
 Set input / output ports information. More...
 
virtual Port::Info getInputPortInfo (Port::Index idx) const =0
 Get information of an input port. More...
 
virtual Port::Info getOutputPortInfo (Port::Index idx) const =0
 Get information of an output port. More...
 
virtual Port::Size::Vector getInputPortWidth (const Port::Index idx) const =0
 Get the size of a 1D input port. More...
 
virtual Port::Size::Vector getOutputPortWidth (const Port::Index idx) const =0
 Get the size of a 1D output port. More...
 
virtual Port::Size::Matrix getInputPortMatrixSize (const Port::Index idx) const =0
 Get the size of a 2D input port. More...
 
virtual Port::Size::Matrix getOutputPortMatrixSize (const Port::Index idx) const =0
 Get the size of a 2D output port. More...
 
virtual InputSignalPtr getInputPortSignal (const Port::Index idx) const =0
 Get the signal connected to an input input port. More...
 
virtual OutputSignalPtr getOutputPortSignal (const Port::Index idx) const =0
 Get the signal connected to an output port. More...
 

Constructor & Destructor Documentation

blockfactory::core::BlockInformation::BlockInformation ( )
default
virtual blockfactory::core::BlockInformation::~BlockInformation ( )
virtualdefault

Member Function Documentation

virtual bool blockfactory::core::BlockInformation::addParameterMetadata ( const ParameterMetadata paramMD)
pure virtual

Add a parameter metadata.

In order to gather parameters from the running engine, the block must pass their metadata.

Parameters
paramMDThe metadata to add.
Returns
True for success, false otherwise.
See also
core::BlockInformation::parseParameters

Implemented in blockfactory::mex::SimulinkBlockInformation, and blockfactory::coder::CoderBlockInformation.

virtual Port::Info blockfactory::core::BlockInformation::getInputPortInfo ( Port::Index  idx) const
pure virtual

Get information of an input port.

Parameters
idxThe index of the port.
Returns
A Port::Info object containing the port information.

Implemented in blockfactory::coder::CoderBlockInformation, and blockfactory::mex::SimulinkBlockInformation.

virtual Port::Size::Matrix blockfactory::core::BlockInformation::getInputPortMatrixSize ( const Port::Index  idx) const
pure virtual

Get the size of a 2D input port.

Parameters
idxThe index of the port.
Returns
The size of the port.

Implemented in blockfactory::coder::CoderBlockInformation, and blockfactory::mex::SimulinkBlockInformation.

virtual InputSignalPtr blockfactory::core::BlockInformation::getInputPortSignal ( const Port::Index  idx) const
pure virtual

Get the signal connected to an input input port.

Parameters
idxThe index of the port to which the signal is connected.
Returns
The pointer to the signal connected to the input port for success, a nullptr otherwise.

Implemented in blockfactory::coder::CoderBlockInformation, and blockfactory::mex::SimulinkBlockInformation.

virtual Port::Size::Vector blockfactory::core::BlockInformation::getInputPortWidth ( const Port::Index  idx) const
pure virtual

Get the size of a 1D input port.

Parameters
idxThe index of the port.
Returns
The size of the port.

Implemented in blockfactory::coder::CoderBlockInformation, and blockfactory::mex::SimulinkBlockInformation.

virtual Port::Info blockfactory::core::BlockInformation::getOutputPortInfo ( Port::Index  idx) const
pure virtual

Get information of an output port.

Parameters
idxThe index of the port.
Returns
A Port::Info object containing the port information.

Implemented in blockfactory::coder::CoderBlockInformation, and blockfactory::mex::SimulinkBlockInformation.

virtual Port::Size::Matrix blockfactory::core::BlockInformation::getOutputPortMatrixSize ( const Port::Index  idx) const
pure virtual

Get the size of a 2D output port.

Parameters
idxThe index of the port.
Returns
The size of the port.

Implemented in blockfactory::coder::CoderBlockInformation, and blockfactory::mex::SimulinkBlockInformation.

virtual OutputSignalPtr blockfactory::core::BlockInformation::getOutputPortSignal ( const Port::Index  idx) const
pure virtual

Get the signal connected to an output port.

Parameters
idxThe index of the port to which the signal is connected.
Returns
The pointer to the signal connected to the output port for success, a nullptr otherwise.

Implemented in blockfactory::coder::CoderBlockInformation, and blockfactory::mex::SimulinkBlockInformation.

virtual Port::Size::Vector blockfactory::core::BlockInformation::getOutputPortWidth ( const Port::Index  idx) const
pure virtual

Get the size of a 1D output port.

Parameters
idxThe index of the port.
Returns
The size of the port.

Implemented in blockfactory::coder::CoderBlockInformation, and blockfactory::mex::SimulinkBlockInformation.

virtual bool blockfactory::core::BlockInformation::getUniqueName ( std::string &  blockUniqueName) const
pure virtual

Get the unique name of the block instance.

Retrive from the engine the unique name of the block. A typical example is the scoped name of the block that takes into account its location in the model hierarchy.

Parameters
[out]blockUniqueNameThe unique name of the block instance.
Returns
True for success, false otherwise.

Implemented in blockfactory::mex::SimulinkBlockInformation, and blockfactory::coder::CoderBlockInformation.

virtual bool blockfactory::core::BlockInformation::optionFromKey ( const std::string &  key,
double &  option 
) const
pure virtual

Convert a block option from its string identifier to a specific implementation.

Parameters
[in]keyIdentifier of the block option.
[out]optionImplementation-specific block option.
Returns
True if the option has been converted, false otherwise.

Implemented in blockfactory::mex::SimulinkBlockInformation, and blockfactory::coder::CoderBlockInformation.

virtual bool blockfactory::core::BlockInformation::parseParameters ( Parameters parameters)
pure virtual

Parse the core::Block parameters.

This method allows defining how to gather block parameters from a specific implementation.

Parameters
[out]parametersA container filled with the parsed parameters.
Returns
True for success, false otherwise.

Implemented in blockfactory::mex::SimulinkBlockInformation, and blockfactory::coder::CoderBlockInformation.

virtual bool blockfactory::core::BlockInformation::setPortsInfo ( const InputPortsInfo inputPortsInfo,
const OutputPortsInfo outputPortsInfo 
)
pure virtual

Set input / output ports information.

Specify I/O ports information such as indices, dimensions, and datatype.

Parameters
inputPortsInfoVector of core::Port::Info objects storing input port information.
outputPortsInfoVector of core::Port::Info objects storing output port information.
Returns
True for success, false otherwise.
Note
This method also automatically set the number of input and output ports and should be called only once.

Implemented in blockfactory::coder::CoderBlockInformation, and blockfactory::mex::SimulinkBlockInformation.


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