X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d12368e5b9db4863e721dd4f9ed40574b9860da6..1c006a013e83828a40b76b6c652a995b5c2fa552:/src/s4u/s4u_host.cpp diff --git a/src/s4u/s4u_host.cpp b/src/s4u/s4u_host.cpp index 82d6d66ca2..2e25a3d198 100644 --- a/src/s4u/s4u_host.cpp +++ b/src/s4u/s4u_host.cpp @@ -33,8 +33,6 @@ template class Extendable; namespace s4u { -std::map host_list; // FIXME: move it to Engine - simgrid::xbt::signal Host::onCreation; simgrid::xbt::signal Host::onDestruction; simgrid::xbt::signal Host::onStateChange; @@ -44,7 +42,7 @@ Host::Host(const char* name) : name_(name) { xbt_assert(Host::by_name_or_null(name) == nullptr, "Refusing to create a second host named '%s'.", name); - host_list[name_] = this; + Engine::getInstance()->addHost(std::string(name_), this); new simgrid::surf::HostImpl(this); } @@ -72,27 +70,26 @@ void Host::destroy() if (not currentlyDestroying_) { currentlyDestroying_ = true; onDestruction(*this); - host_list.erase(name_); + Engine::getInstance()->delHost(std::string(name_)); delete this; } } Host* Host::by_name(std::string name) { - return host_list.at(name); // Will raise a std::out_of_range if the host does not exist + return Engine::getInstance()->hostByName(name); } Host* Host::by_name(const char* name) { - return host_list.at(std::string(name)); // Will raise a std::out_of_range if the host does not exist + return Engine::getInstance()->hostByName(std::string(name)); } Host* Host::by_name_or_null(const char* name) { - return by_name_or_null(std::string(name)); + return Engine::getInstance()->hostByNameOrNull(std::string(name)); } Host* Host::by_name_or_null(std::string name) { - auto host = host_list.find(name); - return host == host_list.end() ? nullptr : host->second; + return Engine::getInstance()->hostByNameOrNull(name); } Host *Host::current(){