TbbFlow.cxx
Go to the documentation of this file.
1 #include "WireCellTbb/TbbFlow.h"
2 
4 #include "WireCellUtil/String.h"
5 #include "WireCellUtil/Persist.h"
6 
7 #include <string>
8 #include <iostream>
9 
11 
12 using namespace WireCell;
13 using namespace WireCellTbb;
14 
15 TbbFlow::TbbFlow()
16 {
17 }
18 
19 TbbFlow::~TbbFlow()
20 {
21 }
22 
23 Configuration TbbFlow::default_configuration() const
24 {
25  std::string json = R"(
26 {
27 "dfp": "TbbDataFlowGraph",
28 "graph":[]
29 }
30 )";
31  return Persist::loads(json);
32 }
33 
35 {
36  std::string type, name, desc = get<std::string>(cfg, "dfp","TbbDataFlowGraph");
37  std::tie(type,name) = String::parse_pair(desc);
38  m_dfp = Factory::lookup<IDataFlowGraph>(type, name);
39 
40  m_dfpgraph.configure(cfg["graph"]);
41 
42 }
43 
44 void TbbFlow::execute()
45 {
46  if (!m_dfp) {
47  std::cerr << "TbbFlow: not configured\n";
48  return;
49  }
50 
51  std::cerr << "TbbFlow::Execute\n";
52 
53  for (auto thc : m_dfpgraph.connections()) {
54  auto tail_tn = get<0>(thc);
55  auto head_tn = get<1>(thc);
56  auto conn = get<2>(thc);
57 
58  std::cerr << "TbbFlow: Connect: "
59  << tail_tn.type << ":" << tail_tn.name
60  << " ( " << conn.tail << " -> " << conn.head << " ) "
61  << head_tn.type << ":" << head_tn.name << "\n";
62 
63  INode::pointer tail_node = WireCell::Factory::lookup<INode>(tail_tn.type, tail_tn.name);
64  INode::pointer head_node = WireCell::Factory::lookup<INode>(head_tn.type, head_tn.name);
65 
66  m_dfp->connect(tail_node, head_node, conn.tail, conn.head);
67  }
68 
69 
70  m_dfp->run();
71 }
72 
static QCString name
Definition: declinfo.cpp:673
std::string string
Definition: nybbler.cc:12
std::pair< std::string, std::string > parse_pair(const std::string &in, const std::string &delim=":")
Definition: String.cxx:15
cfg
Definition: dbjson.py:29
def configure(cfg)
Definition: cuda.py:34
std::shared_ptr< Interface > pointer
Definition: Interface.h:16
Definition: Main.h:22
Json::Value loads(const std::string &text, const externalvars_t &extvar=externalvars_t(), const externalvars_t &extcode=externalvars_t())
Definition: Persist.cxx:152
WIRECELL_FACTORY(TbbFlow, WireCellTbb::TbbFlow, WireCell::IApplication, WireCell::IConfigurable)
std::string type(const T &t)
Definition: Type.h:20
conn
Definition: dbjson.py:16
Json::Value Configuration
Definition: Configuration.h:50