Pothos  0.7.0-gf7fbae99
The Pothos dataflow programming software suite
BlockImpl.hpp
Go to the documentation of this file.
1 
11 #pragma once
16 #include <utility> //std::forward
17 
18 inline const Pothos::WorkInfo &Pothos::Block::workInfo(void) const
19 {
20  return _workInfo;
21 }
22 
23 inline Pothos::InputPort *Pothos::Block::input(const std::string &name) const
24 {
25  auto it = _namedInputs.find(name);
26  if (it == _namedInputs.end()) throw PortAccessError(
27  "Pothos::Block::input("+name+")", "input port name does not exist");
28  return it->second;
29 }
30 
31 inline Pothos::InputPort *Pothos::Block::input(const size_t index) const
32 {
33  if (index >= _indexedInputs.size()) throw PortAccessError(
34  "Pothos::Block::input("+std::to_string(index)+")", "input port index does not exist");
35  return _indexedInputs[index];
36 }
37 
38 inline Pothos::OutputPort *Pothos::Block::output(const std::string &name) const
39 {
40  auto it = _namedOutputs.find(name);
41  if (it == _namedOutputs.end()) throw PortAccessError(
42  "Pothos::Block::output("+name+")", "output port name does not exist");
43  return it->second;
44 }
45 
46 inline Pothos::OutputPort *Pothos::Block::output(const size_t index) const
47 {
48  if (index >= _indexedOutputs.size()) throw PortAccessError(
49  "Pothos::Block::output("+std::to_string(index)+")", "output port index does not exist");
50  return _indexedOutputs[index];
51 }
52 
53 inline const std::vector<Pothos::InputPort*> &Pothos::Block::inputs(void) const
54 {
55  return _indexedInputs;
56 }
57 
58 inline const std::vector<Pothos::OutputPort*> &Pothos::Block::outputs(void) const
59 {
60  return _indexedOutputs;
61 }
62 
63 inline const std::map<std::string, Pothos::InputPort*> &Pothos::Block::allInputs(void) const
64 {
65  return _namedInputs;
66 }
67 
68 inline const std::map<std::string, Pothos::OutputPort*> &Pothos::Block::allOutputs(void) const
69 {
70  return _namedOutputs;
71 }
72 
73 template <typename... ArgsType>
74 void Pothos::Block::emitSignal(const std::string &name, ArgsType&&... args)
75 {
76  const auto it = _namedOutputs.find(name);
77  if (it == _namedOutputs.end() or not it->second->isSignal()) throw PortAccessError(
78  "Pothos::Block::emitSignal("+name+")", "signal port does not exist");
79 
80  const ObjectVector objArgs{{Object(std::forward<ArgsType>(args))...}};
81  it->second->postMessage(std::move(objArgs));
82 }
InputPort * input(const std::string &name) const
Definition: BlockImpl.hpp:23
Definition: WorkInfo.hpp:23
Definition: OutputPort.hpp:31
const std::map< std::string, InputPort * > & allInputs(void) const
Definition: BlockImpl.hpp:63
Definition: Object.hpp:47
Definition: InputPort.hpp:30
const std::vector< InputPort * > & inputs(void) const
Definition: BlockImpl.hpp:53
std::vector< Object > ObjectVector
Definition: Containers.hpp:20
void emitSignal(const std::string &name, ArgsType &&... args)
Definition: BlockImpl.hpp:74
const std::vector< OutputPort * > & outputs(void) const
Definition: BlockImpl.hpp:58
const WorkInfo & workInfo(void) const
Definition: BlockImpl.hpp:18
OutputPort * output(const std::string &name) const
Definition: BlockImpl.hpp:38
const std::map< std::string, OutputPort * > & allOutputs(void) const
Definition: BlockImpl.hpp:68