NodeDumper.cxx
Go to the documentation of this file.
2 #include "WireCellUtil/String.h"
3 #include "WireCellUtil/Type.h"
6 #include "WireCellUtil/Persist.h"
7 #include "WireCellIface/INode.h"
8 #include "WireCellUtil/Logging.h"
9 
12 
13 
14 using spdlog::info;
15 using spdlog::warn;
16 
17 using namespace std;
18 using namespace WireCell;
19 using namespace WireCellApps;
20 
21 
23  : m_cfg(default_configuration())
24 {
25 }
26 
27 NodeDumper::~NodeDumper()
28 {
29 }
30 
32 {
33  m_cfg = config;
34 }
35 
37 {
39  cfg["filename"] = "/dev/stdout";
40  cfg["nodes"] = Json::arrayValue;
41  return cfg;
42 }
43 
44 
46 {
48 
49  int nnodes = m_cfg["nodes"].size();
50  std::vector<std::string> types;
51  if (0 == nnodes) {
52  types = Factory::known_classes<INode>();
53  nnodes = types.size();
54  info("Dumping all known node classes ({})", nnodes);
55  }
56  else {
57  info("Dumping: ({})", nnodes);
58  for (auto type_cfg : m_cfg["nodes"]) {
59  std::string type = convert<string>(type_cfg);
60  types.push_back(type);
61  info("\t{}", type);
62  }
63  }
64 
65 
66  for (auto type : types) {
67 
68  INode::pointer node;
69  try {
70  node = Factory::lookup<INode>(type);
71  }
72  catch (FactoryException& fe) {
73  warn("NodeDumper: failed lookup node: \"{}\"", type);
74  continue;
75  }
76 
77  Configuration one;
78  one["type"] = type;
79  for (auto intype : node->input_types()) {
80  one["input_types"].append(demangle(intype));
81  }
82  for (auto intype : node->output_types()) {
83  one["output_types"].append(demangle(intype));
84  }
85  one["concurrency"] = node->concurrency();
86  one["category"] = node->category();
87 
88  all.append(one);
89  }
90 
91  Persist::dump(get<string>(m_cfg, "filename"), all);
92 }
93 
94 
95 
96 
std::string demangle(T const *=nullptr)
Outputs a demangled name for type T.
Definition: DebugUtils.h:348
virtual void configure(const WireCell::Configuration &config)
Accept a configuration.
Definition: NodeDumper.cxx:31
std::string string
Definition: nybbler.cc:12
STL namespace.
cfg
Definition: dbjson.py:29
WireCell::Configuration m_cfg
Definition: NodeDumper.h:11
Definition: async.h:27
static Config * config
Definition: config.cpp:1054
std::shared_ptr< Interface > pointer
Definition: Interface.h:16
Definition: Main.h:22
static QInternalList< QTextCodec > * all
Definition: qtextcodec.cpp:63
static const char types[][NUM_HTML_LIST_TYPES]
static QCString type
Definition: declinfo.cpp:672
Json::Value Configuration
Definition: Configuration.h:50
virtual WireCell::Configuration default_configuration() const
Optional, override to return a hard-coded default configuration.
Definition: NodeDumper.cxx:36
virtual void execute()
Implement to run something.
Definition: NodeDumper.cxx:45
void dump(const IFrame::pointer frame)
Definition: Fourdee.cxx:120
#define WIRECELL_FACTORY(NAME, CONCRETE,...)
Definition: NamedFactory.h:332
QCString & append(const char *s)
Definition: qcstring.cpp:383