Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
SURF: Unify the types of models in a uniq s_surf_model_t (using an union) +reindent...
[simgrid.git] / src / surf / surf.c
index a4e1d75..2c32aa7 100644 (file)
@@ -106,10 +106,6 @@ int __surf_is_absolute_file_path(const char *file_path)
 #endif
 }
 
-typedef struct surf_model_object {
-  surf_model_t model;
-} s_surf_model_object_t, *surf_model_object_t;
-
 static double NOW = 0;
 
 xbt_dynar_t model_list = NULL;
@@ -243,7 +239,7 @@ double generic_maxmin_share_resources(xbt_swag_t running_actions,
 e_surf_action_state_t surf_action_get_state(surf_action_t action)
 {
   surf_action_state_t action_state =
-    &(action->model_type->common_public->states);
+    &(action->model_type->common_public.states);
 
   if (action->state_set == action_state->ready_action_set)
     return SURF_ACTION_READY;
@@ -268,7 +264,7 @@ double surf_action_get_finish_time(surf_action_t action)
 
 void surf_action_free(surf_action_t * action)
 {
-  (*action)->model_type->common_public->action_cancel(*action);
+  (*action)->model_type->common_public.action_cancel(*action);
   free(*action);
   *action = NULL;
 }
@@ -277,7 +273,7 @@ void surf_action_change_state(surf_action_t action,
                               e_surf_action_state_t state)
 {
   surf_action_state_t action_state =
-    &(action->model_type->common_public->states);
+    &(action->model_type->common_public.states);
   XBT_IN2("(%p,%s)", action, surf_action_state_names[state]);
   xbt_swag_remove(action, action->state_set);
 
@@ -350,7 +346,7 @@ void surf_init(int *argc, char **argv)
   if (!history)
     history = tmgr_history_new();
 
-  surf_config_init(argc,argv);
+  surf_config_init(argc, argv);
 }
 
 static char *path_name = NULL;
@@ -436,7 +432,7 @@ void surf_presolve(void)
   double next_event_date = -1.0;
   tmgr_trace_event_t event = NULL;
   double value = -1.0;
-  surf_model_object_t model_obj = NULL;
+  surf_resource_t resource = NULL;
   surf_model_t model = NULL;
   unsigned int iter;
 
@@ -447,10 +443,10 @@ void surf_presolve(void)
       break;
     while ((event =
             tmgr_history_get_next_event_leq(history, next_event_date,
-                                            &value, (void **) &model_obj))) {
-      model_obj->model->common_private->update_resource_state(model_obj,
-                                                              event, value,
-                                                              NOW);
+                                            &value, (void **) &resource))) {
+      resource->model->common_private->update_resource_state(resource,
+                                                             event, value,
+                                                             NOW);
     }
   }
   xbt_dynar_foreach(model_list, iter, model) {
@@ -464,7 +460,7 @@ double surf_solve(void)
   double next_event_date = -1.0;
   double model_next_action_end = -1.0;
   double value = -1.0;
-  surf_model_object_t model_obj = NULL;
+  surf_resource_t resource = NULL;
   surf_model_t model = NULL;
   tmgr_trace_event_t event = NULL;
   unsigned int iter;
@@ -473,10 +469,10 @@ double surf_solve(void)
 
   DEBUG0("Looking for next action end");
   xbt_dynar_foreach(model_list, iter, model) {
-    DEBUG1("Running for Resource [%s]", model->common_public->name);
+    DEBUG1("Running for Resource [%s]", model->common_public.name);
     model_next_action_end = model->common_private->share_resources(NOW);
     DEBUG2("Resource [%s] : next action end = %f",
-           model->common_public->name, model_next_action_end);
+           model->common_public.name, model_next_action_end);
     if (((min < 0.0) || (model_next_action_end < min))
         && (model_next_action_end >= 0.0))
       min = model_next_action_end;
@@ -494,17 +490,17 @@ double surf_solve(void)
     DEBUG0("Updating models");
     while ((event =
             tmgr_history_get_next_event_leq(history, next_event_date,
-                                            &value, (void **) &model_obj))) {
-      if (model_obj->model->common_private->resource_used(model_obj)) {
+                                            &value, (void **) &resource))) {
+      if (resource->model->common_private->resource_used(resource)) {
         min = next_event_date - NOW;
         DEBUG1
           ("This event will modify model state. Next event set to %f", min);
       }
       /* update state of model_obj according to new value. Does not touch lmm.
          It will be modified if needed when updating actions */
-      model_obj->model->common_private->update_resource_state(model_obj,
-                                                              event, value,
-                                                              NOW + min);
+      resource->model->common_private->update_resource_state(resource,
+                                                             event, value,
+                                                             NOW + min);
     }
   }