Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
ee11d0b84466c793266a668c071d4bb4418a1821
[simgrid.git] / src / surf / sg_platf.c
1 /* Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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. */
6
7 #include "xbt/misc.h"
8 #include "xbt/log.h"
9 #include "xbt/str.h"
10 #include "xbt/dict.h"
11 #include "simgrid/platf_interface.h"
12 #include "surf/surf_private.h"
13
14 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_parse);
15 xbt_dynar_t surf_parse_host_cb_list = NULL; // of functions of type: surf_parsing_host_arg_t -> void
16 xbt_dynar_t surf_parse_router_cb_list = NULL; // of functions of type: surf_parsing_router_arg_t -> void
17
18 /** Module management function: creates all internal data structures */
19 void sg_platf_init(void) {
20   surf_parse_host_cb_list = xbt_dynar_new(sizeof(surf_parse_host_fct_t), NULL);
21   surf_parse_router_cb_list = xbt_dynar_new(sizeof(surf_parse_host_fct_t), NULL);
22 }
23 /** Module management function: frees all internal data structures */
24 void sg_platf_exit(void) {
25   xbt_dynar_free(&surf_parse_host_cb_list);
26   xbt_dynar_free(&surf_parse_router_cb_list);
27 }
28
29 void sg_platf_new_host(surf_parsing_host_arg_t h){
30   unsigned int iterator;
31   surf_parse_host_fct_t fun;
32   xbt_dynar_foreach(surf_parse_host_cb_list, iterator, fun) {
33     if (fun) (*fun) (h);
34   }
35 }
36 void sg_platf_new_router(surf_parsing_router_arg_t router) {
37   unsigned int iterator;
38   surf_parse_router_fct_t fun;
39   xbt_dynar_foreach(surf_parse_router_cb_list, iterator, fun) {
40     if (fun) (*fun) (router);
41   }
42 }
43
44
45 void surf_parse_host_add_cb(surf_parse_host_fct_t fct) {
46   xbt_dynar_push(surf_parse_host_cb_list, &fct);
47 }
48 void surf_parse_router_add_cb(surf_parse_router_fct_t fct) {
49   xbt_dynar_push(surf_parse_router_cb_list, &fct);
50 }
51