Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Factorize initializations for Action constructors.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Fri, 4 Apr 2014 09:27:38 +0000 (11:27 +0200)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Fri, 4 Apr 2014 11:06:03 +0000 (13:06 +0200)
Also initialize m_hat to NOTSET.

src/surf/surf_interface.cpp
src/surf/surf_interface.hpp

index 93506d6..7c325f9 100644 (file)
@@ -759,26 +759,34 @@ const char *surf_action_state_names[6] = {
   "SURF_ACTION_NOT_IN_THE_SYSTEM"
 };
 
   "SURF_ACTION_NOT_IN_THE_SYSTEM"
 };
 
+void Action::initialize(ModelPtr model, double cost, bool failed,
+                        lmm_variable_t var)
+{
+  m_priority = 1.0;
+  m_refcount = 1;
+  m_remains = cost;
+  m_maxDuration = NO_MAX_DURATION;
+  m_finish = -1.0;
+  m_failed = failed;
+  m_start = surf_get_clock();
+  m_cost = cost;
+  p_model = model;
+  p_data = NULL;
+  p_variable = var;
+  m_lastValue = 0;
+  m_lastUpdate = 0;
+  m_suspended = false;
+  m_hat = NOTSET;
+}
+
 Action::Action()
 Action::Action()
-: m_refcount(1)
-{}
+{
+  initialize(NULL, 0.0, false); // FIXME: not used
+}
 
 Action::Action(ModelPtr model, double cost, bool failed)
 
 Action::Action(ModelPtr model, double cost, bool failed)
- : m_priority(1.0)
- , m_refcount(1)
- , m_remains(cost)
- , m_maxDuration(NO_MAX_DURATION)
- , m_finish(-1.0)
- , m_failed(failed)
- , m_start(surf_get_clock())
- , m_cost(cost)
- , p_model(model)
- , p_data(NULL)
- , p_variable(NULL)
- , m_lastValue(0)
- , m_lastUpdate(0)
- , m_suspended(false)
 {
 {
+  initialize(model, cost, failed);
   #ifdef HAVE_TRACING
     p_category = NULL;
   #endif
   #ifdef HAVE_TRACING
     p_category = NULL;
   #endif
@@ -793,21 +801,8 @@ Action::Action(ModelPtr model, double cost, bool failed)
 }
 
 Action::Action(ModelPtr model, double cost, bool failed, lmm_variable_t var)
 }
 
 Action::Action(ModelPtr model, double cost, bool failed, lmm_variable_t var)
- : m_priority(1.0)
- , m_refcount(1)
- , m_remains(cost)
- , m_maxDuration(NO_MAX_DURATION)
- , m_finish(-1.0)
- , m_failed(failed)
- , m_start(surf_get_clock())
- , m_cost(cost)
- , p_model(model)
- , p_data(NULL)
- , p_variable(var)
- , m_lastValue(0)
- , m_lastUpdate(0)
- , m_suspended(false)
 {
 {
+  initialize(model, cost, failed, var);
   #ifdef HAVE_TRACING
     p_category = NULL;
   #endif
   #ifdef HAVE_TRACING
     p_category = NULL;
   #endif
index 1b4a4c7..b16e770 100644 (file)
@@ -390,6 +390,13 @@ void surf_action_lmm_update_index_heap(void *action, int i);
  * @details An action is an event generated by a resource (e.g.: a communication for the network)
  */
 class Action : public actionHook, public actionLmmHook {
  * @details An action is an event generated by a resource (e.g.: a communication for the network)
  */
 class Action : public actionHook, public actionLmmHook {
+private:
+  /**
+   * @brief Common initializations for the constructors
+   */
+  void initialize(ModelPtr model, double cost, bool failed,
+                  lmm_variable_t var = NULL);
+
 public:
   /**
    * @brief Action constructor
 public:
   /**
    * @brief Action constructor