Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
CpuTiTmgr: change a C enum into an enum class
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 7 Jul 2018 22:46:51 +0000 (00:46 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 7 Jul 2018 22:46:51 +0000 (00:46 +0200)
src/surf/cpu_ti.cpp
src/surf/cpu_ti.hpp

index 08960f0..bbc2ffa 100644 (file)
@@ -70,7 +70,7 @@ double CpuTiTmgr::integrate(double a, double b)
   if (fabs(a -b) < EPSILON)
     return 0.0;
 
   if (fabs(a -b) < EPSILON)
     return 0.0;
 
-  if (type_ == TRACE_FIXED) {
+  if (type_ == Type::FIXED) {
     return ((b - a) * value_);
   }
 
     return ((b - a) * value_);
   }
 
@@ -158,7 +158,7 @@ double CpuTiTmgr::solve(double a, double amount)
     return a;
 
   /* Is the trace fixed ? */
     return a;
 
   /* Is the trace fixed ? */
-  if (type_ == TRACE_FIXED) {
+  if (type_ == Type::FIXED) {
     return (a + (amount / value_));
   }
 
     return (a + (amount / value_));
   }
 
@@ -232,7 +232,7 @@ CpuTiTmgr::CpuTiTmgr(tmgr_trace_t speed_trace, double value) : speed_trace_(spee
 
   /* no availability file, fixed trace */
   if (not speed_trace) {
 
   /* no availability file, fixed trace */
   if (not speed_trace) {
-    type_ = TRACE_FIXED;
+    type_  = Type::FIXED;
     value_ = value;
     XBT_DEBUG("No availability trace. Constant value = %f", value);
     return;
     value_ = value;
     XBT_DEBUG("No availability trace. Constant value = %f", value);
     return;
@@ -240,12 +240,12 @@ CpuTiTmgr::CpuTiTmgr(tmgr_trace_t speed_trace, double value) : speed_trace_(spee
 
   /* only one point available, fixed trace */
   if (speed_trace->event_list.size() == 1) {
 
   /* only one point available, fixed trace */
   if (speed_trace->event_list.size() == 1) {
-    type_  = TRACE_FIXED;
+    type_  = Type::FIXED;
     value_ = speed_trace->event_list.front().value_;
     return;
   }
 
     value_ = speed_trace->event_list.front().value_;
     return;
   }
 
-  type_ = TRACE_DYNAMIC;
+  type_ = Type::DYNAMIC;
 
   /* count the total time of trace file */
   for (auto const& val : speed_trace->event_list)
 
   /* count the total time of trace file */
   for (auto const& val : speed_trace->event_list)
@@ -395,7 +395,7 @@ void CpuTi::apply_event(tmgr_trace_event_t event, double value)
     delete speed_integrated_trace_;
     speed_.scale = val.value_;
 
     delete speed_integrated_trace_;
     speed_.scale = val.value_;
 
-    CpuTiTmgr* trace = new CpuTiTmgr(TRACE_FIXED, val.value_);
+    CpuTiTmgr* trace = new CpuTiTmgr(CpuTiTmgr::Type::FIXED, val.value_);
     XBT_DEBUG("value %f", val.value_);
 
     speed_integrated_trace_ = trace;
     XBT_DEBUG("value %f", val.value_);
 
     speed_integrated_trace_ = trace;
index 9c6f0a8..df03111 100644 (file)
@@ -6,13 +6,11 @@
 #ifndef SURF_MODEL_CPUTI_H_
 #define SURF_MODEL_CPUTI_H_
 
 #ifndef SURF_MODEL_CPUTI_H_
 #define SURF_MODEL_CPUTI_H_
 
-#include <boost/intrusive/list.hpp>
-
-//#include <xbt/base.h>
-
 #include "src/surf/cpu_interface.hpp"
 #include "src/surf/trace_mgr.hpp"
 
 #include "src/surf/cpu_interface.hpp"
 #include "src/surf/trace_mgr.hpp"
 
+#include <boost/intrusive/list.hpp>
+
 namespace simgrid {
 namespace surf {
 
 namespace simgrid {
 namespace surf {
 
@@ -42,15 +40,13 @@ public:
   int binary_search(double* array, double a, int low, int high);
 };
 
   int binary_search(double* array, double a, int low, int high);
 };
 
-enum trace_type {
-
-  TRACE_FIXED,                /*< Trace fixed, no availability file */
-  TRACE_DYNAMIC               /*< Dynamic, have an availability file */
-};
-
 class CpuTiTmgr {
 public:
 class CpuTiTmgr {
 public:
-  CpuTiTmgr(trace_type type, double value) : type_(type), value_(value){};
+  enum class Type {
+    FIXED,  /*< Trace fixed, no availability file */
+    DYNAMIC /*< Dynamic, have an availability file */
+  };
+  CpuTiTmgr(Type type, double value) : type_(type), value_(value){};
   CpuTiTmgr(tmgr_trace_t speed_trace, double value);
   CpuTiTmgr(const CpuTiTmgr&) = delete;
   CpuTiTmgr& operator=(const CpuTiTmgr&) = delete;
   CpuTiTmgr(tmgr_trace_t speed_trace, double value);
   CpuTiTmgr(const CpuTiTmgr&) = delete;
   CpuTiTmgr& operator=(const CpuTiTmgr&) = delete;
@@ -60,7 +56,7 @@ public:
   double solve(double a, double amount);
   double get_power_scale(double a);
 
   double solve(double a, double amount);
   double get_power_scale(double a);
 
-  trace_type type_;
+  Type type_;
   double value_;                 /*< Percentage of cpu speed available. Value fixed between 0 and 1 */
 
   /* Dynamic */
   double value_;                 /*< Percentage of cpu speed available. Value fixed between 0 and 1 */
 
   /* Dynamic */