Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
further snake_case in routing
[simgrid.git] / src / s4u / s4u_link.cpp
index 60ef3fb..d9a5089 100644 (file)
@@ -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 <algorithm>
 
 #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,11 +18,9 @@ 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->name();
+  return link->get_cname();
 }
 sg_link_t sg_link_by_name(const char* name)
 {
@@ -67,7 +66,6 @@ void sg_link_exit()
 {
   simgrid::surf::LinkImpl::linksExit();
 }
-}
 
 /***********
  * C++ API *
@@ -82,13 +80,21 @@ Link* Link::byName(const char* name)
     return nullptr;
   return &res->piface_;
 }
+const std::string& Link::get_name() const
+{
+  return this->pimpl_->get_name();
+}
+const char* Link::get_cname() const
+{
+  return this->pimpl_->get_cname();
+}
 const char* Link::name()
 {
-  return this->pimpl_->getCname();
+  return get_cname();
 }
 bool Link::isUsed()
 {
-  return this->pimpl_->isUsed();
+  return this->pimpl_->is_used();
 }
 
 double Link::latency()
@@ -106,17 +112,18 @@ int 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()
@@ -149,6 +156,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 *
  *************/