Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
try to clean and uniformize Activity Impls
[simgrid.git] / src / kernel / EngineImpl.cpp
1 /* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved.          */
2
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. */
5
6 #include "src/kernel/EngineImpl.hpp"
7 #include "simgrid/kernel/routing/NetPoint.hpp"
8 #include "simgrid/kernel/routing/NetZoneImpl.hpp"
9 #include "simgrid/s4u/Host.hpp"
10 #include "src/surf/StorageImpl.hpp"
11 #include "src/surf/network_interface.hpp"
12
13 #include <algorithm>
14
15 namespace simgrid {
16 namespace kernel {
17
18 EngineImpl::~EngineImpl()
19 {
20   /* copy all names to not modify the map while iterating over it.
21    *
22    * Plus, the hosts are destroyed in the lexicographic order to ensure that the output is reproducible: we don't want
23    * to kill them in the pointer order as it could be platform-dependent, which would break the tests.
24    */
25   std::vector<std::string> names;
26   for (auto const& kv : hosts_)
27     names.push_back(kv.second->get_name());
28
29   std::sort(names.begin(), names.end());
30
31   for (auto const& name : names)
32     hosts_.at(name)->destroy();
33
34   /* Also delete the other data */
35   delete netzone_root_;
36   for (auto const& kv : netpoints_)
37     delete kv.second;
38
39   for (auto const& kv : storages_)
40     if (kv.second)
41       kv.second->get_impl()->destroy();
42
43   for (auto const& kv : links_)
44     if (kv.second)
45       kv.second->get_impl()->destroy();
46 }
47 }
48 }