FunctionCat.h
Go to the documentation of this file.
1 #ifndef WIRECELLTBB_FUNCTIONCAT
2 #define WIRECELLTBB_FUNCTIONCAT
3 
6 
7 #include <iostream> // temporary, don't ignore the error code, chump!
8 
9 namespace WireCellTbb {
10 
11 
12  // Body for a TBB function node.
13  class FunctionBody {
15  public:
17  m_wcnode = std::dynamic_pointer_cast<WireCell::IFunctionNodeBase>(wcnode);
18  }
19  virtual ~FunctionBody() {}
20 
21  boost::any operator() (const boost::any &in) const {
22  boost::any ret;
23  bool ok = (*m_wcnode)(in, ret); // fixme: don't ignore the error code!
24  if (!ok) {
25  std::cerr << "I'm ignoring the error code!\n";
26  }
27  return ret;
28  }
29 
30  };
31 
32  // Wrap the TBB (compound) node
33  class FunctionWrapper : public NodeWrapper {
34  tbb::flow::graph_node *m_tbbnode;
35 
36  public:
37 
39  : m_tbbnode(new function_node(graph, wcnode->concurrency(), FunctionBody(wcnode)))
40  {
41  }
42 
44  return { dynamic_cast< receiver_type* >(m_tbbnode) };
45  }
46 
48  return { dynamic_cast< sender_type* >(m_tbbnode) };
49  }
50  };
51 
52 
53 }
54 
55 #endif
std::shared_ptr< IFunctionNodeBase > pointer
Definition: IFunctionNode.h:16
boost::any operator()(const boost::any &in) const
Definition: FunctionCat.h:21
def graph(desc, maker=maker)
Definition: apa.py:294
virtual receiver_port_vector receiver_ports()
Definition: FunctionCat.h:43
virtual sender_port_vector sender_ports()
Definition: FunctionCat.h:47
FunctionBody(WireCell::INode::pointer wcnode)
Definition: FunctionCat.h:16
tbb::flow::graph_node * m_tbbnode
Definition: FunctionCat.h:34
std::shared_ptr< Interface > pointer
Definition: Interface.h:16
std::vector< receiver_type * > receiver_port_vector
Definition: NodeWrapper.h:19
tbb::flow::sender< boost::any > sender_type
Definition: NodeWrapper.h:15
WireCell::IFunctionNodeBase::pointer m_wcnode
Definition: FunctionCat.h:14
FunctionWrapper(tbb::flow::graph &graph, WireCell::INode::pointer wcnode)
Definition: FunctionCat.h:38
std::vector< sender_type * > sender_port_vector
Definition: NodeWrapper.h:18
tbb::flow::function_node< boost::any, boost::any > function_node
Definition: NodeWrapper.h:30
tbb::flow::receiver< boost::any > receiver_type
Definition: NodeWrapper.h:16