Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Cut k/m/Resource.[ch] to its own files
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 10 Mar 2018 16:36:49 +0000 (17:36 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 10 Mar 2018 16:36:49 +0000 (17:36 +0100)
src/kernel/model/Resource.cpp [new file with mode: 0644]
src/kernel/model/Resource.hpp [new file with mode: 0644]
src/s4u/s4u_storage.cpp
src/surf/StorageImpl.hpp
src/surf/cpu_interface.hpp
src/surf/network_interface.hpp
src/surf/surf_interface.cpp
src/surf/surf_interface.hpp
src/surf/trace_mgr_test.cpp
tools/cmake/DefinePackages.cmake

diff --git a/src/kernel/model/Resource.cpp b/src/kernel/model/Resource.cpp
new file mode 100644 (file)
index 0000000..f7b290c
--- /dev/null
@@ -0,0 +1,72 @@
+/* Copyright (c) 2004-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. */
+
+#include "src/kernel/model/Resource.hpp"
+#include "src/kernel/lmm/maxmin.hpp" // Constraint
+#include "src/surf/surf_interface.hpp"
+
+namespace simgrid {
+namespace kernel {
+namespace model {
+
+Resource::Resource(surf::Model* model, const std::string& name, lmm::Constraint* constraint)
+    : name_(name), model_(model), constraint_(constraint)
+{
+}
+
+Resource::~Resource() = default;
+
+bool Resource::isOn() const
+{
+  return isOn_;
+}
+bool Resource::isOff() const
+{
+  return not isOn_;
+}
+
+void Resource::turnOn()
+{
+  isOn_ = true;
+}
+
+void Resource::turnOff()
+{
+  isOn_ = false;
+}
+
+double Resource::getLoad()
+{
+  return constraint_->get_usage();
+}
+
+surf::Model* Resource::model() const
+{
+  return model_;
+}
+
+const std::string& Resource::getName() const
+{
+  return name_;
+}
+
+const char* Resource::getCname() const
+{
+  return name_.c_str();
+}
+
+bool Resource::operator==(const Resource& other) const
+{
+  return name_ == other.name_;
+}
+
+kernel::lmm::Constraint* Resource::constraint() const
+{
+  return const_cast<kernel::lmm::Constraint*>(constraint_);
+}
+
+} // namespace model
+} // namespace kernel
+} // namespace simgrid
diff --git a/src/kernel/model/Resource.hpp b/src/kernel/model/Resource.hpp
new file mode 100644 (file)
index 0000000..153325e
--- /dev/null
@@ -0,0 +1,92 @@
+/* Copyright (c) 2004-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. */
+
+#ifndef SIMGRID_KERNEL_MODEL_RESOURCE_HPP
+#define SIMGRID_KERNEL_MODEL_RESOURCE_HPP
+
+#include "src/surf/surf_interface.hpp"
+
+namespace simgrid {
+namespace kernel {
+namespace model {
+
+/** @ingroup SURF_interface
+ * @brief SURF resource interface class
+ * @details This is the ancestor class of every resources in SimGrid, such as links, CPU or storage
+ */
+XBT_PUBLIC_CLASS Resource
+{
+public:
+  /**
+   * @brief Constructor of LMM Resources
+   *
+   * @param model Model associated to this Resource
+   * @param name The name of the Resource
+   * @param constraint The lmm constraint associated to this Resource if it is part of a LMM component
+   */
+  Resource(surf::Model * model, const std::string& name, lmm::Constraint* constraint);
+
+  virtual ~Resource();
+
+  /** @brief Get the Model of the current Resource */
+  surf::Model* model() const;
+
+  /** @brief Get the name of the current Resource */
+  const std::string& getName() const;
+  /** @brief Get the name of the current Resource */
+  const char* getCname() const;
+
+  bool operator==(const Resource& other) const;
+
+  /**
+   * @brief Apply an event of external load event to that resource
+   *
+   * @param event What happened
+   * @param value [TODO]
+   */
+  virtual void apply_event(tmgr_trace_event_t event, double value) = 0;
+
+  /** @brief Check if the current Resource is used (if it currently serves an action) */
+  virtual bool isUsed() = 0;
+
+  /** @brief returns the current load (in flops per second, byte per second or similar) */
+  virtual double getLoad();
+
+  /** @brief Check if the current Resource is active */
+  virtual bool isOn() const;
+  /** @brief Check if the current Resource is shut down */
+  virtual bool isOff() const;
+  /** @brief Turn on the current Resource */
+  virtual void turnOn();
+  /** @brief Turn off the current Resource */
+  virtual void turnOff();
+
+private:
+  std::string name_;
+  surf::Model* model_;
+  bool isOn_ = true;
+
+public: /* LMM */
+  /** @brief Get the lmm constraint associated to this Resource if it is part of a LMM component (or null if none) */
+  kernel::lmm::Constraint* constraint() const;
+
+protected:
+  const kernel::lmm::Constraint* constraint_ = nullptr;
+};
+} // namespace model
+} // namespace kernel
+} // namespace simgrid
+
+namespace std {
+template <> class hash<simgrid::kernel::model::Resource> {
+public:
+  std::size_t operator()(const simgrid::kernel::model::Resource& r) const
+  {
+    return (std::size_t)xbt_str_hash(r.getCname());
+  }
+};
+} // namespace std
+
+#endif
index e1aabf1..983b597 100644 (file)
@@ -7,6 +7,7 @@
 #include "simgrid/s4u/Host.hpp"
 #include "simgrid/s4u/Storage.hpp"
 #include "simgrid/simix.hpp"
+#include "src/kernel/model/Resource.hpp"
 #include "src/plugins/file_system/FileSystem.hpp"
 #include "src/surf/StorageImpl.hpp"
 #include <unordered_map>
index 20ccd55..e290906 100644 (file)
@@ -8,6 +8,7 @@
 #include <xbt/signal.hpp>
 
 #include "simgrid/s4u/Storage.hpp"
+#include "src/kernel/model/Resource.hpp"
 #include "src/surf/PropertyHolder.hpp"
 #include "surf_interface.hpp"
 #include <map>
index 9a8bdde..1eb54c3 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "simgrid/s4u/Host.hpp"
 #include "src/kernel/lmm/maxmin.hpp"
+#include "src/kernel/model/Resource.hpp"
 
 #include <list>
 
index 082dc35..aedbde8 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "simgrid/s4u/Link.hpp"
 #include "src/kernel/lmm/maxmin.hpp"
+#include "src/kernel/model/Resource.hpp"
 #include "src/surf/PropertyHolder.hpp"
 #include "src/surf/surf_interface.hpp"
 #include "xbt/base.h"
index d887e1f..78638e2 100644 (file)
@@ -515,66 +515,6 @@ void Model::updateActionsStateFull(double /*now*/, double /*delta*/)
  * Resource *
  ************/
 
-namespace simgrid {
-namespace kernel {
-namespace model {
-
-Resource::Resource(surf::Model* model, const std::string& name, lmm::Constraint* constraint)
-    : name_(name), model_(model), constraint_(constraint)
-{}
-
-Resource::~Resource() = default;
-
-bool Resource::isOn() const {
-  return isOn_;
-}
-bool Resource::isOff() const {
-  return not isOn_;
-}
-
-void Resource::turnOn()
-{
-  isOn_ = true;
-}
-
-void Resource::turnOff()
-{
-  isOn_ = false;
-}
-
-double Resource::getLoad()
-{
-  return constraint_->get_usage();
-}
-
-surf::Model* Resource::model() const
-{
-  return model_;
-}
-
-const std::string& Resource::getName() const
-{
-  return name_;
-}
-
-const char* Resource::getCname() const
-{
-  return name_.c_str();
-}
-
-bool Resource::operator==(const Resource &other) const {
-  return name_ == other.name_;
-}
-
-kernel::lmm::Constraint* Resource::constraint() const
-{
-  return const_cast<kernel::lmm::Constraint*>(constraint_);
-}
-
-}
-} // namespace kernel
-}
-
 /**********
  * Action *
  **********/
index 9c0859b..adfddab 100644 (file)
@@ -382,84 +382,5 @@ struct s_surf_metric_t {
   tmgr_trace_event_t event; /**< The associated trace event associated to the metric */
 };
 
-namespace simgrid {
-namespace kernel {
-namespace model {
-
-/** @ingroup SURF_interface
- * @brief SURF resource interface class
- * @details This is the ancestor class of every resources in SimGrid, such as links, CPU or storage
- */
-XBT_PUBLIC_CLASS Resource {
-public:
-  /**
-   * @brief Constructor of LMM Resources
-   *
-   * @param model Model associated to this Resource
-   * @param name The name of the Resource
-   * @param constraint The lmm constraint associated to this Resource if it is part of a LMM component
-   */
-  Resource(surf::Model * model, const std::string& name, lmm::Constraint* constraint);
-
-  virtual ~Resource();
-
-  /** @brief Get the Model of the current Resource */
-  surf::Model* model() const;
-
-  /** @brief Get the name of the current Resource */
-  const std::string& getName() const;
-  /** @brief Get the name of the current Resource */
-  const char* getCname() const;
-
-  bool operator==(const Resource &other) const;
-
-  /**
-   * @brief Apply an event of external load event to that resource
-   *
-   * @param event What happened
-   * @param value [TODO]
-   */
-  virtual void apply_event(tmgr_trace_event_t event, double value) = 0;
-
-  /** @brief Check if the current Resource is used (if it currently serves an action) */
-  virtual bool isUsed()=0;
-
-  /** @brief returns the current load (in flops per second, byte per second or similar) */
-  virtual double getLoad();
-
-  /** @brief Check if the current Resource is active */
-  virtual bool isOn() const;
-  /** @brief Check if the current Resource is shut down */
-  virtual bool isOff() const;
-  /** @brief Turn on the current Resource */
-  virtual void turnOn();
-  /** @brief Turn off the current Resource */
-  virtual void turnOff();
-
-private:
-  std::string name_;
-  surf::Model* model_;
-  bool isOn_ = true;
-
-public: /* LMM */
-  /** @brief Get the lmm constraint associated to this Resource if it is part of a LMM component (or null if none) */
-  kernel::lmm::Constraint* constraint() const;
-
-protected:
-  const kernel::lmm::Constraint* constraint_ = nullptr;
-};
-} // namespace model
-}
-}
-
-namespace std {
-template <> class hash<simgrid::kernel::model::Resource> {
-public:
-  std::size_t operator()(const simgrid::kernel::model::Resource& r) const
-  {
-    return (std::size_t)xbt_str_hash(r.getCname());
-  }
-};
-}
 
 #endif /* SURF_MODEL_H_ */
index a63420b..d8bc1c9 100644 (file)
@@ -9,6 +9,7 @@ bool init_unit_test(); // boost forget to give this prototype on NetBSD, which d
 #define BOOST_TEST_NO_MAIN
 #include <boost/test/unit_test.hpp>
 
+#include "src/kernel/model/Resource.hpp"
 #include "src/surf/surf_interface.hpp"
 #include "src/surf/trace_mgr.hpp"
 
index ba15c8c..b77c0a1 100644 (file)
@@ -303,6 +303,9 @@ set(SURF_SRC
   src/kernel/lmm/maxmin.hpp
   src/kernel/lmm/maxmin.cpp
   
+  src/kernel/model/Resource.hpp
+  src/kernel/model/Resource.cpp
+  
   src/kernel/routing/ClusterZone.cpp
   src/kernel/routing/ClusterZone.hpp
   src/kernel/routing/DijkstraZone.cpp