Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
implement some more getters in surf::Link and s4u::Link
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 21 Nov 2017 15:15:22 +0000 (16:15 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 21 Nov 2017 15:15:22 +0000 (16:15 +0100)
include/simgrid/s4u/Link.hpp
src/s4u/s4u_link.cpp
src/surf/network_interface.cpp
src/surf/network_interface.hpp

index 2255bc1..f554dfe 100644 (file)
@@ -7,11 +7,11 @@
 #define S4U_LINK_HPP_
 
 #include <simgrid/link.h>
 #define S4U_LINK_HPP_
 
 #include <simgrid/link.h>
-#include <xbt/base.h>
-#include <xbt/signal.hpp>
-
 #include <string>
 #include <unordered_map>
 #include <string>
 #include <unordered_map>
+#include <xbt/Extendable.hpp>
+#include <xbt/base.h>
+#include <xbt/signal.hpp>
 
 /***********
  * Classes *
 
 /***********
  * Classes *
@@ -23,7 +23,7 @@ class NetworkAction;
 };
 namespace s4u {
 /** @brief A Link represents the network facilities between [hosts](\ref simgrid::s4u::Host) */
 };
 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<Link>
 {
   friend simgrid::surf::LinkImpl;
 
 {
   friend simgrid::surf::LinkImpl;
 
@@ -52,6 +52,9 @@ public:
    */
   int sharingPolicy();
 
    */
   int sharingPolicy();
 
+  /** @brief Returns the current load (in flops per second) */
+  double getUsage();
+
   /** @brief Check if the Link is used */
   bool isUsed();
 
   /** @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 */
 
   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<void(s4u::Link&)> onCreation;
   /* The signals */
   /** @brief Callback signal fired when a new Link is created */
   static simgrid::xbt::signal<void(s4u::Link&)> onCreation;
index c640077..7a38166 100644 (file)
@@ -114,6 +114,11 @@ int Link::sharingPolicy()
   return this->pimpl_->sharingPolicy();
 }
 
   return this->pimpl_->sharingPolicy();
 }
 
+double Link::getUsage()
+{
+  return lmm_constraint_get_usage(this->pimpl_->constraint());
+}
+
 void Link::turnOn()
 {
   simgrid::simix::kernelImmediate([this]() {
 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 *
  *************/
 /*************
  * Callbacks *
  *************/
index a7803a9..6521cfd 100644 (file)
@@ -30,6 +30,13 @@ namespace simgrid {
   {
     return links->size();
   }
   {
     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()
   {
   /** @brief Returns a list of all existing links */
   LinkImpl** LinkImpl::linksList()
   {
index 14a1518..476775c 100644 (file)
@@ -174,6 +174,7 @@ public:
   static LinkImpl* byName(std::string name);
   static int linksCount();
   static LinkImpl** linksList();
   static LinkImpl* byName(std::string name);
   static int linksCount();
   static LinkImpl** linksList();
+  static void linksList(std::vector<s4u::Link*>* linkList);
   static void linksExit();
 };
 
   static void linksExit();
 };