* 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"
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<std::string, LinkImpl*>* LinkImpl::links = new std::unordered_map<std::string, LinkImpl*>();
-
-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<s4u::Link*>* 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 *
*********/
{
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());
}
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());