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 sg_platf_host_cb_list = NULL; // of sg_platf_host_cb_t
16 xbt_dynar_t sg_platf_router_cb_list = NULL; // of sg_platf_router_cb_t
17 xbt_dynar_t sg_platf_postparse_cb_list = NULL; // of void_f_void_t
19 /** Module management function: creates all internal data structures */
20 void sg_platf_init(void) {
21 sg_platf_host_cb_list = xbt_dynar_new(sizeof(sg_platf_host_cb_t), NULL);
22 sg_platf_router_cb_list = xbt_dynar_new(sizeof(sg_platf_host_cb_t), NULL);
23 sg_platf_postparse_cb_list = xbt_dynar_new(sizeof(void_f_void_t),NULL);
25 /** Module management function: frees all internal data structures */
26 void sg_platf_exit(void) {
27 xbt_dynar_free(&sg_platf_host_cb_list);
28 xbt_dynar_free(&sg_platf_router_cb_list);
29 xbt_dynar_free(&sg_platf_postparse_cb_list);
32 void sg_platf_new_host(sg_platf_host_cbarg_t h){
33 unsigned int iterator;
34 sg_platf_host_cb_t fun;
35 xbt_dynar_foreach(sg_platf_host_cb_list, iterator, fun) {
39 void sg_platf_new_router(sg_platf_router_cbarg_t router) {
40 unsigned int iterator;
41 sg_platf_router_cb_t fun;
42 xbt_dynar_foreach(sg_platf_router_cb_list, iterator, fun) {
46 void sg_platf_open() { /* Do nothing: just for symmetry of user code */ }
48 void sg_platf_close() {
49 unsigned int iterator;
51 xbt_dynar_foreach(sg_platf_postparse_cb_list, iterator, fun) {
57 void sg_platf_host_add_cb(sg_platf_host_cb_t fct) {
58 xbt_dynar_push(sg_platf_host_cb_list, &fct);
60 void sg_platf_router_add_cb(sg_platf_router_cb_t fct) {
61 xbt_dynar_push(sg_platf_router_cb_list, &fct);
63 void sg_platf_postparse_add_cb(void_f_void_t fct) {
64 xbt_dynar_push(sg_platf_postparse_cb_list, &fct);