char* surf_parsed_filename = NULL; // to locate parse error messages
+xbt_dynar_t parsed_link_list = NULL; /* temporary store of current list link of a route */
+
/*
* Helping functions
*/
*/
/* make sure these symbols are defined as strong ones in this file so that the linker can resolve them */
-xbt_dynar_t STag_surfxml_process_cb_list = NULL;
-xbt_dynar_t ETag_surfxml_process_cb_list = NULL;
-xbt_dynar_t STag_surfxml_argument_cb_list = NULL;
-xbt_dynar_t ETag_surfxml_argument_cb_list = NULL;
/* The default current property receiver. Setup in the corresponding opening callbacks. */
xbt_dict_t current_property_set = NULL;
void surf_parse_init_callbacks(void)
{
- sg_platf_init(); // FIXME: move to a proper place?
- STag_surfxml_process_cb_list =
- xbt_dynar_new(sizeof(void_f_void_t), NULL);
- ETag_surfxml_process_cb_list =
- xbt_dynar_new(sizeof(void_f_void_t), NULL);
- STag_surfxml_argument_cb_list =
- xbt_dynar_new(sizeof(void_f_void_t), NULL);
- ETag_surfxml_argument_cb_list =
- xbt_dynar_new(sizeof(void_f_void_t), NULL);
+ sg_platf_init();
}
void surf_parse_reset_callbacks(void)
void surf_parse_free_callbacks(void)
{
- sg_platf_exit(); // FIXME: better place?
-
- xbt_dynar_free(&STag_surfxml_process_cb_list);
- xbt_dynar_free(&ETag_surfxml_process_cb_list);
- xbt_dynar_free(&STag_surfxml_argument_cb_list);
- xbt_dynar_free(&ETag_surfxml_argument_cb_list);
+ sg_platf_exit();
}
/* Stag and Etag parse functions */
}
void STag_surfxml_link_ctn(void){
- s_sg_platf_linkctn_cbarg_t linkctn;
- memset(&linkctn,0,sizeof(linkctn));
-
- linkctn.id = A_surfxml_link_ctn_id;
+ char *link_id;
switch (A_surfxml_link_ctn_direction) {
case AU_surfxml_link_ctn_direction:
case A_surfxml_link_ctn_direction_NONE:
- linkctn.direction = SURF_LINK_DIRECTION_NONE;
+ link_id = xbt_strdup(A_surfxml_link_ctn_id);
break;
case A_surfxml_link_ctn_direction_UP:
- linkctn.direction = SURF_LINK_DIRECTION_UP;
+ link_id = bprintf("%s_UP", A_surfxml_link_ctn_id);
break;
case A_surfxml_link_ctn_direction_DOWN:
- linkctn.direction = SURF_LINK_DIRECTION_DOWN;
+ link_id = bprintf("%s_DOWN", A_surfxml_link_ctn_id);
break;
}
- sg_platf_new_linkctn(&linkctn);
+ // FIXME we should push the surf link object but it don't
+ // work because of model rulebased
+ xbt_dynar_push(parsed_link_list, &link_id);
}
void ETag_surfxml_backbone(void){
xbt_assert(strlen(A_surfxml_route_src) > 0 || strlen(A_surfxml_route_dst) > 0,
"Missing end-points while defining route \"%s\"->\"%s\"",
A_surfxml_route_src, A_surfxml_route_dst);
+ parsed_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
}
void STag_surfxml_ASroute(void){
xbt_assert(strlen(A_surfxml_ASroute_src) > 0 || strlen(A_surfxml_ASroute_dst) > 0
"Missing end-points while defining route \"%s\"->\"%s\" (with %s and %s as gateways)",
A_surfxml_ASroute_src, A_surfxml_ASroute_dst,
A_surfxml_ASroute_gw_src,A_surfxml_ASroute_gw_dst);
+ parsed_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
}
void STag_surfxml_bypassRoute(void){
xbt_assert(strlen(A_surfxml_bypassRoute_src) > 0 || strlen(A_surfxml_bypassRoute_dst) > 0,
"Missing end-points while defining bupass route \"%s\"->\"%s\"",
A_surfxml_bypassRoute_src, A_surfxml_bypassRoute_dst);
+ parsed_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
}
void STag_surfxml_bypassASroute(void){
xbt_assert(strlen(A_surfxml_bypassASroute_src) > 0 || strlen(A_surfxml_bypassASroute_dst) > 0
"Missing end-points while defining route \"%s\"->\"%s\" (with %s and %s as gateways)",
A_surfxml_bypassASroute_src, A_surfxml_bypassASroute_dst,
A_surfxml_bypassASroute_gw_src,A_surfxml_bypassASroute_gw_dst);
+ parsed_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
}
void ETag_surfxml_route(void){
route.src = A_surfxml_route_src;
route.dst = A_surfxml_route_dst;
+ route.link_list = parsed_link_list;
switch (A_surfxml_route_symmetrical) {
case AU_surfxml_route_symmetrical:
}
sg_platf_new_route(&route);
+ parsed_link_list = NULL;
}
void ETag_surfxml_ASroute(void){
ASroute.dst = A_surfxml_ASroute_dst;
ASroute.gw_src = A_surfxml_ASroute_gw_src;
ASroute.gw_dst = A_surfxml_ASroute_gw_dst;
+ ASroute.link_list = parsed_link_list;
switch (A_surfxml_ASroute_symmetrical) {
case AU_surfxml_ASroute_symmetrical:
}
sg_platf_new_ASroute(&ASroute);
+ parsed_link_list = NULL;
}
void ETag_surfxml_bypassRoute(void){
route.src = A_surfxml_bypassRoute_src;
route.dst = A_surfxml_bypassRoute_dst;
+ route.link_list = parsed_link_list;
sg_platf_new_bypassRoute(&route);
+ parsed_link_list = NULL;
}
void ETag_surfxml_bypassASroute(void){
ASroute.dst = A_surfxml_bypassASroute_dst;
ASroute.gw_src = A_surfxml_bypassASroute_gw_src;
ASroute.gw_dst = A_surfxml_bypassASroute_gw_dst;
+ ASroute.link_list = parsed_link_list;
sg_platf_new_bypassASroute(&ASroute);
+ parsed_link_list = NULL;
}
void ETag_surfxml_trace(void){
xbt_dict_free(¤t_property_set);
}
+static int argc;
+static char **argv;
+
+void STag_surfxml_process(void){
+ argc = 1;
+ argv = xbt_new(char *, 1);
+ argv[0] = xbt_strdup(A_surfxml_process_function);
+}
+
+void ETag_surfxml_process(void){
+ s_sg_platf_process_cbarg_t process;
+ memset(&process,0,sizeof(process));
+
+ process.argc = argc;
+ process.argv = (const char **)argv;
+ process.properties = current_property_set;
+ process.host = A_surfxml_process_host;
+ process.function = A_surfxml_process_function;
+ process.start_time = surf_parse_get_double(A_surfxml_process_start_time);
+ process.kill_time = surf_parse_get_double(A_surfxml_process_kill_time);
+
+ switch (A_surfxml_process_on_failure) {
+ case AU_surfxml_process_on_failure:
+ case A_surfxml_process_on_failure_DIE:
+ process.on_failure = SURF_PROCESS_ON_FAILURE_DIE;
+ break;
+ case A_surfxml_process_on_failure_RESTART:
+ process.on_failure = SURF_PROCESS_ON_FAILURE_RESTART;
+ break;
+ }
+
+ sg_platf_new_process(&process);
+ current_property_set = NULL;
+}
+
+void STag_surfxml_argument(void){
+ argc++;
+ argv = xbt_realloc(argv, (argc) * sizeof(char *));
+ argv[(argc) - 1] = xbt_strdup(A_surfxml_argument_value);
+}
+
/* nothing to do in those functions */
void ETag_surfxml_prop(void){}
void STag_surfxml_random(void){}
void ETag_surfxml_peer(void){}
void STag_surfxml_backbone(void){}
void ETag_surfxml_link_ctn(void){}
-
-// FIXME should not call surfxml_call_cb_functions
-void STag_surfxml_process(void){
- surfxml_call_cb_functions(STag_surfxml_process_cb_list);
-}
-void STag_surfxml_argument(void){
- surfxml_call_cb_functions(STag_surfxml_argument_cb_list);
-}
-
-#define parse_method(type,name) \
- void type##Tag_surfxml_##name(void) \
- { surfxml_call_cb_functions(type##Tag_surfxml_##name##_cb_list); } \
- void type##Tag_surfxml_##name(void)
-
-parse_method(E, process);
-parse_method(E, argument);
+void ETag_surfxml_argument(void){}
/* Open and Close parse file */
int_f_void_t surf_parse = _surf_parse;
-/* Aux parse functions */
-
-void surfxml_add_callback(xbt_dynar_t cb_list, void_f_void_t function)
-{
- xbt_dynar_push(cb_list, &function);
-}
-
-void surfxml_del_callback(xbt_dynar_t cb_list, void_f_void_t function)
-{
- xbt_ex_t e;
- unsigned int it=0;
- void_f_void_t null_f=NULL;
-
- TRY {
- it = xbt_dynar_search(cb_list,&function);
- }
- CATCH(e) {
- if (e.category == not_found_error) {
- xbt_ex_free(e);
- xbt_die("Trying to remove a callback that is not here! This should not happen");
- }
- RETHROW;
- }
-
- xbt_dynar_replace(cb_list, it,&null_f);
-}
-
-static XBT_INLINE void surfxml_call_cb_functions(xbt_dynar_t cb_list)
-{
- unsigned int iterator;
- void_f_void_t fun;
- xbt_dynar_foreach(cb_list, iterator, fun) {
- if (fun) fun();
- }
-}
-
-
/* Prop tag functions */
/**