1 /* Copyright (c) 2010-2016. 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_events.hpp"
9 #include "simgrid/jedule/jedule.hpp"
10 #include "simgrid/jedule/jedule_platform.hpp"
11 #include "simgrid/s4u/NetZone.hpp"
12 #include "xbt/asserts.h"
18 Event::Event(std::string name, double start_time, double end_time, std::string type)
19 : name(name), start_time(start_time), end_time(end_time), type(type)
21 this->resource_subsets = new std::vector<jed_subset_t>();
26 if (!this->resource_subsets->empty()){
27 for (auto subset: *this->resource_subsets)
29 delete this->resource_subsets;
33 void Event::addResources(std::vector<sg_host_t> *host_selection)
35 get_resource_selection_by_hosts(this->resource_subsets, host_selection);
38 void Event::addCharacteristic(char *characteristic)
40 xbt_assert( characteristic != nullptr );
41 this->characteristics_list.push_back(characteristic);
44 void Event::addInfo(char* key, char *value) {
45 xbt_assert((key != nullptr) && value != nullptr);
46 this->info_map.insert({key, value});
49 void Event::print(FILE *jed_file)
51 fprintf(jed_file, " <event>\n");
52 fprintf(jed_file, " <prop key=\"name\" value=\"%s\" />\n", this->name.c_str());
53 fprintf(jed_file, " <prop key=\"start\" value=\"%g\" />\n", this->start_time);
54 fprintf(jed_file, " <prop key=\"end\" value=\"%g\" />\n", this->end_time);
55 fprintf(jed_file, " <prop key=\"type\" value=\"%s\" />\n", this->type.c_str());
57 xbt_assert(!this->resource_subsets-> empty());
58 fprintf(jed_file, " <res_util>\n");
59 for (auto subset: *this->resource_subsets) {
60 fprintf(jed_file, " <select resources=\"");
61 fprintf(jed_file, "%s", subset->parent->getHierarchyAsString().c_str());
62 fprintf(jed_file, ".[%d-%d]", subset->start_idx, subset->start_idx + subset->nres-1);
63 fprintf(jed_file, "\" />\n");
65 fprintf(jed_file, " </res_util>\n");
67 if (!this->characteristics_list.empty()){
68 fprintf(jed_file, " <characteristics>\n");
69 for (auto ch: this->characteristics_list)
70 fprintf(jed_file, " <characteristic name=\"%s\" />\n", ch);
71 fprintf(jed_file, " </characteristics>\n");
74 if (!this->info_map.empty()){
75 fprintf(jed_file, " <info>\n");
76 for (auto elm: this->info_map)
77 fprintf(jed_file, " <prop key=\"%s\" value=\"%s\" />\n",elm.first,elm.second);
78 fprintf(jed_file, " </info>\n");
81 fprintf(jed_file, " </event>\n");