FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
SignalBlock.h
1#ifndef FHSIM_BASE_SIGNALBLOCK_H
2#define FHSIM_BASE_SIGNALBLOCK_H
3
4#include <fhsim/simobject/SimObject.h>
5
6#include <string>
7#include <vector>
8
9namespace fhsim_base {
10
17class SignalBlock : public SimObject
18{
19 public:
21 enum class PortWidthRule
22 {
25 };
26
33 SignalBlock(const std::string& name, ISimObjectCreator* creator, PortWidthRule rule = PortWidthRule::DefaultOne);
34
42 static int ReadCount(ISimObjectCreator* creator, const std::string& name, int defaultValue);
43
45 static int ReadCount(ISimObjectCreator* creator, const std::string& name);
46
47 protected:
49 int PortWidth() const { return m_portWidth; }
50
61 std::vector<double> ReadScalarOrVector(ISimObjectCreator* creator, const std::string& name, double defaultValue) const;
62
68 std::vector<double> ReadScalarOrVector(ISimObjectCreator* creator, const std::string& name) const;
69
71 std::vector<double> m_out;
72
73 private:
74 int m_portWidth;
75};
76
77} // namespace fhsim_base
78
79#endif
Definition SignalBlock.h:18
std::vector< double > m_out
The output buffer, PortWidth() elements. A block may resize it, for example to the width of an output...
Definition SignalBlock.h:71
std::vector< double > ReadScalarOrVector(ISimObjectCreator *creator, const std::string &name, double defaultValue) const
SignalBlock(const std::string &name, ISimObjectCreator *creator, PortWidthRule rule=PortWidthRule::DefaultOne)
static int ReadCount(ISimObjectCreator *creator, const std::string &name, int defaultValue)
PortWidthRule
Whether the parameter PortWidth must be in the input file.
Definition SignalBlock.h:22
@ DefaultOne
Not in the file: the width is 1.
@ Required
Not in the file: an error is reported.
int PortWidth() const
The number of elements in the signals of the block (the parameter PortWidth).
Definition SignalBlock.h:49
static int ReadCount(ISimObjectCreator *creator, const std::string &name)
As above for a count that must be in the file.
std::vector< double > ReadScalarOrVector(ISimObjectCreator *creator, const std::string &name) const