X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/fd769219531a772284d75320187a0ef9f8118afd..9ac8863c26f8fd0ca6d402d48a2cbfbb73dbe591:/src/instr/jedule/jedule_events.cpp diff --git a/src/instr/jedule/jedule_events.cpp b/src/instr/jedule/jedule_events.cpp index 64dc9dd63b..93f494cc00 100644 --- a/src/instr/jedule/jedule_events.cpp +++ b/src/instr/jedule/jedule_events.cpp @@ -4,74 +4,85 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ +#include "simgrid/jedule/jedule_events.hpp" +#include "simgrid/jedule/jedule_output.hpp" #include #include -#include +#include -#include "xbt/dict.h" -#include "xbt/dynar.h" #include "xbt/asserts.h" -#include "simgrid/jedule/jedule_events.h" -#include "simgrid/jedule/jedule_platform.h" - #if HAVE_JEDULE +namespace simgrid{ +namespace jedule{ + +void Event::deleteEvent(){ + while (!this->resource_subsets.empty()){ + xbt_free(this->resource_subsets.back()); + this->resource_subsets.pop_back(); + } + delete this; +} -void jed_event_add_resources(jed_event_t event, xbt_dynar_t host_selection) { +void Event::addResources(std::vector *host_selection) { xbt_dynar_t resource_subset_list; jed_res_subset_t res_set; unsigned int i; - resource_subset_list = xbt_dynar_new(sizeof(jed_res_subset_t), NULL); + resource_subset_list = xbt_dynar_new(sizeof(jed_res_subset_t), nullptr); jed_simgrid_get_resource_selection_by_hosts(resource_subset_list, host_selection); xbt_dynar_foreach(resource_subset_list, i, res_set) { - xbt_dynar_push(event->resource_subsets, &res_set); + this->resource_subsets.push_back(res_set); } - xbt_dynar_free(&resource_subset_list); + xbt_dynar_free_container(&resource_subset_list); } -void jed_event_add_characteristic(jed_event_t event, char *characteristic) { - xbt_assert( characteristic != NULL ); - xbt_dynar_push(event->characteristics_list, &characteristic); +void Event::addCharacteristic(char *characteristic) { + xbt_assert( characteristic != nullptr ); + this->characteristics_list.push_back(characteristic); } -void jed_event_add_info(jed_event_t event, char *key, char *value) { - char *val_cp; - - xbt_assert(key != NULL); - xbt_assert(value != NULL); - - val_cp = strdup(value); - xbt_dict_set(event->info_hash, key, val_cp, NULL); +void Event::addInfo(char* key, char *value) { + xbt_assert((key != nullptr) && value != nullptr); + this->info_map.insert({key, value}); } -void create_jed_event(jed_event_t *event, char *name, double start_time, - double end_time, const char *type) { - - *event = xbt_new0(s_jed_event_t,1); - (*event)->name = xbt_strdup(name); +void Event::print(FILE *jed_file){ + fprintf(jed_file, " \n"); + fprintf(jed_file, " \n", this->name.c_str()); + fprintf(jed_file, " \n", this->start_time); + fprintf(jed_file, " \n", this->end_time); + fprintf(jed_file, " \n", this->type.c_str()); + + xbt_assert(!this->resource_subsets.empty()); + fprintf(jed_file, " \n"); + for (auto subset: this->resource_subsets) { + fprintf(jed_file, "