SourceCat.h
Go to the documentation of this file.
1 /** Facade/adapter to TBB for source node category. */
2 #ifndef WIRECELLTBB_SOURCECAT
3 #define WIRECELLTBB_SOURCECAT
4 
7 
8 
9 namespace WireCellTbb {
10 
11 
12  // adapter to convert from WC source node to TBB source node body.
13  class SourceBody {
15  public:
17 
19  m_wcnode = std::dynamic_pointer_cast<WireCell::ISourceNodeBase>(wcnode);
20  }
21  bool operator()(boost::any& out) {
22  return (*m_wcnode)(out);
23  }
24  };
25 
26  // implement facade to access ports for source nodes
27  class SourceNodeWrapper : public NodeWrapper {
29  public:
31  : m_tbbnode(new source_node(graph, SourceBody(wcnode), false))
32  { }
34  delete m_tbbnode;
35  }
36  virtual void initialize() {
37  m_tbbnode->activate();
38  }
40  auto ptr = dynamic_cast< sender_type* >(m_tbbnode);
41  return sender_port_vector{ptr};
42  }
43  };
44 }
45 #endif
bool operator()(boost::any &out)
Definition: SourceCat.h:21
def graph(desc, maker=maker)
Definition: apa.py:294
tbb::flow::source_node< boost::any > source_node
Types for TBB nodes.
Definition: NodeWrapper.h:28
std::shared_ptr< Interface > pointer
Definition: Interface.h:16
virtual sender_port_vector sender_ports()
Definition: SourceCat.h:39
SourceNodeWrapper(tbb::flow::graph &graph, WireCell::INode::pointer wcnode)
Definition: SourceCat.h:30
tbb::flow::sender< boost::any > sender_type
Definition: NodeWrapper.h:15
const void * ptr(const T *p)
Definition: format.h:3138
std::shared_ptr< ISourceNodeBase > pointer
Definition: ISourceNode.h:16
SourceBody(WireCell::INode::pointer wcnode)
Definition: SourceCat.h:18
WireCell::ISourceNodeBase::pointer m_wcnode
Definition: SourceCat.h:14
std::vector< sender_type * > sender_port_vector
Definition: NodeWrapper.h:18