X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d7137248837c462e9a20c5640f2c74541faa7ef5..aa81c22541cf879a49de1ab587cb10eab7abb38b:/src/surf/network_interface.cpp diff --git a/src/surf/network_interface.cpp b/src/surf/network_interface.cpp index 40939e4467..4960b2ac4c 100644 --- a/src/surf/network_interface.cpp +++ b/src/surf/network_interface.cpp @@ -4,6 +4,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "network_interface.hpp" +#include "simgrid/s4u/Engine.hpp" #include "simgrid/sg_config.hpp" #include "src/surf/surf_interface.hpp" #include "surf/surf.hpp" @@ -13,52 +14,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network, surf, "Logging specific to the SURF network module"); -namespace simgrid { -namespace kernel { -namespace resource { - -/* List of links */ -std::unordered_map* LinkImpl::links = new std::unordered_map(); - -LinkImpl* LinkImpl::by_name(std::string name) -{ - auto link = links->find(name); - return link == links->end() ? nullptr : link->second; -} -/** @brief Returns the amount of links in the platform */ -int LinkImpl::linksCount() -{ - return links->size(); -} -void LinkImpl::linksList(std::vector* linkList) -{ - for (auto const& kv : *links) { - linkList->push_back(&kv.second->piface_); - } -} - -/** @brief Returns a list of all existing links */ -LinkImpl** LinkImpl::linksList() -{ - LinkImpl** res = xbt_new(LinkImpl*, (int)links->size()); - int i = 0; - for (auto const& kv : *links) { - res[i] = kv.second; - i++; - } - return res; -} -/** @brief destructor of the static data */ -void LinkImpl::linksExit() -{ - for (auto const& kv : *links) - (kv.second)->destroy(); - delete links; -} -} -} -} // namespace simgrid - /********* * Model * *********/ @@ -122,12 +77,12 @@ LinkImpl::LinkImpl(NetworkModel* model, const std::string& name, lmm::Constraint { if (name != "__loopback__") - xbt_assert(not LinkImpl::by_name(name), "Link '%s' declared several times in the platform.", name.c_str()); + xbt_assert(not s4u::Link::by_name_or_null(name), "Link '%s' declared several times in the platform.", name.c_str()); latency_.scale = 1; bandwidth_.scale = 1; - links->insert({name, this}); + s4u::Engine::get_instance()->link_register(name, &piface_); XBT_DEBUG("Create link '%s'", name.c_str()); } @@ -190,16 +145,12 @@ void LinkImpl::on_bandwidth_change() s4u::Link::on_bandwidth_change(this->piface_); } -void LinkImpl::set_state_trace(tmgr_trace_t trace) -{ - xbt_assert(stateEvent_ == nullptr, "Cannot set a second state trace to Link %s", get_cname()); - stateEvent_ = future_evt_set->add_trace(trace, this); -} void LinkImpl::set_bandwidth_trace(tmgr_trace_t trace) { xbt_assert(bandwidth_.event == nullptr, "Cannot set a second bandwidth trace to Link %s", get_cname()); bandwidth_.event = future_evt_set->add_trace(trace, this); } + void LinkImpl::set_latency_trace(tmgr_trace_t trace) { xbt_assert(latency_.event == nullptr, "Cannot set a second latency trace to Link %s", get_cname());