1 /* Copyright (c) 2010-2014. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "simgrid/jedule/jedule_output.hpp"
8 #include "simgrid/host.h"
14 #include "xbt/dynar.h"
15 #include "xbt/asserts.h"
19 #define STR_BUF_SIZE 1024
21 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(jed_out, jedule, "Logging specific to Jedule output");
23 xbt_dynar_t jedule_event_list;
25 void write_jedule_output(FILE *file, jedule_t jedule, xbt_dynar_t event_list) {
26 if (!xbt_dynar_is_empty(jedule_event_list)){
28 fprintf(file, "<jedule>\n");
30 if (!jedule->jedule_meta_info.empty()){
31 fprintf(file, " <jedule_meta>\n");
32 for (auto elm: jedule->jedule_meta_info)
33 fprintf(file, " <prop key=\"%s\" value=\"%s\" />\n",elm.first,elm.second);
34 fprintf(file, " </jedule_meta>\n");
37 fprintf(file, " <platform>\n");
38 jedule->root_container->print(file);
39 fprintf(file, " </platform>\n");
41 fprintf(file, " <events>\n");
44 xbt_dynar_foreach(event_list, i, event) {
47 fprintf(file, " </events>\n");
49 fprintf(file, "</jedule>\n");
53 void jedule_init_output() {
54 jedule_event_list = xbt_dynar_new(sizeof(jed_event_t), nullptr);
57 void jedule_cleanup_output() {
58 while (!xbt_dynar_is_empty(jedule_event_list)) {
59 jed_event_t evt = xbt_dynar_pop_as(jedule_event_list, jed_event_t) ;
63 xbt_dynar_free_container(&jedule_event_list);
66 void jedule_store_event(jed_event_t event) {
67 xbt_assert(event != nullptr);
68 xbt_dynar_push(jedule_event_list, &event);