WrapperFactory.h
Go to the documentation of this file.
1 #ifndef WIRECELLTBB_WRAPPERFACTORY
2 #define WIRECELLTBB_WRAPPERFACTORY
3 
4 #include "WireCellIface/INode.h"
6 
7 namespace WireCellTbb {
8 
9  // Make a node wrapper for every type of node category
10  struct WrapperMaker {
11  virtual ~WrapperMaker() {}
13  };
14  template<class Wrapper>
15  struct WrapperMakerT : public WrapperMaker {
16  virtual ~WrapperMakerT() {}
18  return Node(new Wrapper(g,n));
19  }
20  };
21 
23  public:
25 
26  template<class Wrapper>
28  m_factory[cat] = new WrapperMakerT<Wrapper>;
29  }
30 
32 
33  typedef std::map<WireCell::INode::pointer, Node> WCNode2Wrapper;
34  WCNode2Wrapper& seen() { return m_nodes; }
35  private:
36  typedef std::map<WireCell::INode::NodeCategory, WrapperMaker*> NodeMakers;
37 
39  NodeMakers m_factory;
40  WCNode2Wrapper m_nodes;
41  };
42 
43 
44 };
45 
46 #endif
def graph(desc, maker=maker)
Definition: apa.py:294
static const double g
Definition: Units.h:145
virtual Node operator()(tbb::flow::graph &g, WireCell::INode::pointer n)
std::shared_ptr< NodeWrapper > Node
Definition: NodeWrapper.h:51
void bind_maker(WireCell::INode::NodeCategory cat)
std::shared_ptr< Interface > pointer
Definition: Interface.h:16
tbb::flow::graph & m_graph
WCNode2Wrapper & seen()
std::map< WireCell::INode::pointer, Node > WCNode2Wrapper
std::map< WireCell::INode::NodeCategory, WrapperMaker * > NodeMakers
std::size_t n
Definition: format.h:3399
virtual Node operator()(tbb::flow::graph &g, WireCell::INode::pointer n)=0