Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
dynar to std::vector
[simgrid.git] / teshsuite / surf / surf_usage2 / surf_usage2.cpp
index 0fc3a43..f849953 100644 (file)
@@ -17,15 +17,15 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test, "Messages specific for surf example");
 
 int main(int argc, char **argv)
 {
-  sg_host_t hostA = NULL;
-  sg_host_t hostB = NULL;
+  sg_host_t hostA = nullptr;
+  sg_host_t hostB = nullptr;
   double now = -1.0;
   int running;
 
   surf_init(&argc, argv);       /* Initialize some common structures */
 
-  xbt_cfg_set_parse(_sg_cfg_set, "network/model:CM02");
-  xbt_cfg_set_parse(_sg_cfg_set, "cpu/model:Cas01");
+  xbt_cfg_set_parse("network/model:CM02");
+  xbt_cfg_set_parse("cpu/model:Cas01");
 
   xbt_assert(argc >1, "Usage : %s platform.txt\n", argv[0]);
   parse_platform_file(argv[1]);
@@ -47,28 +47,32 @@ int main(int argc, char **argv)
 
   surf_solve(-1.0);                 /* Takes traces into account. Returns 0.0 */
   do {
-    surf_action_t action = NULL;
-    unsigned int iter;
-    surf_model_t model = NULL;
+    surf_action_t action = nullptr;
     running = 0;
 
     now = surf_get_clock();
     XBT_INFO("Next Event : %g", now);
 
-    xbt_dynar_foreach(all_existing_models, iter, model) {
+    for (auto model: *all_existing_models) {
       if (surf_model_running_action_set_size((surf_model_t)model)) {
         XBT_DEBUG("\t Running that model");
         running = 1;
       }
-      while ((action = surf_model_extract_failed_action_set((surf_model_t)model))) {
+
+      action = surf_model_extract_failed_action_set(static_cast<surf_model_t>(model));
+      while (action != nullptr) {
         XBT_INFO("   * Done Action");
         XBT_DEBUG("\t * Failed Action: %p", action);
         action->unref();
+        action = surf_model_extract_failed_action_set(static_cast<surf_model_t>(model));
       }
-      while ((action = surf_model_extract_done_action_set((surf_model_t)model))) {
+
+      action = surf_model_extract_done_action_set(static_cast<surf_model_t>(model));
+      while (action != nullptr){
         XBT_INFO("   * Done Action");
         XBT_DEBUG("\t * Done Action: %p", action);
         action->unref();
+        action = surf_model_extract_done_action_set(static_cast<surf_model_t>(model));
       }
     }
   } while (running && surf_solve(-1.0) >= 0.0);