Factory.cxx
Go to the documentation of this file.
3 
4 using namespace WireCell::Pgraph;
5 
7  : l(Log::logger("pgraph"))
8 {
9  // categories defined in INode.h.
10  // if it's not here, you ain't usin' it.
11  bind_maker<Source>(INode::sourceNode);
12  bind_maker<Sink>(INode::sinkNode);
13  bind_maker<Function>(INode::functionNode);
14  bind_maker<Queuedout>(INode::queuedoutNode);
15  bind_maker<Join>(INode::joinNode);
16  bind_maker<Split>(INode::splitNode);
17  bind_maker<Fanout>(INode::fanoutNode);
18  bind_maker<Fanin>(INode::faninNode);
19  bind_maker<Hydra>(INode::hydraNode);
20  // ...
21 }
22 
24  if (!wcnode) {
25  l->critical("factory given nullptr wcnode");
26  THROW(ValueError() << errmsg{"nullptr wcnode"});
27  }
28 
29  auto nit = m_nodes.find(wcnode);
30  if (nit != m_nodes.end()) {
31  return nit->second;
32  }
33  auto mit = m_factory.find(wcnode->category());
34  if (mit == m_factory.end()) {
35  l->critical("factory failed to find maker for category: {}",
36  wcnode->category());
37  THROW(ValueError() << errmsg{"failed to find maker"});
38  }
39  auto maker = mit->second;
40 
41  Node* node = (*maker)(wcnode);
42  m_nodes[wcnode] = node;
43  return node;
44 }
boost::error_info< struct tag_errmsg, std::string > errmsg
Definition: Exceptions.h:54
static QStrList * l
Definition: config.cpp:1044
Node * operator()(WireCell::INode::pointer wcnode)
Definition: Factory.cxx:23
std::shared_ptr< Interface > pointer
Definition: Interface.h:16
#define THROW(e)
Definition: Exceptions.h:25
logptr_t logger(std::string name)
Definition: Logging.cxx:71
Thrown when a wrong value has been encountered.
Definition: Exceptions.h:37
WCNodeWrapperMap m_nodes
Definition: Factory.h:46
NodeMakers m_factory
Definition: Factory.h:45
def maker(G, ac, typename)
Definition: apa.py:280
Log::logptr_t l
Definition: Factory.h:47