Pothos  0.2.1-g9f04573d
The Pothos dataflow programming software suite
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros
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 
229  void setupInput(const std::string &name, const DType &dtype = "", const std::string &domain = "");
230 
238  void setupInput(const size_t index, const DType &dtype = "", const std::string &domain = "");
239 
250  void setupOutput(const std::string &name, const DType &dtype = "", const std::string &domain = "");
251 
259  void setupOutput(const size_t index, const DType &dtype = "", const std::string &domain = "");
260 
267  void registerCallable(const std::string &name, const Callable &call);
268 
275  void registerSignal(const std::string &name);
276 
285  void registerSlot(const std::string &name);
286 
301  void registerProbe(
302  const std::string &name,
303  const std::string &signalName="",
304  const std::string &slotName="");
305 
315  void yield(void);
316 
324  Object opaqueCallMethod(const std::string &name, const Object *inputArgs, const size_t numArgs) const;
325 
326 private:
327  WorkInfo _workInfo;
328  std::vector<std::string> _inputPortNames;
329  std::vector<std::string> _outputPortNames;
330  std::vector<InputPort*> _indexedInputs;
331  std::vector<OutputPort*> _indexedOutputs;
332  std::map<std::string, InputPort*> _namedInputs;
333  std::map<std::string, OutputPort*> _namedOutputs;
334  std::multimap<std::string, Callable> _calls;
335  std::map<std::string, std::pair<std::string, std::string>> _probes;
336  ThreadPool _threadPool;
337  Block(const Block &){} // non construction-copyable
338  Block &operator=(const Block &){return *this;} // non copyable
339 public:
340  std::shared_ptr<WorkerActor> _actor;
341  friend class WorkerActor;
342 };
343 
344 } //namespace Pothos
Definition: WorkInfo.hpp:23
Definition: Connectable.hpp:39
#define POTHOS_API
Definition: Config.hpp:41
Definition: OutputPort.hpp:30
std::shared_ptr< WorkerActor > _actor
Definition: Block.hpp:340
Definition: Callable.tmpl.hpp:30
Definition: ThreadPool.hpp:113
Definition: Object.hpp:55
Definition: InputPort.hpp:30
Definition: Block.hpp:36
Definition: DType.hpp:38