1 /* Copyright (c) 2010-2019. 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.hpp"
8 #include "simgrid/s4u/NetZone.hpp"
9 #include "xbt/asserts.h"
11 #if SIMGRID_HAVE_JEDULE
15 void Event::add_resources(const std::vector<sg_host_t>& host_selection)
17 get_resource_selection_by_hosts(this->resource_subsets_, host_selection);
20 void Event::add_characteristic(char* characteristic)
22 xbt_assert( characteristic != nullptr );
23 this->characteristics_list_.push_back(characteristic);
26 void Event::add_info(char* key, char* value)
28 xbt_assert((key != nullptr) && value != nullptr);
29 this->info_map_.insert({key, value});
32 void Event::print(FILE* jed_file) const
34 fprintf(jed_file, " <event>\n");
35 fprintf(jed_file, " <prop key=\"name\" value=\"%s\" />\n", this->name_.c_str());
36 fprintf(jed_file, " <prop key=\"start\" value=\"%g\" />\n", this->start_time_);
37 fprintf(jed_file, " <prop key=\"end\" value=\"%g\" />\n", this->end_time_);
38 fprintf(jed_file, " <prop key=\"type\" value=\"%s\" />\n", this->type_.c_str());
40 xbt_assert(not this->resource_subsets_.empty());
41 fprintf(jed_file, " <res_util>\n");
42 for (auto const& subset : this->resource_subsets_) {
43 fprintf(jed_file, " <select resources=\"");
44 fprintf(jed_file, "%s", subset.parent->get_hierarchy_as_string().c_str());
45 fprintf(jed_file, ".[%d-%d]", subset.start_idx, subset.start_idx + subset.nres - 1);
46 fprintf(jed_file, "\" />\n");
48 fprintf(jed_file, " </res_util>\n");
50 if (not this->characteristics_list_.empty()) {
51 fprintf(jed_file, " <characteristics>\n");
52 for (auto const& ch : this->characteristics_list_)
53 fprintf(jed_file, " <characteristic name=\"%s\" />\n", ch.c_str());
54 fprintf(jed_file, " </characteristics>\n");
57 if (not this->info_map_.empty()) {
58 fprintf(jed_file, " <info>\n");
59 for (auto const& elm : this->info_map_)
60 fprintf(jed_file, " <prop key=\"%s\" value=\"%s\" />\n", elm.first.c_str(), elm.second.c_str());
61 fprintf(jed_file, " </info>\n");
64 fprintf(jed_file, " </event>\n");