Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines.
[simgrid.git] / src / bindings / lua / lua_platf.cpp
index b10982d..3ad9dc8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2021. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -84,8 +84,6 @@ int console_add_backbone(lua_State *L) {
   lua_getstack(L, 1, &ar);
   lua_getinfo(L, "Sl", &ar);
 
-  link.properties = nullptr;
-
   lua_ensure(lua_istable(L, -1),"Bad Arguments to create backbone in Lua. Should be a table with named arguments.");
 
   lua_pushstring(L, "id");
@@ -370,21 +368,9 @@ int console_add_route(lua_State *L) {
    */
   lua_pushstring(L,"symmetrical");
   lua_gettable(L,-2);
-  if (lua_isstring(L, -1)) {
-    const char* value = lua_tostring(L, -1);
-    if (strcmp("YES", value) == 0)
-      route.symmetrical = true;
-    else
-      route.symmetrical = false;
-  }
-  else {
-    route.symmetrical = true;
-  }
+  route.symmetrical = (not lua_isstring(L, -1) || strcasecmp("YES", lua_tostring(L, -1)) == 0);
   lua_pop(L,1);
 
-  route.gw_src = nullptr;
-  route.gw_dst = nullptr;
-
   sg_platf_new_route(&route);
 
   return 0;
@@ -442,16 +428,7 @@ int console_add_ASroute(lua_State *L) {
 
   lua_pushstring(L,"symmetrical");
   lua_gettable(L,-2);
-  if (lua_isstring(L, -1)) {
-    const char* value = lua_tostring(L, -1);
-    if (strcmp("YES", value) == 0)
-      ASroute.symmetrical = true;
-    else
-      ASroute.symmetrical = false;
-  }
-  else {
-    ASroute.symmetrical = true;
-  }
+  ASroute.symmetrical = (not lua_isstring(L, -1) || strcasecmp("YES", lua_tostring(L, -1)) == 0);
   lua_pop(L,1);
 
   sg_platf_new_route(&ASroute);
@@ -475,26 +452,9 @@ int console_AS_open(lua_State *L) {
  const char* mode = lua_tostring(L, -1);
  lua_pop(L, 1);
 
- int mode_int = A_surfxml_AS_routing_None;
- if (not strcmp(mode, "Full"))
-   mode_int = A_surfxml_AS_routing_Full;
- else if (not strcmp(mode, "Floyd"))
-   mode_int = A_surfxml_AS_routing_Floyd;
- else if (not strcmp(mode, "Dijkstra"))
-   mode_int = A_surfxml_AS_routing_Dijkstra;
- else if (not strcmp(mode, "DijkstraCache"))
-   mode_int = A_surfxml_AS_routing_DijkstraCache;
- else if (not strcmp(mode, "Vivaldi"))
-   mode_int = A_surfxml_AS_routing_Vivaldi;
- else if (not strcmp(mode, "Cluster"))
-   mode_int = A_surfxml_AS_routing_Cluster;
- else if (not strcmp(mode, "none"))
-   mode_int = A_surfxml_AS_routing_None;
- else xbt_die("Don't have the model name '%s'",mode);
-
  simgrid::kernel::routing::ZoneCreationArgs AS;
  AS.id = id;
- AS.routing = mode_int;
+ AS.routing                                    = mode;
  simgrid::kernel::routing::NetZoneImpl* new_as = sg_platf_new_Zone_begin(&AS);
 
  /* Build a Lua representation of the new AS on the stack */