Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
better leaking than segfaulting
[simgrid.git] / src / surf / callbacks.cpp
index d8d48c7..34774a0 100644 (file)
 #include "src/surf/surf_interface.hpp"
 #include "src/surf/host_interface.hpp"
 
-void surf_host_created_callback(void (*callback)(sg_host_t))
+void surf_on_host_created(void (*callback)(sg_host_t))
 {
-  hostCreatedCallbacks.connect([callback](Host* host) {
-    const char* id = host->getName();
-    sg_host_t h = sg_host_by_name(id);
-    xbt_assert(h != NULL, "Host not found for name %s", id);
-    callback(h);
+  simgrid::surf::Host::onCreation.connect([callback](simgrid::surf::Host* host) {
+    callback(host->p_host);
+  });
+}
+
+void surf_on_storage_created(void (*callback)(sg_storage_t))
+{
+  simgrid::surf::storageCreatedCallbacks.connect([callback](simgrid::surf::Storage* storage) {
+    const char* id = storage->getName();
+    // TODO, create sg_storage_by_name
+    sg_storage_t s = xbt_lib_get_elm_or_null(storage_lib, id);
+    xbt_assert(s != NULL, "Storage not found for name %s", id);
+    callback(s);
   });
 }