From 1d558deeec797460abbfa5ed52f1e7ae784dcf7e Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Tue, 8 Nov 2011 21:23:47 +0100 Subject: [PATCH] Kill the XML-level callbacks to AS_open/close and create some at sg_platf level instead --- include/surf/surf_routing.h | 5 +++++ include/surf/surfxml_parse.h | 2 -- src/include/simgrid/platf_interface.h | 4 ++++ src/instr/instr_routing.c | 4 ++-- src/surf/sg_platf.c | 28 +++++++++++++++++++++++++++ src/surf/surf_routing.c | 7 +++---- src/surf/surfxml_parse.c | 12 ++++-------- src/surf/surfxml_parseplatf.c | 12 ++---------- 8 files changed, 48 insertions(+), 26 deletions(-) diff --git a/include/surf/surf_routing.h b/include/surf/surf_routing.h index a0a891d562..b348c640c5 100644 --- a/include/surf/surf_routing.h +++ b/include/surf/surf_routing.h @@ -29,4 +29,9 @@ extern int ROUTING_ASR_LEVEL; //Routing level extern int COORD_ASR_LEVEL; //Coordinates level extern int NS3_ASR_LEVEL; //host node for ns3 + +/* The callbacks to register for the routing to work */ +void routing_AS_open(const char *AS_id, const char *wanted_routing_type); +void routing_AS_close(void); + #endif /* _SURF_SURF_H */ diff --git a/include/surf/surfxml_parse.h b/include/surf/surfxml_parse.h index cf9c13e169..6c01e2f9fc 100644 --- a/include/surf/surfxml_parse.h +++ b/include/surf/surfxml_parse.h @@ -31,8 +31,6 @@ XBT_PUBLIC_DATA(xbt_dynar_t) STag_surfxml_trace_connect_cb_list; XBT_PUBLIC_DATA(xbt_dynar_t) ETag_surfxml_trace_connect_cb_list; XBT_PUBLIC_DATA(xbt_dynar_t) STag_surfxml_random_cb_list; XBT_PUBLIC_DATA(xbt_dynar_t) ETag_surfxml_random_cb_list; -XBT_PUBLIC_DATA(xbt_dynar_t) STag_surfxml_AS_cb_list; -XBT_PUBLIC_DATA(xbt_dynar_t) ETag_surfxml_AS_cb_list; XBT_PUBLIC_DATA(xbt_dynar_t) STag_surfxml_ASroute_cb_list; XBT_PUBLIC_DATA(xbt_dynar_t) ETag_surfxml_ASroute_cb_list; XBT_PUBLIC_DATA(xbt_dynar_t) STag_surfxml_bypassRoute_cb_list; diff --git a/src/include/simgrid/platf_interface.h b/src/include/simgrid/platf_interface.h index 4afc6ed1ea..07da10daf4 100644 --- a/src/include/simgrid/platf_interface.h +++ b/src/include/simgrid/platf_interface.h @@ -21,12 +21,16 @@ typedef void (*sg_platf_host_cb_t)(sg_platf_host_cbarg_t); typedef void (*sg_platf_router_cb_t)(sg_platf_router_cbarg_t); typedef void (*sg_platf_link_cb_t)(sg_platf_link_cbarg_t); typedef void (*sg_platf_peer_cb_t)(sg_platf_peer_cbarg_t); +typedef void (*sg_platf_ASopen_cb_t)(const char*id, const char*routing); void sg_platf_host_add_cb(sg_platf_host_cb_t); void sg_platf_router_add_cb(sg_platf_router_cb_t); void sg_platf_link_add_cb(sg_platf_link_cb_t); void sg_platf_peer_add_cb(sg_platf_peer_cb_t fct); void sg_platf_postparse_add_cb(void_f_void_t fct); +void sg_platf_ASopen_add_cb(sg_platf_ASopen_cb_t fct); +void sg_platf_ASclose_add_cb(void_f_void_t fct); + diff --git a/src/instr/instr_routing.c b/src/instr/instr_routing.c index 765dcea227..c81c10318a 100644 --- a/src/instr/instr_routing.c +++ b/src/instr/instr_routing.c @@ -288,8 +288,8 @@ void instr_routing_define_callbacks () if (!TRACE_is_enabled()) return; //always need the call backs to ASes (we need only the root AS), //to create the rootContainer and the rootType properly - surfxml_add_callback(STag_surfxml_AS_cb_list, &instr_routing_parse_start_AS); - surfxml_add_callback(ETag_surfxml_AS_cb_list, &instr_routing_parse_end_AS); + sg_platf_ASopen_add_cb(instr_routing_parse_start_AS); + sg_platf_ASclose_add_cb(instr_routing_parse_end_AS); if (!TRACE_needs_platform()) return; sg_platf_link_add_cb(instr_routing_parse_start_link); sg_platf_host_add_cb(instr_routing_parse_start_host); diff --git a/src/surf/sg_platf.c b/src/surf/sg_platf.c index f19336a855..4d526eec04 100644 --- a/src/surf/sg_platf.c +++ b/src/surf/sg_platf.c @@ -15,6 +15,8 @@ xbt_dynar_t sg_platf_host_cb_list = NULL; // of sg_platf_host_cb_t xbt_dynar_t sg_platf_link_cb_list = NULL; // of sg_platf_link_cb_t xbt_dynar_t sg_platf_router_cb_list = NULL; // of sg_platf_router_cb_t xbt_dynar_t sg_platf_peer_cb_list = NULL; // of sg_platf_peer_cb_t +xbt_dynar_t sg_platf_ASopen_cb_list = NULL; //of sg_platf_ASopen_cb_t +xbt_dynar_t sg_platf_ASclose_cb_list = NULL; //of void_f_void_t xbt_dynar_t sg_platf_postparse_cb_list = NULL; // of void_f_void_t /** Module management function: creates all internal data structures */ @@ -24,6 +26,8 @@ void sg_platf_init(void) { sg_platf_link_cb_list = xbt_dynar_new(sizeof(sg_platf_host_cb_t), NULL); sg_platf_peer_cb_list = xbt_dynar_new(sizeof(sg_platf_peer_cb_t), NULL); sg_platf_postparse_cb_list = xbt_dynar_new(sizeof(sg_platf_link_cb_t),NULL); + sg_platf_ASopen_cb_list = xbt_dynar_new(sizeof(sg_platf_ASopen_cb_t),NULL); + sg_platf_ASclose_cb_list = xbt_dynar_new(sizeof(void_f_void_t),NULL); } /** Module management function: frees all internal data structures */ void sg_platf_exit(void) { @@ -31,6 +35,8 @@ void sg_platf_exit(void) { xbt_dynar_free(&sg_platf_router_cb_list); xbt_dynar_free(&sg_platf_postparse_cb_list); xbt_dynar_free(&sg_platf_peer_cb_list); + xbt_dynar_free(&sg_platf_ASopen_cb_list); + xbt_dynar_free(&sg_platf_ASclose_cb_list); } void sg_platf_new_host(sg_platf_host_cbarg_t h){ @@ -72,6 +78,22 @@ void sg_platf_close() { } } +void sg_platf_new_AS_open(const char *id, const char *routing) { + unsigned int iterator; + sg_platf_ASopen_cb_t fun; + xbt_dynar_foreach(sg_platf_ASopen_cb_list, iterator, fun) { + (*fun) (id,routing); + } +} + +void sg_platf_new_AS_close() { + unsigned int iterator; + void_f_void_t fun; + xbt_dynar_foreach(sg_platf_ASclose_cb_list, iterator, fun) { + (*fun) (); + } +} + void sg_platf_host_add_cb(sg_platf_host_cb_t fct) { xbt_dynar_push(sg_platf_host_cb_list, &fct); @@ -88,4 +110,10 @@ void sg_platf_peer_add_cb(sg_platf_peer_cb_t fct) { void sg_platf_postparse_add_cb(void_f_void_t fct) { xbt_dynar_push(sg_platf_postparse_cb_list, &fct); } +void sg_platf_ASopen_add_cb(sg_platf_ASopen_cb_t fct) { + xbt_dynar_push(sg_platf_ASopen_cb_list, &fct); +} +void sg_platf_ASclose_add_cb(void_f_void_t fct) { + xbt_dynar_push(sg_platf_ASclose_cb_list, &fct); +} diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index e9bf02bc80..be05319174 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -312,10 +312,10 @@ static void parse_E_bypassRoute_store_route(void) * Once this function was called, the configuration concerning the used * models cannot be changed anymore. * - * @param AS_id name of this autonomous system. Must be uniq in the platform + * @param AS_id name of this autonomous system. Must be unique in the platform * @param wanted_routing_type one of Full, Floyd, Dijkstra or similar. Full list in the variable routing_models, in src/surf/surf_routing.c */ -void sg_platf_new_AS_open(const char *AS_id, const char *wanted_routing_type) +void routing_AS_open(const char *AS_id, const char *wanted_routing_type) { routing_component_t new_routing; model_type_t model = NULL; @@ -388,7 +388,7 @@ void sg_platf_new_AS_open(const char *AS_id, const char *wanted_routing_type) * even if you add stuff to a closed AS * */ -void sg_platf_new_AS_close() { +void routing_AS_close() { if (current_routing == NULL) { THROWF(arg_error, 0, "Close an AS, but none was under construction"); @@ -1881,4 +1881,3 @@ static void routing_parse_Srandom(void) xbt_dynar_free(&radical_elements); } } - diff --git a/src/surf/surfxml_parse.c b/src/surf/surfxml_parse.c index 9235b3cecd..7a7383ca8a 100644 --- a/src/surf/surfxml_parse.c +++ b/src/surf/surfxml_parse.c @@ -68,8 +68,6 @@ xbt_dynar_t STag_surfxml_trace_connect_cb_list = NULL; xbt_dynar_t ETag_surfxml_trace_connect_cb_list = NULL; xbt_dynar_t STag_surfxml_random_cb_list = NULL; xbt_dynar_t ETag_surfxml_random_cb_list = NULL; -xbt_dynar_t STag_surfxml_AS_cb_list = NULL; -xbt_dynar_t ETag_surfxml_AS_cb_list = NULL; xbt_dynar_t STag_surfxml_ASroute_cb_list = NULL; xbt_dynar_t ETag_surfxml_ASroute_cb_list = NULL; xbt_dynar_t STag_surfxml_bypassRoute_cb_list = NULL; @@ -174,8 +172,6 @@ void surf_parse_init_callbacks(void) xbt_dynar_new(sizeof(void_f_void_t), NULL); STag_surfxml_random_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL); ETag_surfxml_random_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL); - STag_surfxml_AS_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL); - ETag_surfxml_AS_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL); STag_surfxml_ASroute_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL); ETag_surfxml_ASroute_cb_list = @@ -224,8 +220,6 @@ void surf_parse_free_callbacks(void) xbt_dynar_free(&ETag_surfxml_trace_connect_cb_list); xbt_dynar_free(&STag_surfxml_random_cb_list); xbt_dynar_free(&ETag_surfxml_random_cb_list); - xbt_dynar_free(&STag_surfxml_AS_cb_list); - xbt_dynar_free(&ETag_surfxml_AS_cb_list); xbt_dynar_free(&STag_surfxml_ASroute_cb_list); xbt_dynar_free(&ETag_surfxml_ASroute_cb_list); xbt_dynar_free(&STag_surfxml_bypassRoute_cb_list); @@ -421,7 +415,10 @@ void STag_surfxml_trace_connect(void){ surfxml_call_cb_functions(STag_surfxml_trace_connect_cb_list); } void STag_surfxml_AS(void){ - surfxml_call_cb_functions(STag_surfxml_AS_cb_list); + sg_platf_new_AS_open(A_surfxml_AS_id,A_surfxml_AS_routing); +} +void ETag_surfxml_AS(void){ + sg_platf_new_AS_close(); } void STag_surfxml_ASroute(void){ surfxml_call_cb_functions(STag_surfxml_ASroute_cb_list); @@ -466,7 +463,6 @@ parse_method(E, prop); parse_method(E, trace); parse_method(E, trace_connect); parse_method(E, random); -parse_method(E, AS); parse_method(E, ASroute); parse_method(E, bypassRoute); diff --git a/src/surf/surfxml_parseplatf.c b/src/surf/surfxml_parseplatf.c index f1d0d4bd46..50e6301157 100644 --- a/src/surf/surfxml_parseplatf.c +++ b/src/surf/surfxml_parseplatf.c @@ -136,14 +136,6 @@ static void parse_Stag_trace_connect(void) } } -/* Call the right C function when we see the tags */ -static void parse_S_AS(void) { - sg_platf_new_AS_open(A_surfxml_AS_id, A_surfxml_AS_routing); -} -static void parse_E_AS(void) { - sg_platf_new_AS_close(); -} - /* Init and free parse data */ static void init_data(void) @@ -164,8 +156,8 @@ static void init_data(void) &parse_Stag_trace_connect); /* we care about the ASes while parsing the platf. Incredible, isnt it? */ - surfxml_add_callback(STag_surfxml_AS_cb_list, &parse_S_AS); - surfxml_add_callback(ETag_surfxml_AS_cb_list, &parse_E_AS); + sg_platf_ASclose_add_cb(routing_AS_close); + sg_platf_ASopen_add_cb(routing_AS_open); } static void free_data(void) -- 2.20.1