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"
13 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_parse);
14 xbt_dynar_t sg_platf_host_cb_list = NULL; // of sg_platf_host_cb_t
15 xbt_dynar_t sg_platf_link_cb_list = NULL; // of sg_platf_link_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_link_cb_list = xbt_dynar_new(sizeof(sg_platf_host_cb_t), NULL);
24 sg_platf_postparse_cb_list = xbt_dynar_new(sizeof(sg_platf_link_cb_t),NULL);
26 /** Module management function: frees all internal data structures */
27 void sg_platf_exit(void) {
28 xbt_dynar_free(&sg_platf_host_cb_list);
29 xbt_dynar_free(&sg_platf_router_cb_list);
30 xbt_dynar_free(&sg_platf_postparse_cb_list);
33 void sg_platf_new_host(sg_platf_host_cbarg_t h){
34 unsigned int iterator;
35 sg_platf_host_cb_t fun;
36 xbt_dynar_foreach(sg_platf_host_cb_list, iterator, fun) {
40 void sg_platf_new_router(sg_platf_router_cbarg_t router) {
41 unsigned int iterator;
42 sg_platf_router_cb_t fun;
43 xbt_dynar_foreach(sg_platf_router_cb_list, iterator, fun) {
47 void sg_platf_new_link(sg_platf_link_cbarg_t link){
48 unsigned int iterator;
49 sg_platf_link_cb_t fun;
50 xbt_dynar_foreach(sg_platf_link_cb_list, iterator, fun) {
55 void sg_platf_open() { /* Do nothing: just for symmetry of user code */ }
57 void sg_platf_close() {
58 unsigned int iterator;
60 xbt_dynar_foreach(sg_platf_postparse_cb_list, iterator, fun) {
66 void sg_platf_host_add_cb(sg_platf_host_cb_t fct) {
67 xbt_dynar_push(sg_platf_host_cb_list, &fct);
69 void sg_platf_link_add_cb(sg_platf_link_cb_t fct) {
70 xbt_dynar_push(sg_platf_link_cb_list, &fct);
72 void sg_platf_router_add_cb(sg_platf_router_cb_t fct) {
73 xbt_dynar_push(sg_platf_router_cb_list, &fct);
75 void sg_platf_postparse_add_cb(void_f_void_t fct) {
76 xbt_dynar_push(sg_platf_postparse_cb_list, &fct);