Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make the sg_plat_new_host() function public
[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
17 /** Module management function: creates all internal data structures */
18 void sg_platf_init(void) {
19   surf_parse_host_cb_list = xbt_dynar_new(sizeof(surf_parse_host_fct_t), NULL);
20 }
21 /** Module management function: frees all internal data structures */
22 void sg_platf_exit(void) {
23   xbt_dynar_free(&surf_parse_host_cb_list);
24 }
25
26 void sg_platf_new_host(surf_parsing_host_arg_t h){
27   unsigned int iterator;
28   surf_parse_host_fct_t fun;
29   xbt_dynar_foreach(surf_parse_host_cb_list, iterator, fun) {
30     if (fun) (*fun) (h);
31   }
32 }
33 void surf_parse_host_add_cb(surf_parse_host_fct_t fct) {
34   xbt_dynar_push(surf_parse_host_cb_list, &fct);
35 }