Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
simplify
[simgrid.git] / src / instr / jedule / jedule.cpp
1 /* Copyright (c) 2010-2021. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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. */
6
7 #include "simgrid/jedule/jedule.hpp"
8 #include "simgrid/config.h"
9 #include "xbt/asserts.h"
10
11 #if SIMGRID_HAVE_JEDULE
12
13 namespace simgrid{
14 namespace jedule {
15
16 void Jedule::add_meta_info(char* key, char* value)
17 {
18   xbt_assert(key != nullptr);
19   xbt_assert(value != nullptr);
20
21   this->meta_info_.insert({key, value});
22 }
23
24 void Jedule::add_event(const Event& event)
25 {
26   event_set_.emplace_back(event);
27 }
28
29 void Jedule::write_output(FILE* file)
30 {
31   if (not this->event_set_.empty()) {
32     fprintf(file, "<jedule>\n");
33
34     if (not this->meta_info_.empty()) {
35       fprintf(file, "  <jedule_meta>\n");
36       for (auto const& elm : this->meta_info_)
37         fprintf(file, "        <prop key=\"%s\" value=\"%s\" />\n",elm.first,elm.second);
38       fprintf(file, "  </jedule_meta>\n");
39     }
40
41     fprintf(file, "  <platform>\n");
42     this->root_container_.print(file);
43     fprintf(file, "  </platform>\n");
44
45     fprintf(file, "  <events>\n");
46     for (auto const& event : this->event_set_)
47       event.print(file);
48     fprintf(file, "  </events>\n");
49
50     fprintf(file, "</jedule>\n");
51   }
52 }
53
54 } // namespace jedule
55 } // namespace simgrid
56 #endif