1 /* Copyright (c) 2016-2021. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include "src/kernel/EngineImpl.hpp"
7 #include "simgrid/Exception.hpp"
8 #include "simgrid/kernel/routing/NetPoint.hpp"
9 #include "simgrid/kernel/routing/NetZoneImpl.hpp"
10 #include "simgrid/s4u/Host.hpp"
11 #include "src/kernel/resource/DiskImpl.hpp"
12 #include "src/simix/smx_private.hpp"
13 #include "src/surf/network_interface.hpp"
14 #include "src/surf/xml/platf.hpp" // FIXME: KILLME. There must be a better way than mimicking XML here
19 EngineImpl::~EngineImpl()
21 /* Since hosts_ is a std::map, the hosts are destroyed in the lexicographic order, which ensures that the output is
24 while (not hosts_.empty())
25 hosts_.begin()->second->destroy();
27 /* Also delete the other data */
29 for (auto const& kv : netpoints_)
32 for (auto const& kv : links_)
37 void EngineImpl::load_deployment(const std::string& file) const
42 surf_parse_open(file);
47 void EngineImpl::register_function(const std::string& name, const actor::ActorCodeFactory& code)
49 registered_functions[name] = code;
51 void EngineImpl::register_default(const actor::ActorCodeFactory& code)
53 default_function = code;
56 void EngineImpl::add_model(std::shared_ptr<resource::Model> model, const std::vector<resource::Model*>& dependencies)
58 auto model_name = model->get_name();
59 xbt_assert(models_prio_.find(model_name) == models_prio_.end(),
60 "Model %s already exists, use model.set_name() to change its name", model_name.c_str());
62 for (const auto dep : dependencies) {
63 xbt_assert(models_prio_.find(dep->get_name()) != models_prio_.end(),
64 "Model %s doesn't exists. Impossible to use it as dependency.", dep->get_name().c_str());
66 models_.push_back(model.get());
67 models_prio_[model_name] = std::move(model);
71 } // namespace simgrid