Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Python: complex cluster example
[simgrid.git] / src / plugins / link_load.cpp
index 5d99aff..9373f60 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2021. 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. */
@@ -39,11 +39,19 @@ namespace simgrid {
 namespace plugin {
 
 class LinkLoad {
+  s4u::Link* link_{};      /*< The link onto which this data is attached*/
+  bool is_tracked_{false}; /*<Whether the link is tracked or not*/
+
+  double cumulated_bytes_{};      /*< Cumulated load since last reset*/
+  double min_bytes_per_second_{}; /*< Minimum instantaneous load observed since last reset*/
+  double max_bytes_per_second_{}; /*< Maximum instantaneous load observed since last reset*/
+  double last_reset_{};           /*< Timestamp of the last reset (init timestamp by default)*/
+  double last_updated_{};         /*< Timestamp of the last energy update event*/
+
 public:
-  static simgrid::xbt::Extension<simgrid::s4u::Link, LinkLoad> EXTENSION_ID;
+  static xbt::Extension<s4u::Link, LinkLoad> EXTENSION_ID;
 
-  explicit LinkLoad(simgrid::s4u::Link* ptr);
-  ~LinkLoad() = default;
+  explicit LinkLoad(s4u::Link* ptr);
 
   void track();
   void untrack();
@@ -52,32 +60,22 @@ public:
   double get_average_bytes();
 
   /// Getter methods.
-  bool is_tracked() const;
+  bool is_tracked() const { return is_tracked_; }
   double get_cumulated_bytes();
   double get_min_bytes_per_second();
   double get_max_bytes_per_second();
-
-private:
-  s4u::Link* link_{};      /*< The link onto which this data is attached*/
-  bool is_tracked_{false}; /*<Whether the link is tracked or not*/
-
-  double cumulated_bytes_{};      /*< Cumulated load since last reset*/
-  double min_bytes_per_second_{}; /*< Minimum instantaneous load observed since last reset*/
-  double max_bytes_per_second_{}; /*< Maximum instantaneous load observed since last reset*/
-  double last_reset_{};           /*< Timestamp of the last reset (init timestamp by default)*/
-  double last_updated_{};         /*< Timestamp of the last energy update event*/
 };
 
 xbt::Extension<s4u::Link, LinkLoad> LinkLoad::EXTENSION_ID;
 
-LinkLoad::LinkLoad(simgrid::s4u::Link* ptr) : link_(ptr), is_tracked_(false)
+LinkLoad::LinkLoad(s4u::Link* ptr) : link_(ptr), is_tracked_(false)
 {
   XBT_DEBUG("Instantiating a LinkLoad for link '%s'", link_->get_cname());
 }
 
 void LinkLoad::track()
 {
-  xbt_assert(!is_tracked_, "Trying to track load of link '%s' while it is already tracked, aborting.",
+  xbt_assert(not is_tracked_, "Trying to track load of link '%s' while it is already tracked, aborting.",
              link_->get_cname());
   XBT_DEBUG("Tracking load of link '%s'", link_->get_cname());
 
@@ -132,10 +130,6 @@ void LinkLoad::update()
   last_updated_ = now;
 }
 
-bool LinkLoad::is_tracked() const
-{
-  return is_tracked_;
-}
 double LinkLoad::get_cumulated_bytes()
 {
   update();
@@ -193,7 +187,7 @@ static void on_communicate(const simgrid::kernel::resource::NetworkAction& actio
 void sg_link_load_plugin_init()
 {
   xbt_assert(sg_host_count() == 0, "Please call sg_link_load_plugin_init() BEFORE initializing the platform.");
-  xbt_assert(!LinkLoad::EXTENSION_ID.valid(), "Double call to sg_link_load_plugin_init. Aborting.");
+  xbt_assert(not LinkLoad::EXTENSION_ID.valid(), "Double call to sg_link_load_plugin_init. Aborting.");
   LinkLoad::EXTENSION_ID = simgrid::s4u::Link::extension_create<LinkLoad>();
 
   // Attach new LinkLoad links created in the future.