Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
More defensive programing style
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Fri, 14 Apr 2023 12:21:47 +0000 (14:21 +0200)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Fri, 14 Apr 2023 12:21:47 +0000 (14:21 +0200)
src/mc/api/State.cpp

index bccd340..38b0a35 100644 (file)
@@ -22,8 +22,10 @@ State::State(RemoteApp& remote_app) : num_(++expended_states_)
   XBT_VERB("Creating a guide for the state");
   if (_sg_mc_strategy == "none")
     strategy_ = std::make_shared<BasicStrategy>();
-  if (_sg_mc_strategy == "nb_wait")
+  else if (_sg_mc_strategy == "nb_wait")
     strategy_ = std::make_shared<WaitStrategy>();
+  else
+    THROW_IMPOSSIBLE;
 
   recipe_ = std::list<Transition*>();
 
@@ -42,8 +44,10 @@ State::State(RemoteApp& remote_app, std::shared_ptr<State> parent_state)
 {
   if (_sg_mc_strategy == "none")
     strategy_ = std::make_shared<BasicStrategy>();
-  if (_sg_mc_strategy == "nb_wait")
+  else if (_sg_mc_strategy == "nb_wait")
     strategy_ = std::make_shared<WaitStrategy>();
+  else
+    THROW_IMPOSSIBLE;
   *strategy_ = *(parent_state->strategy_);
 
   recipe_ = std::list(parent_state_->get_recipe());