From: Martin Quinson Date: Tue, 21 Nov 2017 15:15:22 +0000 (+0100) Subject: implement some more getters in surf::Link and s4u::Link X-Git-Tag: v3.18~276 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/ed06a04349269c97969b549f83f73d718246cc13 implement some more getters in surf::Link and s4u::Link --- diff --git a/include/simgrid/s4u/Link.hpp b/include/simgrid/s4u/Link.hpp index 2255bc1d59..f554dfec8c 100644 --- a/include/simgrid/s4u/Link.hpp +++ b/include/simgrid/s4u/Link.hpp @@ -7,11 +7,11 @@ #define S4U_LINK_HPP_ #include -#include -#include - #include #include +#include +#include +#include /*********** * Classes * @@ -23,7 +23,7 @@ class NetworkAction; }; namespace s4u { /** @brief A Link represents the network facilities between [hosts](\ref simgrid::s4u::Host) */ -XBT_PUBLIC_CLASS Link +XBT_PUBLIC_CLASS Link : public simgrid::xbt::Extendable { friend simgrid::surf::LinkImpl; @@ -52,6 +52,9 @@ public: */ int sharingPolicy(); + /** @brief Returns the current load (in flops per second) */ + double getUsage(); + /** @brief Check if the Link is used */ bool isUsed(); @@ -68,6 +71,9 @@ public: void setLatencyTrace(tmgr_trace_t trace); /*< setup the trace file with latency events (peak latency changes due to external load). Trace must contain absolute values */ + const char* getProperty(const char* key); + void setProperty(std::string key, std::string value); + /* The signals */ /** @brief Callback signal fired when a new Link is created */ static simgrid::xbt::signal onCreation; diff --git a/src/s4u/s4u_link.cpp b/src/s4u/s4u_link.cpp index c640077613..7a38166c10 100644 --- a/src/s4u/s4u_link.cpp +++ b/src/s4u/s4u_link.cpp @@ -114,6 +114,11 @@ int Link::sharingPolicy() return this->pimpl_->sharingPolicy(); } +double Link::getUsage() +{ + return lmm_constraint_get_usage(this->pimpl_->constraint()); +} + void Link::turnOn() { simgrid::simix::kernelImmediate([this]() { @@ -157,6 +162,15 @@ 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 * *************/ diff --git a/src/surf/network_interface.cpp b/src/surf/network_interface.cpp index a7803a93fe..6521cfd300 100644 --- a/src/surf/network_interface.cpp +++ b/src/surf/network_interface.cpp @@ -30,6 +30,13 @@ namespace simgrid { { 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() { diff --git a/src/surf/network_interface.hpp b/src/surf/network_interface.hpp index 14a1518462..476775c0d7 100644 --- a/src/surf/network_interface.hpp +++ b/src/surf/network_interface.hpp @@ -174,6 +174,7 @@ public: static LinkImpl* byName(std::string name); static int linksCount(); static LinkImpl** linksList(); + static void linksList(std::vector* linkList); static void linksExit(); };