Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use XBT_DECLARE_ENUM_CLASS for kernel::activity::State.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 5 Feb 2021 14:29:03 +0000 (15:29 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 5 Feb 2021 14:48:42 +0000 (15:48 +0100)
src/kernel/activity/ActivityImpl.cpp
src/kernel/activity/ActivityImpl.hpp

index e5f061e..6cb8ac9 100644 (file)
@@ -43,10 +43,7 @@ double ActivityImpl::get_remaining() const
 
 const char* ActivityImpl::get_state_str() const
 {
-  constexpr std::array<const char*, 12> names{{"WAITING", "READY", "RUNNING", "DONE", "CANCELED", "FAILED",
-                                               "SRC_HOST_FAILURE", "DST_HOST_FAILURE", "TIMEOUT", "SRC_TIMEOUT",
-                                               "DST_TIMEOUT", "LINK_FAILURE"}};
-  return names[static_cast<int>(state_)];
+  return to_c_str(state_);
 }
 
 bool ActivityImpl::test()
index 7bc0215..4ba5273 100644 (file)
@@ -9,8 +9,8 @@
 #include <string>
 #include <list>
 
-#include <xbt/base.h>
 #include "simgrid/forward.h"
+#include <xbt/utility.hpp>
 
 #include <atomic>
 #include <simgrid/kernel/resource/Action.hpp>
 namespace simgrid {
 namespace kernel {
 namespace activity {
-enum class State {
-  WAITING = 0,
-  READY,
-  RUNNING,
-  DONE,
-  CANCELED,
-  FAILED,
-  SRC_HOST_FAILURE,
-  DST_HOST_FAILURE,
-  TIMEOUT,
-  SRC_TIMEOUT,
-  DST_TIMEOUT,
-  LINK_FAILURE
-};
+
+XBT_DECLARE_ENUM_CLASS(State, WAITING, READY, RUNNING, DONE, CANCELED, FAILED, SRC_HOST_FAILURE, DST_HOST_FAILURE,
+                       TIMEOUT, SRC_TIMEOUT, DST_TIMEOUT, LINK_FAILURE);
 
 class XBT_PUBLIC ActivityImpl {
   std::atomic_int_fast32_t refcount_{0};