X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/22e6546d2c6f14864cc93c4ed1470d8e8c1e2d95..2202dead030a10e3ef121eb452bc3ee56c8a572b:/src/s4u/s4u_link.cpp diff --git a/src/s4u/s4u_link.cpp b/src/s4u/s4u_link.cpp index c640077613..46a75c6256 100644 --- a/src/s4u/s4u_link.cpp +++ b/src/s4u/s4u_link.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2017. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2013-2018. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -6,8 +6,9 @@ #include #include "simgrid/s4u/Link.hpp" -#include "simgrid/sg_config.h" +#include "simgrid/sg_config.hpp" #include "simgrid/simix.hpp" +#include "src/kernel/lmm/maxmin.hpp" #include "src/surf/network_interface.hpp" #include "xbt/log.h" @@ -17,20 +18,18 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_link, s4u, "Logging specific to the S4U link * C API * *********/ -extern "C" { - const char* sg_link_name(sg_link_t link) { - return link->getCname(); + return link->get_cname(); } sg_link_t sg_link_by_name(const char* name) { - return simgrid::s4u::Link::byName(name); + return simgrid::s4u::Link::by_name(name); } int sg_link_is_shared(sg_link_t link) { - return link->sharingPolicy(); + return (int)link->sharingPolicy(); } double sg_link_bandwidth(sg_link_t link) { @@ -50,11 +49,11 @@ void sg_link_data_set(sg_link_t link, void* data) } int sg_link_count() { - return simgrid::surf::LinkImpl::linksCount(); + return simgrid::kernel::resource::LinkImpl::linksCount(); } sg_link_t* sg_link_list() { - simgrid::surf::LinkImpl** list = simgrid::surf::LinkImpl::linksList(); + simgrid::kernel::resource::LinkImpl** list = simgrid::kernel::resource::LinkImpl::linksList(); sg_link_t* res = (sg_link_t*)list; // Use the same memory area int size = sg_link_count(); @@ -65,8 +64,7 @@ sg_link_t* sg_link_list() } void sg_link_exit() { - simgrid::surf::LinkImpl::linksExit(); -} + simgrid::kernel::resource::LinkImpl::linksExit(); } /*********** @@ -75,28 +73,28 @@ void sg_link_exit() namespace simgrid { namespace s4u { -Link* Link::byName(const char* name) +Link* Link::by_name(const char* name) { - surf::LinkImpl* res = surf::LinkImpl::byName(name); + kernel::resource::LinkImpl* res = kernel::resource::LinkImpl::byName(name); if (res == nullptr) return nullptr; return &res->piface_; } -const std::string& Link::getName() const +const std::string& Link::get_name() const { - return this->pimpl_->getName(); + return this->pimpl_->get_name(); } -const char* Link::getCname() const +const char* Link::get_cname() const { - return this->pimpl_->getCname(); + return this->pimpl_->get_cname(); } const char* Link::name() { - return getCname(); + return get_cname(); } bool Link::isUsed() { - return this->pimpl_->isUsed(); + return this->pimpl_->is_used(); } double Link::latency() @@ -109,22 +107,23 @@ double Link::bandwidth() return this->pimpl_->bandwidth(); } -int Link::sharingPolicy() +Link::SharingPolicy Link::sharingPolicy() { return this->pimpl_->sharingPolicy(); } +double Link::getUsage() +{ + return this->pimpl_->get_constraint()->get_usage(); +} + void Link::turnOn() { - simgrid::simix::kernelImmediate([this]() { - this->pimpl_->turnOn(); - }); + simgrid::simix::kernelImmediate([this]() { this->pimpl_->turn_on(); }); } void Link::turnOff() { - simgrid::simix::kernelImmediate([this]() { - this->pimpl_->turnOff(); - }); + simgrid::simix::kernelImmediate([this]() { this->pimpl_->turn_off(); }); } void* Link::getData() @@ -157,13 +156,22 @@ void Link::setLatencyTrace(tmgr_trace_t trace) }); } +const char* Link::getProperty(const char* key) +{ + return this->pimpl_->getProperty(key); +} +void Link::setProperty(std::string key, std::string value) +{ + simgrid::simix::kernelImmediate([this, key, value] { this->pimpl_->setProperty(key, value); }); +} + /************* * Callbacks * *************/ simgrid::xbt::signal Link::onCreation; simgrid::xbt::signal Link::onDestruction; simgrid::xbt::signal Link::onStateChange; -simgrid::xbt::signal Link::onCommunicate; -simgrid::xbt::signal Link::onCommunicationStateChange; +simgrid::xbt::signal Link::onCommunicate; +simgrid::xbt::signal Link::onCommunicationStateChange; } }