Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' into MC_LTL
[simgrid.git] / src / instr / jedule / jedule_events.c
1 /*
2  * jedule_events.c
3  *
4  *  Created on: Nov 30, 2010
5  *      Author: sascha
6  */
7
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11
12 #include "xbt/dict.h"
13 #include "xbt/dynar.h"
14 #include "xbt/asserts.h"
15
16 #include "instr/jedule/jedule_events.h"
17 #include "instr/jedule/jedule_platform.h"
18
19 #ifdef HAVE_JEDULE
20
21 void jed_event_add_resources(jed_event_t event, xbt_dynar_t host_selection) {
22         xbt_dynar_t resource_subset_list;
23         jed_res_subset_t res_set;
24         unsigned int i;
25
26         resource_subset_list = xbt_dynar_new(sizeof(jed_res_subset_t), NULL);
27
28         jed_simgrid_get_resource_selection_by_hosts(resource_subset_list, host_selection);
29         xbt_dynar_foreach(resource_subset_list, i, res_set)  {
30                 xbt_dynar_push(event->resource_subsets, &res_set);
31         }
32
33         xbt_dynar_free(&resource_subset_list);
34 }
35
36 void jed_event_add_characteristic(jed_event_t event, char *characteristic) {
37         xbt_assert( characteristic != NULL );
38         xbt_dynar_push(event->characteristics_list, &characteristic);
39 }
40
41
42 void jed_event_add_info(jed_event_t event, char *key, char *value) {
43         char *val_cp;
44
45         xbt_assert(key != NULL);
46         xbt_assert(value != NULL);
47
48         val_cp = strdup(value);
49         xbt_dict_set(event->info_hash, key, val_cp, NULL);
50 }
51
52
53 void create_jed_event(jed_event_t *event, char *name, double start_time,
54                 double end_time, const char *type) {
55
56         *event = (jed_event_t) calloc(1, sizeof(s_jed_event_t));
57         (*event)->name = xbt_strdup(name);
58
59         (*event)->start_time = start_time;
60         (*event)->end_time = end_time;
61
62         (*event)->type = xbt_strdup(type);
63
64         (*event)->resource_subsets = xbt_dynar_new(sizeof(jed_res_subset_t), NULL);
65         (*event)->characteristics_list = xbt_dynar_new(sizeof(char*), NULL);
66         (*event)->info_hash = xbt_dict_new_homogeneous(NULL);
67
68 }
69
70
71 void jed_event_free(jed_event_t event) {
72
73         free(event->name);
74         free(event->type);
75
76         xbt_dynar_free(&event->resource_subsets);
77
78         xbt_dynar_free(&event->characteristics_list);
79         xbt_dict_free(&event->info_hash);
80
81         free(event);
82 }
83
84 #endif