Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Cut k/m/Resource.[ch] to its own files
[simgrid.git] / src / kernel / EngineImpl.cpp
1 /* Copyright (c) 2016-2017. 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/s4u/Host.hpp"
8 #include "src/kernel/routing/NetPoint.hpp"
9 #include "src/kernel/routing/NetZoneImpl.hpp"
10
11 #include <algorithm>
12
13 namespace simgrid {
14 namespace kernel {
15
16 EngineImpl::EngineImpl() = default;
17 EngineImpl::~EngineImpl()
18 {
19   /* copy all names to not modify the map while iterating over it.
20    *
21    * Plus, the hosts are destroyed in the lexicographic order to ensure
22    * that the output is reproducible: we don't want to kill them in the
23    * pointer order as it could be platform-dependent, which would break
24    * the tests.
25    */
26   std::vector<std::string> names;
27   for (auto const& kv : hosts_)
28     names.push_back(kv.second->getName());
29
30   std::sort(names.begin(), names.end());
31
32   for (auto const& name : names)
33     hosts_.at(name)->destroy();
34
35   /* Also delete the other data */
36   delete netRoot_;
37   for (auto const& kv : netpoints_)
38     delete kv.second;
39 }
40 }
41 }