Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' into 'python_bindings_host_load_plugin'
[simgrid.git] / src / mc / transition / TransitionAny.hpp
index 25f67dd..494006b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2022. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2023. 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. */
@@ -8,12 +8,12 @@
 
 #include "src/kernel/actor/SimcallObserver.hpp"
 #include "src/mc/transition/Transition.hpp"
+#include "src/mc/transition/TransitionComm.hpp"
 
 #include <sstream>
 #include <string>
 
-namespace simgrid {
-namespace mc {
+namespace simgrid::mc {
 
 class TestAnyTransition : public Transition {
   std::vector<Transition*> transitions_;
@@ -24,6 +24,13 @@ public:
   bool depends(const Transition* other) const override;
 
   Transition* get_current_transition() const { return transitions_.at(times_considered_); }
+  bool result() const
+  {
+    return std::any_of(begin(transitions_), end(transitions_), [](const Transition* transition) {
+      const auto* tested_transition = static_cast<const CommTestTransition*>(transition);
+      return (tested_transition->get_sender() != -1 && tested_transition->get_receiver() != -1);
+    });
+  }
 };
 
 class WaitAnyTransition : public Transition {
@@ -37,7 +44,6 @@ public:
   Transition* get_current_transition() const { return transitions_.at(times_considered_); }
 };
 
-} // namespace mc
-} // namespace simgrid
+} // namespace simgrid::mc
 
 #endif