Pothos  0.4.0-gd11861cd
The Pothos dataflow programming software suite
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
Block.hpp
Go to the documentation of this file.
1 
11 #pragma once
12 #include <Pothos/Config.hpp>
18 #include <memory>
19 #include <string>
20 #include <vector>
21 #include <map>
22 
23 namespace Pothos {
24 
25  class BufferManager;
26 
37 {
38 public:
39 
41  explicit Block(void);
42 
44  virtual ~Block(void);
45 
47  void setThreadPool(const ThreadPool &threadPool);
48 
50  const ThreadPool &getThreadPool(void) const;
51 
52 protected:
53 
64  virtual void work(void);
65 
70  virtual void activate(void);
71 
76  virtual void deactivate(void);
77 
95  virtual void propagateLabels(const InputPort *input);
96 
107  virtual Object opaqueCallHandler(const std::string &name, const Object *inputArgs, const size_t numArgs);
108 
124  virtual std::shared_ptr<BufferManager> getInputBufferManager(const std::string &name, const std::string &domain);
125 
141  virtual std::shared_ptr<BufferManager> getOutputBufferManager(const std::string &name, const std::string &domain);
142 
143 public:
144 
148  std::vector<PortInfo> inputPortInfo(void);
149 
153  std::vector<PortInfo> outputPortInfo(void);
154 
158  InputPort *input(const std::string &name) const;
159 
163  InputPort *input(const size_t index) const;
164 
168  OutputPort *output(const std::string &name) const;
169 
173  OutputPort *output(const size_t index) const;
174 
181  const std::vector<InputPort*> &inputs(void) const;
182 
189  const std::vector<OutputPort*> &outputs(void) const;
190 
196  const std::map<std::string, InputPort*> &allInputs(void) const;
197 
203  const std::map<std::string, OutputPort*> &allOutputs(void) const;
204 
209  const WorkInfo &workInfo(void) const;
210 
217  bool isActive(void) const;
218 
230  InputPort *setupInput(const std::string &name, const DType &dtype = "", const std::string &domain = "");
231 
240  InputPort *setupInput(const size_t index, const DType &dtype = "", const std::string &domain = "");
241 
253  OutputPort *setupOutput(const std::string &name, const DType &dtype = "", const std::string &domain = "");
254 
263  OutputPort *setupOutput(const size_t index, const DType &dtype = "", const std::string &domain = "");
264 
271  void registerCallable(const std::string &name, const Callable &call);
272 
280  void registerSignal(const std::string &name);
281 
290  void registerSlot(const std::string &name);
291 
306  void registerProbe(
307  const std::string &name,
308  const std::string &signalName="",
309  const std::string &slotName="");
310 
320  void yield(void);
321 
327  template <typename... ArgsType>
328  void emitSignal(const std::string &name, ArgsType&&... args);
329 
337  Object opaqueCallMethod(const std::string &name, const Object *inputArgs, const size_t numArgs) const;
338 
339 private:
340  WorkInfo _workInfo;
341  std::vector<std::string> _inputPortNames;
342  std::vector<std::string> _outputPortNames;
343  std::vector<InputPort*> _indexedInputs;
344  std::vector<OutputPort*> _indexedOutputs;
345  std::map<std::string, InputPort*> _namedInputs;
346  std::map<std::string, OutputPort*> _namedOutputs;
347  std::multimap<std::string, Callable> _calls;
348  std::map<std::string, std::pair<std::string, std::string>> _probes;
349  ThreadPool _threadPool;
350  Block(const Block &){} // non construction-copyable
351  Block &operator=(const Block &){return *this;} // non copyable
352 public:
353  std::shared_ptr<WorkerActor> _actor;
354  friend class WorkerActor;
355 };
356 
357 } //namespace Pothos
Definition: WorkInfo.hpp:23
Definition: Connectable.hpp:41
#define POTHOS_API
Definition: Config.hpp:41
Definition: OutputPort.hpp:31
std::shared_ptr< WorkerActor > _actor
Definition: Block.hpp:353
Definition: Callable.hpp:30
Definition: ThreadPool.hpp:113
Definition: Object.hpp:55
Definition: InputPort.hpp:30
Definition: Block.hpp:36
Definition: DType.hpp:38