Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
ed3d6e51aa00a9690f3fda5f2e7d9dec89941fda
[simgrid.git] / src / instr / jedule / jedule.cpp
1 /* Copyright (c) 2010-2016. 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 HAVE_JEDULE
11
12 namespace simgrid{
13 namespace jedule {
14
15 Jedule::~Jedule() {
16   delete this->root_container;
17   for (auto evt: this->event_set)
18     delete evt;
19   this->event_set.clear();
20 }
21
22 void Jedule::addMetaInfo(char *key, char *value) {
23   xbt_assert(key != nullptr);
24   xbt_assert(value != nullptr);
25
26   this->meta_info.insert({key, value});
27 }
28
29 void Jedule::writeOutput(FILE *file) {
30   if (!this->event_set.empty()){
31     fprintf(file, "<jedule>\n");
32
33     if (!this->meta_info.empty()){
34       fprintf(file, "  <jedule_meta>\n");
35       for (auto 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 event :this->event_set)
46         event->print(file);
47     fprintf(file, "  </events>\n");
48
49     fprintf(file, "</jedule>\n");
50   }
51 }
52
53 }
54 }
55 #endif