53 sparta_assert(report_,
"You may not give a null report to a ReportStatisticsHierTree");
56 typedef std::pair<LeafNodeT*, const StatisticInstance*> LeafNodeSI;
62 std::vector<LeafNodeSI>
buildFrom(std::shared_ptr<NodeT> & root,
63 std::vector<std::string> * si_locations =
nullptr)
const {
64 return buildFrom(root.get(), si_locations);
72 std::vector<std::string> * si_locations =
nullptr)
const {
73 std::vector<LeafNodeSI> flattened_leaves;
74 createSubreportHierTree_(root, *report_, flattened_leaves, si_locations,
"");
75 return flattened_leaves;
79 void createSubreportHierTree_(NodeT * report_node,
80 const Report & report,
81 std::vector<LeafNodeSI> & flattened_leaves,
82 std::vector<std::string> * si_locations,
83 const std::string & si_location_prefix)
const
85 const auto & stats = report.getStatistics();
86 const auto & subreports = report.getSubreports();
87 auto & children = report_node->getChildren();
90 for (
const auto & stat : stats) {
91 std::string name = !stat.first.empty() ? stat.first : stat.second->getLocation();
93 si_locations->emplace_back(si_location_prefix + name);
95 boost::replace_all(name,
".",
"_");
97 std::shared_ptr<LeafNodeT> si_node(
new LeafNodeT(name, stat.second.get()));
98 si_node->setParent(report_node);
99 children.emplace_back(si_node);
100 flattened_leaves.emplace_back(std::make_pair(si_node.get(), stat.second.get()));
104 if (!subreports.empty()) {
105 for (
const auto & sr : subreports) {
106 std::vector<std::string> dot_delimited;
107 boost::split(dot_delimited, sr.getName(), boost::is_any_of(
"."));
108 const std::string & name = dot_delimited.back();
110 std::shared_ptr<NodeT> subreport_node(
new NodeT(name, &sr));
111 subreport_node->setParent(report_node);
112 createSubreportHierTree_(subreport_node.get(), sr,
117 children.emplace_back(subreport_node);
122 const Report * report_ =
nullptr;