Logo AND Algorithmique Numérique Distribuée

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