blockfactory  0.8
A framework for wrapping algorithms for dataflow programming
Block.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * GNU Lesser General Public License v2.1 or any later version.
7  */
8 
9 #ifndef BLOCKFACTORY_CORE_BLOCK_H
10 #define BLOCKFACTORY_CORE_BLOCK_H
11 
13 
14 #include <string>
15 #include <vector>
16 
17 namespace blockfactory {
18  namespace core {
19  class Block;
20  class BlockInformation;
21  } // namespace core
22 } // namespace blockfactory
23 
83 {
84 protected:
87 
88 public:
92  virtual ~Block() = default;
93 
100  std::string getUniqueName(const BlockInformation* blockInfo) const;
101 
108  static constexpr unsigned NumberOfParameters = 2;
109 
117  virtual unsigned numberOfParameters();
118 
127  virtual std::vector<std::string> additionalBlockOptions();
128 
138  virtual unsigned numberOfDiscreteStates();
139 
148  virtual unsigned numberOfContinuousStates();
149 
158  virtual bool updateDiscreteState(const BlockInformation* blockInfo);
159 
166  virtual bool stateDerivative(const BlockInformation* blockInfo);
167 
179  virtual bool parameterAtIndexIsTunable(unsigned index);
180 
210  virtual bool parseParameters(BlockInformation* blockInfo);
211 
221  bool getParameters(blockfactory::core::Parameters& params) const;
222 
244  virtual bool configureSizeAndPorts(BlockInformation* blockInfo);
245 
255  virtual bool initialize(BlockInformation* blockInfo);
256 
270  virtual bool initializeInitialConditions(const BlockInformation* blockInfo);
271 
282  virtual bool terminate(const BlockInformation* blockInfo);
283 
293  virtual bool output(const BlockInformation* blockInfo) = 0;
294 };
295 
296 #endif // BLOCKFACTORY_CORE_BLOCK_H
virtual unsigned numberOfParameters()
Returns the number of configuration parameters needed by this block.
Parameters m_parameters
Container for block parameters. You can get this member using Block::getParameters.
Definition: Block.h:86
std::string getUniqueName(const BlockInformation *blockInfo) const
Get the unique name of the block instance.
bool getParameters(blockfactory::core::Parameters &params) const
Gather all the stored parameters.
virtual std::vector< std::string > additionalBlockOptions()
Returns the vector of additional block options.
virtual bool initialize(BlockInformation *blockInfo)
Initialize the block.
virtual bool configureSizeAndPorts(BlockInformation *blockInfo)
Configure the input and output ports.
virtual bool terminate(const BlockInformation *blockInfo)
Cleanup block resources.
virtual unsigned numberOfContinuousStates()
Returns the number of continuous states of the block.
Abstract class for storing generic core::Block properties.
Definition: BlockInformation.h:56
Basic abstract class for wrapping generic algorithms.
Definition: Block.h:82
virtual bool stateDerivative(const BlockInformation *blockInfo)
Update the internal continuous state.
virtual unsigned numberOfDiscreteStates()
Returns the number of discrete states of the block.
Class for storing block&#39;s parameters.
Definition: Parameters.h:34
virtual bool updateDiscreteState(const BlockInformation *blockInfo)
Update the internal discrete state.
virtual bool output(const BlockInformation *blockInfo)=0
Compute the output of the block.
Definition: Block.h:17
virtual bool parseParameters(BlockInformation *blockInfo)
Parse the parameters stored into the core::BlockInformation object.
static constexpr unsigned NumberOfParameters
Number of parameters of core::Block.
Definition: Block.h:108
virtual bool parameterAtIndexIsTunable(unsigned index)
Specify if the parameter at the specified index is tunable.
virtual ~Block()=default
Destructor.
virtual bool initializeInitialConditions(const BlockInformation *blockInfo)
Initialize block initial conditions.