Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
4a5af63c513e372a033c40a65153055ef7b1edd6
[simgrid.git] / examples / simdag / dot / dot_test2.c
1 /* simple test trying to load a DOT file.                                   */
2
3 /* Copyright (c) 2010. The SimGrid Team.
4  * All rights reserved.                                                     */
5
6 /* This program is free software; you can redistribute it and/or modify it
7  * under the terms of the license (GNU LGPL) which comes with this package. */
8
9 #include <stdlib.h>
10 #include <stdio.h>
11 #include "simdag/simdag.h"
12 #include "xbt/log.h"
13 #include "xbt/ex.h"
14 #include <string.h>
15 #define HAVE_JEDULE 0
16
17 XBT_LOG_NEW_DEFAULT_CATEGORY(test,
18                              "Logging specific to this SimDag example");
19
20 int main(int argc, char **argv)
21 {
22   xbt_dynar_t dot;
23   unsigned int cursor;
24   SD_task_t task, *dot_as_array=NULL;
25
26   /* initialisation of SD */
27   SD_init(&argc, argv);
28
29   /* Check our arguments */
30   if (argc < 2) {
31     XBT_INFO("Usage: %s dot_file", argv[0]);
32     exit(1);
33   }
34
35   /* load the DOT file */
36   dot = SD_dotload(argv[1]);
37
38   /* Display all the tasks */
39   XBT_INFO
40       ("------------------- Display all tasks of the loaded DAG ---------------------------");
41   xbt_dynar_foreach(dot, cursor, task) {
42       SD_task_dump(task);
43     }
44
45   XBT_INFO
46       ("--------------------- Transform the dynar into an array ---------------------------");
47   cursor=0;
48   dot_as_array = (SD_task_t*) xbt_dynar_to_array(dot);
49   XBT_INFO
50       ("----------------------------- dump tasks again ------------------------------------");
51   while ((task=dot_as_array[cursor++])){
52     SD_task_dump(task);
53     SD_task_destroy(task);
54   }
55
56   free(dot_as_array);
57
58   /* exit */
59   SD_exit();
60   return 0;
61 }