]> AND Private Git Repository - loba.git/blobdiff - neighbor.cpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
Merge branch 'master' of ssh://info.iut-bm.univ-fcomte.fr/loba
[loba.git] / neighbor.cpp
index e7a4666151df22ecc771ef1c9c883cfdb8e4f0ec..752378312ef2a4ee0fad36cefdb89e221aba8bfd 100644 (file)
@@ -1,18 +1,30 @@
-#include <xbt/sysdep.h>
+#include <limits>
+#include <msg/msg.h>
+
+XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(proc); // needed to compile neighbor.h
+
+#include "misc.h"
+
 #include "neighbor.h"
 
 neighbor::neighbor(const char* hostname)
+    : host(static_cast<hostdata*>(MSG_host_get_data(MSG_get_host_by_name(hostname))))
+    , load(std::numeric_limits<double>::infinity())
+    , debt(0.0)
+    , to_send(0.0)
 {
-    load = std::numeric_limits<double>::infinity();
-    debt = 0.0;
-    name = xbt_strdup(hostname);
-    ctrl_mbox = bprintf("%s_ctrl", hostname);
-    data_mbox = bprintf("%s_data", hostname);
 }
 
 neighbor::~neighbor()
 {
-    free(data_mbox);
-    free(ctrl_mbox);
-    free(name);
+}
+
+void neighbor::print(bool verbose,
+                     e_xbt_log_priority_t logp, xbt_log_category_t cat) const
+{
+    if (verbose)
+        XCLOG4(cat, logp, "%s: load = %g ; debt = %g ; to_send = %g",
+              get_name(), get_load(), get_debt(), get_to_send());
+    else
+        XCLOG2(cat, logp, "%s: load = %g", get_name(), get_load());
 }