- else
-#endif
- { // Use XML parser
-
- int parse_status;
-
- /* init the flex parser */
- after_config_done = 0;
- surf_parse_open(file);
-
- /* Do the actual parsing */
- parse_status = surf_parse();
-
- /* connect all traces relative to hosts */
- for (auto const& elm : trace_connect_list_host_avail) {
- xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
- tmgr_trace_t trace = traces_set_list.at(elm.first);
-
- simgrid::s4u::Host* host = sg_host_by_name(elm.second.c_str());
- xbt_assert(host, "Host %s undefined", elm.second.c_str());
- simgrid::surf::Cpu *cpu = host->pimpl_cpu;
-
- cpu->setStateTrace(trace);
- }
-
- for (auto const& elm : trace_connect_list_host_speed) {
- xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
- tmgr_trace_t trace = traces_set_list.at(elm.first);
-
- simgrid::s4u::Host* host = sg_host_by_name(elm.second.c_str());
- xbt_assert(host, "Host %s undefined", elm.second.c_str());
- simgrid::surf::Cpu *cpu = host->pimpl_cpu;
-
- cpu->setSpeedTrace(trace);
- }
-
- for (auto const& elm : trace_connect_list_link_avail) {
- xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
- tmgr_trace_t trace = traces_set_list.at(elm.first);
-
- sg_link_t link = simgrid::s4u::Link::byName(elm.second.c_str());
- xbt_assert(link, "Link %s undefined", elm.second.c_str());
- link->setStateTrace(trace);
- }
-
- for (auto const& elm : trace_connect_list_link_bw) {
- xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
- tmgr_trace_t trace = traces_set_list.at(elm.first);
- sg_link_t link = simgrid::s4u::Link::byName(elm.second.c_str());
- xbt_assert(link, "Link %s undefined", elm.second.c_str());
- link->setBandwidthTrace(trace);
- }
-
- for (auto const& elm : trace_connect_list_link_lat) {
- xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
- tmgr_trace_t trace = traces_set_list.at(elm.first);
- sg_link_t link = simgrid::s4u::Link::byName(elm.second.c_str());
- xbt_assert(link, "Link %s undefined", elm.second.c_str());
- link->setLatencyTrace(trace);
- }
-
- surf_parse_close();
-
- if (parse_status)
- surf_parse_error(std::string("Parse error in ") + file);
+
+ for (auto const& [trace, name] : trace_connect_list_link_avail) {
+ simgrid_parse_assert(traces_set_list.find(trace) != traces_set_list.end(),
+ "<trace_connect kind=\"LINK_AVAIL\">: Trace " + trace + " undefined.");
+ auto profile = traces_set_list.at(trace);
+
+ auto link = engine->link_by_name_or_null(name);
+ simgrid_parse_assert(link, "<trace_connect kind=\"LINK_AVAIL\">: Link " + name + " undefined.");
+ link->set_state_profile(profile);