Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove all xbt_assert.*(0,FALSE or NULL for xbt_die
[simgrid.git] / src / surf / gtnets / gtnets_topology.cc
index 7a21c64..7df843c 100644 (file)
@@ -9,11 +9,12 @@
 //Temporary classes for generating GTNetS topology
 
 #include "gtnets_topology.h"
-#ifdef DEBUG0
-       #undef DEBUG0
+#ifdef XBT_DEBUG
+       #undef XBT_DEBUG
 #endif
 #include "xbt/log.h"
 #include "xbt/asserts.h"
+#include <stdio.h> //for fflush in print_topology
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network_gtnets_topology, surf_network_gtnets,
                                 "Logging specific to the SURF network GTNetS simulator");
@@ -67,7 +68,7 @@ bool GTNETS_Node::include(int hostid){
 void GTNETS_Node::print_hosts(){
   set<int>::iterator it;
   for (it = hosts_.begin(); it != hosts_.end(); it++){
-    DEBUG1("host id %d", *it);
+    XBT_DEBUG("host id %d", *it);
   }
 }
 
@@ -95,15 +96,13 @@ GTNETS_Link::~GTNETS_Link(){
 }
 
 void GTNETS_Link::print_link_status(){
-  DEBUG1("link id: %d", ID_);
+  XBT_DEBUG("****** link id: %d", ID_);
   if (src_node_){
-    DEBUG2("[src] id: %d, is it router?: %d, host list: ",src_node_->id(), src_node_->is_router());
-    src_node_->print_hosts();
+    XBT_DEBUG("[src] id: %d, is it router?: %d",src_node_->id(), src_node_->is_router());
   }
 
   if (dst_node_){
-    DEBUG2("[dst] id: %d, is it router?: %d, host list: ",dst_node_->id(), dst_node_->is_router());
-    dst_node_->print_hosts();
+    XBT_DEBUG("[dst] id: %d, is it router?: %d",dst_node_->id(), dst_node_->is_router());
   }
 }
 
@@ -180,8 +179,11 @@ int GTNETS_Topology::add_link(int id){
 
 int GTNETS_Topology::add_router(int id){
   set<int>::iterator iter = routers_.find(id);
-  xbt_assert1((iter == routers_.end()), "Router %d already exists", id);
-  routers_.insert(id);
+  if(iter == routers_.end()){
+         routers_.insert(id);
+  }else{
+         XBT_DEBUG("Router (#%d) already exists", id);
+  }
   return 0;
 }
 
@@ -211,22 +213,15 @@ int GTNETS_Topology::add_onehop_route(int src, int dst, int linkid){
   xbt_assert1(!(iter == links_.end()), "Link %d not found", linkid);
   link = iter->second;
 
-  DEBUG4("Add onehop route, src: %d, dst: %d, linkid: %d, %d",src, dst, linkid, link->id());
+  XBT_DEBUG("Add onehop route, src (#%d), dst (#%d), linkid %d:(#%d)",src, dst, linkid, link->id());
 
   GTNETS_Node *src_node, *dst_node;
   src_node = link->src_node();
   dst_node = link->dst_node();
 
-  if (XBT_LOG_ISENABLED(surf_network_gtnets_topology, xbt_log_priority_debug)) {
-    link->print_link_status();
-    src_node->print_hosts();
-    dst_node->print_hosts();
-  }
-
-
   // If not exists a route, add one.
   if (!link->route_exists()){
-    //check whether there exists a node for the src host/router.
+    //check whether there exists a node for the src.
     int s_node_id = nodeid_from_hostid(src);
     int node_id;
 
@@ -262,7 +257,7 @@ int GTNETS_Topology::add_onehop_route(int src, int dst, int linkid){
       nodes_[d_node_id]->add_host(dst);
 
     link->add_dst(nodes_[d_node_id]);
-  }else if (src_node && dst_node){
+  }else if (!(src_node && dst_node)){
       xbt_assert0((src_node && dst_node), "Either src or dst is null");
   }
 
@@ -363,8 +358,9 @@ int GTNETS_Topology::add_onehop_route(int src, int dst, int linkid){
       
   }
   else{
-    xbt_assert0(0, "Shouldn't be here");
+    xbt_die("Shouldn't be here");
   }
+
   return 0;
 }
 
@@ -376,13 +372,13 @@ int GTNETS_Topology::nodeid_from_hostid(int hostid){
 }
 
 void GTNETS_Topology::print_topology(){
-  DEBUG0("<<<<<================================>>>>>");
-  DEBUG0("Dumping GTNETS topollogy information");
+  XBT_DEBUG("<<<<<================================>>>>>");
+  XBT_DEBUG("Dumping GTNETS topollogy information");
   map<int, GTNETS_Link*>::iterator it;
   for (it = links_.begin(); it != links_.end(); it++){
     it->second->print_link_status();
   }
-  DEBUG0(">>>>>================================<<<<<");
+  XBT_DEBUG(">>>>>================================<<<<<");
   fflush(NULL);
 }