]> AND Public Git Repository - simgrid.git/blobdiff - src/mc/VisitedState.cpp
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Rename variables to avoid shadowed declarations.
[simgrid.git] / src / mc / VisitedState.cpp
index 436ab817126a0a2954cbbacf66b84740551c89d9..6e46c3c3d0b71bff3a3cb57fa4329f9b968ff568 100644 (file)
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_VisitedState, mc, "Logging specific to state equality detection mechanisms");
 
-using api = simgrid::mc::Api;
-
-namespace simgrid {
-namespace mc {
+namespace simgrid::mc {
 
 /** @brief Save the current state */
 VisitedState::VisitedState(unsigned long state_number) : num(state_number)
 {
-  this->heap_bytes_used = api::get().get_remote_heap_bytes();
-  this->actors_count = api::get().get_actors_size();
+  this->heap_bytes_used = Api::get().get_remote_heap_bytes();
+  this->actors_count    = Api::get().get_actors().size();
   this->system_state = std::make_shared<simgrid::mc::Snapshot>(state_number);
 }
 
@@ -46,17 +43,16 @@ std::unique_ptr<simgrid::mc::VisitedState>
 VisitedStates::addVisitedState(unsigned long state_number, simgrid::mc::State* graph_state, bool compare_snapshots)
 {
   auto new_state             = std::make_unique<simgrid::mc::VisitedState>(state_number);
-  graph_state->system_state_ = new_state->system_state;
+  graph_state->set_system_state(new_state->system_state);
   XBT_DEBUG("Snapshot %p of visited state %ld (exploration stack state %ld)", new_state->system_state.get(),
-            new_state->num, graph_state->num_);
+            new_state->num, graph_state->get_num());
 
-  auto range =
-      boost::range::equal_range(states_, new_state.get(), api::get().compare_pair());
+  auto [range_begin, range_end] = boost::range::equal_range(states_, new_state.get(), Api::get().compare_pair());
 
   if (compare_snapshots)
-    for (auto i = range.first; i != range.second; ++i) {
+    for (auto i = range_begin; i != range_end; ++i) {
       auto& visited_state = *i;
-      if (api::get().snapshot_equal(visited_state->system_state.get(), new_state->system_state.get())) {
+      if (Api::get().snapshot_equal(visited_state->system_state.get(), new_state->system_state.get())) {
         // The state has been visited:
 
         std::unique_ptr<simgrid::mc::VisitedState> old_state =
@@ -84,10 +80,9 @@ VisitedStates::addVisitedState(unsigned long state_number, simgrid::mc::State* g
     }
 
   XBT_DEBUG("Insert new visited state %ld (total : %lu)", new_state->num, (unsigned long)states_.size());
-  states_.insert(range.first, std::move(new_state));
+  states_.insert(range_begin, std::move(new_state));
   this->prune();
   return nullptr;
 }
 
-}
-}
+} // namespace simgrid::mc