Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
change way vivaldi coordinates are managed internally
[simgrid.git] / src / kernel / EngineImpl.cpp
index 28f993c..0635354 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2020. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2016-2021. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -10,7 +10,6 @@
 #include "simgrid/s4u/Host.hpp"
 #include "src/kernel/resource/DiskImpl.hpp"
 #include "src/simix/smx_private.hpp"
-#include "src/surf/StorageImpl.hpp"
 #include "src/surf/network_interface.hpp"
 #include "src/surf/xml/platf.hpp" // FIXME: KILLME. There must be a better way than mimicking XML here
 
@@ -30,16 +29,12 @@ EngineImpl::~EngineImpl()
   for (auto const& kv : netpoints_)
     delete kv.second;
 
-  for (auto const& kv : storages_)
-    if (kv.second)
-      kv.second->destroy();
-
   for (auto const& kv : links_)
     if (kv.second)
       kv.second->destroy();
 }
 
-void EngineImpl::load_deployment(const std::string& file)
+void EngineImpl::load_deployment(const std::string& file) const
 {
   sg_platf_exit();
   sg_platf_init();
@@ -58,5 +53,19 @@ void EngineImpl::register_default(const actor::ActorCodeFactory& code)
   default_function = code;
 }
 
+void EngineImpl::add_model(std::shared_ptr<resource::Model> model, const std::vector<resource::Model*>& dependencies)
+{
+  auto model_name = model->get_name();
+  xbt_assert(models_prio_.find(model_name) == models_prio_.end(),
+             "Model %s already exists, use model.set_name() to change its name", model_name.c_str());
+
+  for (const auto dep : dependencies) {
+    xbt_assert(models_prio_.find(dep->get_name()) != models_prio_.end(),
+               "Model %s doesn't exists. Impossible to use it as dependency.", dep->get_name().c_str());
+  }
+  models_.push_back(model.get());
+  models_prio_[model_name] = std::move(model);
+}
+
 } // namespace kernel
 } // namespace simgrid