Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
surfxml: better error checking, and less include of internal headers
[simgrid.git] / src / surf / sg_platf.cpp
index 2e0adca..2c4dd11 100644 (file)
@@ -55,6 +55,7 @@ void sg_platf_exit(void) {
 
   /* make sure that we will reinit the models while loading the platf once reinited */
   surf_parse_models_setup_already_called = 0;
+  surf_parse_lex_destroy();
 }
 
 /** @brief Add an "host" to the current AS */
@@ -122,15 +123,14 @@ void sg_platf_new_router(sg_platf_router_cbarg_t router)
 
   if (current_routing->hierarchy_ == SURF_ROUTING_NULL)
     current_routing->hierarchy_ = SURF_ROUTING_BASE;
-  xbt_assert(!xbt_lib_get_or_null(as_router_lib, router->id, ROUTING_ASR_LEVEL),
-             "Reading a router, processing unit \"%s\" already exists",
-             router->id);
+  xbt_assert(nullptr == xbt_lib_get_or_null(as_router_lib, router->id, ROUTING_ASR_LEVEL),
+             "Refusing to create a router named '%s': this name already describes a node.", router->id);
 
-  simgrid::surf::NetCard *info = new simgrid::surf::NetCardImpl(router->id, SURF_NETWORK_ELEMENT_ROUTER, current_routing);
-  info->setId(current_routing->addComponent(info));
-  xbt_lib_set(as_router_lib, router->id, ROUTING_ASR_LEVEL, (void *) info);
-  XBT_DEBUG("Having set name '%s' id '%d'", router->id, info->id());
-  simgrid::surf::netcardCreatedCallbacks(info);
+  simgrid::surf::NetCard *netcard = new simgrid::surf::NetCardImpl(router->id, SURF_NETWORK_ELEMENT_ROUTER, current_routing);
+  netcard->setId(current_routing->addComponent(netcard));
+  xbt_lib_set(as_router_lib, router->id, ROUTING_ASR_LEVEL, (void *) netcard);
+  XBT_DEBUG("Having set name '%s' id '%d'", router->id, netcard->id());
+  simgrid::surf::netcardCreatedCallbacks(netcard);
 
   if (router->coord && strcmp(router->coord, "")) {
     unsigned int cursor;
@@ -515,7 +515,7 @@ void sg_platf_new_route(sg_platf_route_cbarg_t route)
 
 void sg_platf_new_bypassRoute(sg_platf_route_cbarg_t bypassRoute)
 {
-  routing_get_current()->parseBypassroute(bypassRoute);
+  routing_get_current()->addBypassRoute(bypassRoute);
 }
 
 void sg_platf_new_process(sg_platf_process_cbarg_t process)