Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use const& for std::string parameter (sonar, again).
[simgrid.git] / src / surf / cpu_cas01.cpp
index 8570cff..ed072e0 100644 (file)
@@ -44,9 +44,8 @@ void surf_cpu_model_init_Cas01()
     return;
   }
 
-  auto cpu_model_pm = std::make_shared<simgrid::kernel::resource::CpuCas01Model>();
-  simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::CPU_PM, cpu_model_pm,
-                                                         true);
+  auto cpu_model_pm = std::make_shared<simgrid::kernel::resource::CpuCas01Model>("Cpu_Cas01");
+  simgrid::kernel::EngineImpl::get_instance()->add_model(cpu_model_pm);
   simgrid::s4u::Engine::get_instance()->get_netzone_root()->get_impl()->set_cpu_pm_model(cpu_model_pm);
 }
 
@@ -54,7 +53,7 @@ namespace simgrid {
 namespace kernel {
 namespace resource {
 
-CpuCas01Model::CpuCas01Model()
+CpuCas01Model::CpuCas01Model(const std::string& name) : CpuModel(name)
 {
   if (config::get_value<std::string>("cpu/optim") == "Lazy")
     set_update_algorithm(Model::UpdateAlgo::LAZY);
@@ -86,13 +85,12 @@ bool CpuCas01::is_used() const
 /** @brief take into account changes of speed (either load or max) */
 void CpuCas01::on_speed_change()
 {
-  const lmm::Variable* var;
   const lmm::Element* elem = nullptr;
 
   get_model()->get_maxmin_system()->update_constraint_bound(get_constraint(),
                                                             get_core_count() * speed_.scale * speed_.peak);
-  while ((var = get_constraint()->get_variable(&elem))) {
-    const CpuCas01Action* action = static_cast<CpuCas01Action*>(var->get_id());
+  while (const auto* var = get_constraint()->get_variable(&elem)) {
+    const auto* action = static_cast<CpuCas01Action*>(var->get_id());
 
     get_model()->get_maxmin_system()->update_variable_bound(action->get_variable(),
                                                             action->requested_core() * speed_.scale * speed_.peak);
@@ -121,14 +119,12 @@ void CpuCas01::apply_event(profile::Event* event, double value)
         get_iface()->turn_on();
       }
     } else {
-      const lmm::Constraint* cnst = get_constraint();
-      const lmm::Variable* var;
       const lmm::Element* elem = nullptr;
       double date              = surf_get_clock();
 
       get_iface()->turn_off();
 
-      while ((var = cnst->get_variable(&elem))) {
+      while (const auto* var = get_constraint()->get_variable(&elem)) {
         Action* action = var->get_id();
 
         if (action->get_state() == Action::State::INITED || action->get_state() == Action::State::STARTED ||