QueuedoutCat.h
Go to the documentation of this file.
1 /** This adapts the queued out node category to a TBB multifunction node.
2  */
3 
4 #ifndef WIRECELLTBB_QUEUEDOUT
5 #define WIRECELLTBB_QUEUEDOUT
6 
9 
10 namespace WireCellTbb {
11 
12 
13  class QueuedoutBody {
15  public:
18  m_wcnode = std::dynamic_pointer_cast<WireCell::IQueuedoutNodeBase>(wcnode);
19  }
20  void operator()(const boost::any& in, queuedout_port& out) {
22  bool ok = (*m_wcnode)(in, outq);
23  if (!ok) { return; } // fixme: do something better here!
24  for (auto a : outq) {
25  std::get<0>(out).try_put(a);
26  }
27  }
28  };
29  class QueuedoutWrapper : public NodeWrapper {
30  public:
31 
33  : m_tbbnode(new queuedout_node(graph, wcnode->concurrency(), QueuedoutBody(wcnode)))
34  { }
35  virtual ~QueuedoutWrapper() {
36  delete m_tbbnode; m_tbbnode = nullptr;
37  }
38 
40  auto ptr = dynamic_cast< receiver_type* >(m_tbbnode);
41  return receiver_port_vector{ptr};
42  }
43 
45  auto ptr = &tbb::flow::output_port<0>(*m_tbbnode);
46  return sender_port_vector{ptr};
47  }
48  private:
50  };
51 
52 }
53 #endif
virtual receiver_port_vector receiver_ports()
Definition: QueuedoutCat.h:39
def graph(desc, maker=maker)
Definition: apa.py:294
std::deque< boost::any > queuedany
void operator()(const boost::any &in, queuedout_port &out)
Definition: QueuedoutCat.h:20
std::shared_ptr< IQueuedoutNodeBase > pointer
virtual sender_port_vector sender_ports()
Definition: QueuedoutCat.h:44
QueuedoutBody(WireCell::INode::pointer wcnode)
Definition: QueuedoutCat.h:17
std::shared_ptr< Interface > pointer
Definition: Interface.h:16
tbb::flow::multifunction_node< boost::any, any_single > queuedout_node
Definition: NodeWrapper.h:31
std::vector< receiver_type * > receiver_port_vector
Definition: NodeWrapper.h:19
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1124
const void * ptr(const T *p)
Definition: format.h:3138
QueuedoutWrapper(tbb::flow::graph &graph, WireCell::INode::pointer wcnode)
Definition: QueuedoutCat.h:32
WireCell::IQueuedoutNodeBase::pointer m_wcnode
Definition: QueuedoutCat.h:14
std::vector< sender_type * > sender_port_vector
Definition: NodeWrapper.h:18
queuedout_node * m_tbbnode
Definition: QueuedoutCat.h:49
queuedout_node::output_ports_type queuedout_port
Definition: NodeWrapper.h:32
tbb::flow::receiver< boost::any > receiver_type
Definition: NodeWrapper.h:16