1 /* Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011. The SimGrid Team.
2 * All rights reserved. */
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. */
11 #include "simgrid/platf_interface.h"
12 #include "surf/surf_private.h"
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
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);
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);
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) {
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);
45 void surf_parse_host_add_cb(surf_parse_host_fct_t fct) {
46 xbt_dynar_push(surf_parse_host_cb_list, &fct);
48 void surf_parse_router_add_cb(surf_parse_router_fct_t fct) {
49 xbt_dynar_push(surf_parse_router_cb_list, &fct);