Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
python: First working example
[simgrid.git] / src / kernel / resource / Resource.cpp
index 6b9ffe1..816ae08 100644 (file)
@@ -6,6 +6,7 @@
 #include "simgrid/kernel/resource/Resource.hpp"
 #include "src/kernel/lmm/maxmin.hpp" // Constraint
 #include "src/surf/surf_interface.hpp"
+#include "src/surf/trace_mgr.hpp"
 
 namespace simgrid {
 namespace kernel {
@@ -18,31 +19,31 @@ Resource::Resource(Model* model, const std::string& name, lmm::Constraint* const
 
 Resource::~Resource() = default;
 
-bool Resource::isOn() const
+bool Resource::is_on() const
 {
   return is_on_;
 }
-bool Resource::isOff() const
+bool Resource::is_off() const
 {
   return not is_on_;
 }
 
-void Resource::turnOn()
+void Resource::turn_on()
 {
   is_on_ = true;
 }
 
-void Resource::turnOff()
+void Resource::turn_off()
 {
   is_on_ = false;
 }
 
-double Resource::getLoad()
+double Resource::get_load()
 {
   return constraint_->get_usage();
 }
 
-Model* Resource::model() const
+Model* Resource::get_model() const
 {
   return model_;
 }
@@ -62,7 +63,14 @@ bool Resource::operator==(const Resource& other) const
   return name_ == other.name_;
 }
 
-kernel::lmm::Constraint* Resource::constraint() const
+void Resource::set_state_trace(tmgr_trace_t trace)
+{
+  xbt_assert(state_event_ == nullptr, "Cannot set a second state trace to %s", get_cname());
+
+  state_event_ = future_evt_set.add_trace(trace, this);
+}
+
+kernel::lmm::Constraint* Resource::get_constraint() const
 {
   return constraint_;
 }