Public Types | Public Member Functions | Private Types | Private Attributes | List of all members
WireCell::Pgraph::Factory Class Reference

#include <Factory.h>

Public Types

typedef std::map< INode::pointer, Node * > WCNodeWrapperMap
 

Public Member Functions

 Factory ()
 
template<class Wrapper >
void bind_maker (INode::NodeCategory cat)
 
Nodeoperator() (WireCell::INode::pointer wcnode)
 

Private Types

typedef std::map< INode::NodeCategory, Maker * > NodeMakers
 

Private Attributes

NodeMakers m_factory
 
WCNodeWrapperMap m_nodes
 
Log::logptr_t l
 

Detailed Description

Definition at line 28 of file Factory.h.

Member Typedef Documentation

Definition at line 44 of file Factory.h.

Definition at line 33 of file Factory.h.

Constructor & Destructor Documentation

Factory::Factory ( )

Definition at line 6 of file Factory.cxx.

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 }
logptr_t logger(std::string name)
Definition: Logging.cxx:71
Log::logptr_t l
Definition: Factory.h:47

Member Function Documentation

template<class Wrapper >
void WireCell::Pgraph::Factory::bind_maker ( INode::NodeCategory  cat)
inline

Definition at line 36 of file Factory.h.

36  {
37  m_factory[cat] = new MakerT<Wrapper>;
38  }
NodeMakers m_factory
Definition: Factory.h:45
Node * Factory::operator() ( WireCell::INode::pointer  wcnode)

Definition at line 23 of file Factory.cxx.

23  {
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
#define THROW(e)
Definition: Exceptions.h:25
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

Member Data Documentation

Log::logptr_t WireCell::Pgraph::Factory::l
private

Definition at line 47 of file Factory.h.

NodeMakers WireCell::Pgraph::Factory::m_factory
private

Definition at line 45 of file Factory.h.

WCNodeWrapperMap WireCell::Pgraph::Factory::m_nodes
private

Definition at line 46 of file Factory.h.


The documentation for this class was generated from the following files: