#define SIMGRID_S4U_NETZONE_HPP
#include <simgrid/forward.h>
+#include <xbt/graph.h>
#include <xbt/signal.hpp>
+#include <map>
#include <string>
#include <unordered_map>
#include <utility>
void set_property(const std::string& key, const std::string& value);
std::vector<NetZone*> get_children() const;
+ void extract_xbt_graph(const s_xbt_graph_t* graph, std::map<std::string, xbt_node_t>* nodes,
+ std::map<std::string, xbt_edge_t>* edges);
/* Add content to the netzone, at parsing time. It should be sealed afterward. */
int add_component(kernel::routing::NetPoint* elm); /* A host, a router or a netzone, whatever */
return std::string(proc.get_name()) + "-" + std::to_string(proc.get_pid());
}
-static const char* instr_node_name(const s_xbt_node_t* node)
-{
- return static_cast<char*>(xbt_graph_node_get_data(node));
-}
-
static container_t lowestCommonAncestor(const simgrid::instr::Container* a1, const simgrid::instr::Container* a2)
{
// this is only an optimization (since most of a1 and a2 share the same parent)
recursiveNewValueForUserStateType(type_name, value, color, simgrid::instr::Container::get_root()->type_);
}
-static void recursiveXBTGraphExtraction(const s_xbt_graph_t* graph, std::map<std::string, xbt_node_t>* nodes,
- std::map<std::string, xbt_edge_t>* edges, const_sg_netzone_t netzone)
-{
- // bottom-up recursion
- for (auto const& netzone_child : netzone->get_children())
- recursiveXBTGraphExtraction(graph, nodes, edges, netzone_child);
-
- netzone->get_impl()->get_graph(graph, nodes, edges);
-}
-
namespace simgrid {
namespace instr {
xbt_graph_t g = xbt_graph_new_graph(0, nullptr);
std::map<std::string, xbt_node_t>* nodes = new std::map<std::string, xbt_node_t>();
std::map<std::string, xbt_edge_t>* edges = new std::map<std::string, xbt_edge_t>();
- recursiveXBTGraphExtraction(g, nodes, edges, s4u::Engine::get_instance()->get_netzone_root());
+ s4u::Engine::get_instance()->get_netzone_root()->extract_xbt_graph(g, nodes, edges);
std::ofstream fs;
fs.open(output_filename, std::ofstream::out);
fs << " node [width=.3, height=.3, style=filled, color=skyblue]" << std::endl << std::endl;
for (auto const& elm : *nodes)
- fs << " \"" << instr_node_name(elm.second) << "\";" << std::endl;
+ fs << " \"" << elm.first << "\";" << std::endl;
for (auto const& elm : *edges) {
- const char* src_s = instr_node_name(elm.second->src);
- const char* dst_s = instr_node_name(elm.second->dst);
+ const char* src_s = static_cast<char*>(elm.second->src->data);
+ const char* dst_s = static_cast<char*>(elm.second->dst->data);
if (g->directed)
fs << " \"" << src_s << "\" -> \"" << dst_s << "\";" << std::endl;
else
{
pimpl_->add_bypass_route(src, dst, gw_src, gw_dst, link_list, symmetrical);
}
+
+void NetZone::extract_xbt_graph(const s_xbt_graph_t* graph, std::map<std::string, xbt_node_t>* nodes,
+ std::map<std::string, xbt_edge_t>* edges)
+{
+ for (auto const& child : get_children())
+ child->extract_xbt_graph(graph, nodes, edges);
+
+ pimpl_->get_graph(graph, nodes, edges);
+}
} // namespace s4u
} // namespace simgrid