blockfactory  0.8
A framework for wrapping algorithms for dataflow programming
BlockInformation.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_BLOCKINFORMATION_H
10 #define BLOCKFACTORY_CORE_BLOCKINFORMATION_H
11 
12 #include "BlockFactory/Core/Port.h"
13 
14 #include <memory>
15 #include <string>
16 #include <tuple>
17 #include <utility>
18 #include <vector>
19 
20 namespace blockfactory {
21  namespace core {
22  class BlockInformation;
23  class ParameterMetadata;
24  class Parameters;
25  class Signal;
26  using InputPortsInfo = std::vector<Port::Info>;
27  using OutputPortsInfo = std::vector<Port::Info>;
28  using InputSignalPtr = std::shared_ptr<const blockfactory::core::Signal>;
29  using OutputSignalPtr = std::shared_ptr<blockfactory::core::Signal>;
30 
31  // List of possible keys for defining block options:
32  const std::string BlockOptionPrioritizeOrder = "wbt.BlockOptionPrioritizeOrder";
33  } // namespace core
34 } // namespace blockfactory
35 
57 {
58 public:
59  BlockInformation() = default;
60  virtual ~BlockInformation() = default;
61 
71  virtual bool getUniqueName(std::string& blockUniqueName) const = 0;
72 
73  // =====================
74  // BLOCK OPTIONS METHODS
75  // =====================
76 
84  virtual bool optionFromKey(const std::string& key, double& option) const = 0;
85 
86  // ==================
87  // PARAMETERS METHODS
88  // ==================
89 
98  virtual bool parseParameters(Parameters& parameters) = 0;
99 
110  virtual bool addParameterMetadata(const ParameterMetadata& paramMD) = 0;
111 
112  // ========================
113  // PORT INFORMATION SETTERS
114  // ========================
115 
128  virtual bool setPortsInfo(const InputPortsInfo& inputPortsInfo,
129  const OutputPortsInfo& outputPortsInfo) = 0;
130 
131  // ========================
132  // PORT INFORMATION GETTERS
133  // ========================
134 
141  virtual Port::Info getInputPortInfo(Port::Index idx) const = 0;
142 
149  virtual Port::Info getOutputPortInfo(Port::Index idx) const = 0;
150 
157  virtual Port::Size::Vector getInputPortWidth(const Port::Index idx) const = 0;
158 
165  virtual Port::Size::Vector getOutputPortWidth(const Port::Index idx) const = 0;
166 
173  virtual Port::Size::Matrix getInputPortMatrixSize(const Port::Index idx) const = 0;
174 
181  virtual Port::Size::Matrix getOutputPortMatrixSize(const Port::Index idx) const = 0;
182 
183  // =============
184  // BLOCK SIGNALS
185  // =============
186 
194  virtual InputSignalPtr getInputPortSignal(const Port::Index idx) const = 0;
195 
203  virtual OutputSignalPtr getOutputPortSignal(const Port::Index idx) const = 0;
204 };
205 
206 #endif // BLOCKFACTORY_CORE_BLOCKINFORMATION_H
virtual Port::Size::Vector getOutputPortWidth(const Port::Index idx) const =0
Get the size of a 1D output port.
Class for storing parameter metadata.
Definition: Parameter.h:59
std::shared_ptr< blockfactory::core::Signal > OutputSignalPtr
Definition: BlockInformation.h:29
virtual Port::Size::Matrix getOutputPortMatrixSize(const Port::Index idx) const =0
Get the size of a 2D output port.
virtual OutputSignalPtr getOutputPortSignal(const Port::Index idx) const =0
Get the signal connected to an output port.
size_t Index
The 0-based index of a port.
Definition: Port.h:39
virtual Port::Info getInputPortInfo(Port::Index idx) const =0
Get information of an input port.
Abstract class for storing generic core::Block properties.
Definition: BlockInformation.h:56
virtual bool getUniqueName(std::string &blockUniqueName) const =0
Get the unique name of the block instance.
Class for storing block&#39;s parameters.
Definition: Parameters.h:34
virtual Port::Size::Matrix getInputPortMatrixSize(const Port::Index idx) const =0
Get the size of a 2D input port.
std::vector< Port::Info > OutputPortsInfo
Definition: BlockInformation.h:27
Definition: Block.h:17
A container of port information.
Definition: Port.h:78
virtual bool addParameterMetadata(const ParameterMetadata &paramMD)=0
Add a parameter metadata.
int Vector
Definition: Port.h:98
virtual InputSignalPtr getInputPortSignal(const Port::Index idx) const =0
Get the signal connected to an input input port.
std::vector< Port::Info > InputPortsInfo
Definition: BlockInformation.h:26
std::shared_ptr< const blockfactory::core::Signal > InputSignalPtr
Definition: BlockInformation.h:28
struct{Rows rows Matrix
Definition: Port.h:104
virtual bool parseParameters(Parameters &parameters)=0
Parse the core::Block parameters.
const std::string BlockOptionPrioritizeOrder
Definition: BlockInformation.h:32
virtual bool setPortsInfo(const InputPortsInfo &inputPortsInfo, const OutputPortsInfo &outputPortsInfo)=0
Set input / output ports information.
virtual Port::Size::Vector getInputPortWidth(const Port::Index idx) const =0
Get the size of a 1D input port.
virtual Port::Info getOutputPortInfo(Port::Index idx) const =0
Get information of an output port.
virtual bool optionFromKey(const std::string &key, double &option) const =0
Convert a block option from its string identifier to a specific implementation.