Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
not all resources need a property set, only Host, Link and Storage
[simgrid.git] / src / surf / surf_c_bindings.cpp
index fb4004a..bc658f3 100644 (file)
@@ -171,7 +171,7 @@ void routing_get_route_and_latency(sg_routing_edge_t src, sg_routing_edge_t dst,
 surf_host_model_t surf_host_get_model(sg_host_t host)
 {
   simgrid::surf::Host* surf_host =
-    (simgrid::surf::Host*) host->facet(SURF_HOST_LEVEL);
+    (simgrid::surf::Host*) host->facet<simgrid::surf::Host>();
   return (surf_host_model_t) surf_host->getModel();
 }
 
@@ -242,10 +242,6 @@ const char *surf_resource_name(surf_cpp_resource_t resource){
   return resource->getName();
 }
 
-xbt_dict_t surf_resource_get_properties(surf_cpp_resource_t resource){
-  return resource->getProperties();
-}
-
 e_surf_resource_state_t surf_resource_get_state(surf_cpp_resource_t resource){
   return resource->getState();
 }
@@ -258,6 +254,10 @@ surf_action_t surf_host_sleep(sg_host_t host, double duration){
   return get_casted_host(host)->sleep(duration);
 }
 
+xbt_dict_t sg_host_get_properties(sg_host_t host) {
+       return get_casted_host(host)->getProperties();
+}
+
 double surf_host_get_speed(sg_host_t host, double load){
   return sg_host_surfcpu(host)->getSpeed(load);
 }
@@ -385,8 +385,6 @@ void surf_host_set_params(sg_host_t host, vm_params_t params){
 }
 
 void surf_vm_destroy(sg_host_t resource){
-  /* Before clearing the entries in host_lib, we have to pick up resources. */
-  const char* name = resource->id().c_str();
   /* We deregister objects from host_lib, without invoking the freeing callback
    * of each level.
    *
@@ -395,8 +393,7 @@ void surf_vm_destroy(sg_host_t resource){
    */
   sg_host_surfcpu_destroy(resource);
   sg_host_edge_destroy(resource,1);
-  // TODO, use backlink from simgrid::surf::Host to simgrid::Host
-  simgrid::Host::by_name_or_null(name)->set_facet(SURF_HOST_LEVEL, nullptr);
+  resource->set_facet<simgrid::surf::Host>(nullptr);
 
   /* TODO: comment out when VM storage is implemented. */
   // host->set_facet(SURF_STORAGE_LEVEL, nullptr);
@@ -450,6 +447,10 @@ sg_size_t surf_storage_get_used_size(surf_resource_t resource){
   return static_cast<simgrid::surf::Storage*>(surf_storage_resource_priv(resource))->getUsedSize();
 }
 
+xbt_dict_t surf_storage_get_properties(surf_resource_t resource){
+  return static_cast<simgrid::surf::Storage*>(surf_storage_resource_priv(resource))->getProperties();
+}
+
 const char* surf_storage_get_host(surf_resource_t resource){
   return static_cast<simgrid::surf::Storage*>(surf_storage_resource_priv(resource))->p_attach;
 }