Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
align file position to the C++ namespaces
[simgrid.git] / src / kernel / resource / Resource.cpp
index dc46230..b975e92 100644 (file)
@@ -1,10 +1,11 @@
-/* Copyright (c) 2004-2018. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2019. 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/resource/Resource.hpp"
+#include "simgrid/kernel/resource/Resource.hpp"
 #include "src/kernel/lmm/maxmin.hpp" // Constraint
+#include "src/kernel/resource/profile/trace_mgr.hpp"
 #include "src/surf/surf_interface.hpp"
 
 namespace simgrid {
@@ -18,41 +19,41 @@ Resource::Resource(Model* model, const std::string& name, lmm::Constraint* const
 
 Resource::~Resource() = default;
 
-bool Resource::isOn() const
+bool Resource::is_on() const
 {
-  return isOn_;
+  return is_on_;
 }
-bool Resource::isOff() const
+bool Resource::is_off() const
 {
-  return not isOn_;
+  return not is_on_;
 }
 
-void Resource::turnOn()
+void Resource::turn_on()
 {
-  isOn_ = true;
+  is_on_ = true;
 }
 
-void Resource::turnOff()
+void Resource::turn_off()
 {
-  isOn_ = false;
+  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_;
 }
 
-const std::string& Resource::getName() const
+const std::string& Resource::get_name() const
 {
   return name_;
 }
 
-const char* Resource::getCname() const
+const char* Resource::get_cname() const
 {
   return name_.c_str();
 }
@@ -62,9 +63,16 @@ bool Resource::operator==(const Resource& other) const
   return name_ == other.name_;
 }
 
-kernel::lmm::Constraint* Resource::constraint() const
+void Resource::set_state_profile(profile::Profile* profile)
 {
-  return const_cast<kernel::lmm::Constraint*>(constraint_);
+  xbt_assert(state_event_ == nullptr, "Cannot set a second state profile to %s", get_cname());
+
+  state_event_ = future_evt_set.add_trace(profile, this);
+}
+
+kernel::lmm::Constraint* Resource::get_constraint() const
+{
+  return constraint_;
 }
 
 } // namespace resource