Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Clean surf interface
authorPaul Bédaride <paul.bedaride@gmail.com>
Thu, 12 Dec 2013 10:44:32 +0000 (11:44 +0100)
committerPaul Bédaride <paul.bedaride@gmail.com>
Thu, 12 Dec 2013 11:59:43 +0000 (12:59 +0100)
30 files changed:
.cproject
src/surf/cpu_cas01.cpp
src/surf/cpu_cas01.hpp
src/surf/cpu_interface.cpp
src/surf/cpu_interface.hpp
src/surf/cpu_ti.cpp
src/surf/cpu_ti.hpp
src/surf/network_cm02.cpp
src/surf/network_cm02.hpp
src/surf/network_constant.cpp
src/surf/network_constant.hpp
src/surf/network_interface.cpp
src/surf/network_interface.hpp
src/surf/network_smpi.cpp
src/surf/storage_interface.cpp
src/surf/storage_interface.hpp
src/surf/storage_n11.cpp
src/surf/surf_c_bindings.cpp
src/surf/surf_interface.cpp
src/surf/surf_interface.hpp
src/surf/surf_routing_cluster.cpp
src/surf/surf_routing_generic.cpp
src/surf/vm_workstation_hl13.cpp
src/surf/vm_workstation_interface.cpp
src/surf/workstation_clm03.cpp
src/surf/workstation_clm03.hpp
src/surf/workstation_interface.cpp
src/surf/workstation_interface.hpp
src/surf/workstation_ptask_L07.cpp
src/surf/workstation_ptask_L07.hpp

index 70f5e1a..56ee086 100644 (file)
--- a/.cproject
+++ b/.cproject
@@ -1,5 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?fileVersion 5.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage2">
+<?fileVersion 5.0.0?>
+
+<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage2">
        <storageModule moduleId="org.eclipse.cdt.core.settings">
                <cconfiguration id="cdt.managedbuild.toolchain.gnu.base.1053321950">
                        <storageModule externalCElementFile="cdt.managedbuild.toolchain.gnu.base.1053321950_org.eclipse.cdt.core.settings" id="cdt.managedbuild.toolchain.gnu.base.1053321950" name="Default"/>
        <storageModule moduleId="org.eclipse.cdt.core.settings">
                <cconfiguration id="cdt.managedbuild.toolchain.gnu.base.1053321950">
                        <storageModule externalCElementFile="cdt.managedbuild.toolchain.gnu.base.1053321950_org.eclipse.cdt.core.settings" id="cdt.managedbuild.toolchain.gnu.base.1053321950" name="Default"/>
@@ -19,4 +21,5 @@
                        <resource resourceType="PROJECT" workspacePath="/simgrid"/>
                </configuration>
        </storageModule>
                        <resource resourceType="PROJECT" workspacePath="/simgrid"/>
                </configuration>
        </storageModule>
+       <storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
 </cproject>
 </cproject>
index 648e0c4..7d15235 100644 (file)
@@ -81,11 +81,11 @@ CpuCas01Model::CpuCas01Model() : CpuModel("cpu")
   p_cpuRunningActionSetThatDoesNotNeedBeingChecked =
       xbt_swag_new(xbt_swag_offset(*action, p_stateHookup));
 
   p_cpuRunningActionSetThatDoesNotNeedBeingChecked =
       xbt_swag_new(xbt_swag_offset(*action, p_stateHookup));
 
-  if (p_updateMechanism == UM_LAZY) {
+  if (getUpdateMechanism() == UM_LAZY) {
        shareResources = &CpuCas01Model::shareResourcesLazy;
        updateActionsState = &CpuCas01Model::updateActionsStateLazy;
 
        shareResources = &CpuCas01Model::shareResourcesLazy;
        updateActionsState = &CpuCas01Model::updateActionsStateLazy;
 
-  } else if (p_updateMechanism == UM_FULL) {
+  } else if (getUpdateMechanism() == UM_FULL) {
        shareResources = &CpuCas01Model::shareResourcesFull;
        updateActionsState = &CpuCas01Model::updateActionsStateFull;
   } else
        shareResources = &CpuCas01Model::shareResourcesFull;
        updateActionsState = &CpuCas01Model::updateActionsStateFull;
   } else
@@ -95,7 +95,7 @@ CpuCas01Model::CpuCas01Model() : CpuModel("cpu")
     p_maxminSystem = lmm_system_new(m_selectiveUpdate);
   }
 
     p_maxminSystem = lmm_system_new(m_selectiveUpdate);
   }
 
-  if (p_updateMechanism == UM_LAZY) {
+  if (getUpdateMechanism() == UM_LAZY) {
     p_actionHeap = xbt_heap_new(8, NULL);
     xbt_heap_set_update_callback(p_actionHeap,  surf_action_lmm_update_index_heap);
     p_modifiedSet = xbt_swag_new(xbt_swag_offset(*actionlmm, p_actionListHookup));
     p_actionHeap = xbt_heap_new(8, NULL);
     xbt_heap_set_update_callback(p_actionHeap,  surf_action_lmm_update_index_heap);
     p_modifiedSet = xbt_swag_new(xbt_swag_offset(*actionlmm, p_actionListHookup));
@@ -153,7 +153,7 @@ CpuPtr CpuCas01Model::createResource(const char *name, xbt_dynar_t power_peak,
 
 double CpuCas01Model::shareResourcesFull(double /*now*/)
 {
 
 double CpuCas01Model::shareResourcesFull(double /*now*/)
 {
-  return Model::shareResourcesMaxMin(p_runningActionSet,
+  return Model::shareResourcesMaxMin(getRunningActionSet(),
                              p_maxminSystem, lmm_solve);
 }
 
                              p_maxminSystem, lmm_solve);
 }
 
@@ -174,8 +174,7 @@ void CpuCas01Model::addTraces()
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
-    host->p_stateEvent =
-        tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(host));
+    host->p_stateEvent = tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(host));
   }
 
   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
   }
 
   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
@@ -193,12 +192,13 @@ void CpuCas01Model::addTraces()
 /************
  * Resource *
  ************/
 /************
  * Resource *
  ************/
-CpuCas01Lmm::CpuCas01Lmm(CpuCas01ModelPtr model, const char *name, xbt_dynar_t powerPeak,
+CpuCas01Lmm::CpuCas01Lmm(CpuCas01ModelPtr model_, const char *name, xbt_dynar_t powerPeak,
                          int pstate, double powerScale, tmgr_trace_t powerTrace, int core,
                          e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace,
                          xbt_dict_t properties)
                          int pstate, double powerScale, tmgr_trace_t powerTrace, int core,
                          e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace,
                          xbt_dict_t properties)
-: Resource(model, name, properties)
-, CpuLmm(model, name, properties, core, xbt_dynar_get_as(powerPeak, pstate, double), powerScale) {
+: Resource(model_, name, properties)
+, CpuLmm(lmm_constraint_new(getModel()->getMaxminSystem(), this, core * powerScale * xbt_dynar_get_as(powerPeak, pstate, double)),
+                core, xbt_dynar_get_as(powerPeak, pstate, double), powerScale) {
   p_powerEvent = NULL;
   p_powerPeakList = powerPeak;
   m_pstate = pstate;
   p_powerEvent = NULL;
   p_powerPeakList = powerPeak;
   m_pstate = pstate;
@@ -211,14 +211,12 @@ CpuCas01Lmm::CpuCas01Lmm(CpuCas01ModelPtr model, const char *name, xbt_dynar_t p
   XBT_DEBUG("CPU create: peak=%f, pstate=%d", m_powerPeak, m_pstate);
 
   m_core = core;
   XBT_DEBUG("CPU create: peak=%f, pstate=%d", m_powerPeak, m_pstate);
 
   m_core = core;
-  p_stateCurrent = stateInitial;
+  m_stateCurrent = stateInitial;
   if (powerTrace)
     p_powerEvent = tmgr_history_add_trace(history, powerTrace, 0.0, 0, static_cast<ResourcePtr>(this));
 
   if (stateTrace)
     p_stateEvent = tmgr_history_add_trace(history, stateTrace, 0.0, 0, static_cast<ResourcePtr>(this));
   if (powerTrace)
     p_powerEvent = tmgr_history_add_trace(history, powerTrace, 0.0, 0, static_cast<ResourcePtr>(this));
 
   if (stateTrace)
     p_stateEvent = tmgr_history_add_trace(history, stateTrace, 0.0, 0, static_cast<ResourcePtr>(this));
-
-  p_constraint = lmm_constraint_new(p_model->p_maxminSystem, this, m_core * m_powerScale * m_powerPeak);
 }
 
 CpuCas01Lmm::~CpuCas01Lmm(){
 }
 
 CpuCas01Lmm::~CpuCas01Lmm(){
@@ -233,7 +231,7 @@ CpuCas01Lmm::~CpuCas01Lmm(){
 
 bool CpuCas01Lmm::isUsed()
 {
 
 bool CpuCas01Lmm::isUsed()
 {
-  return lmm_constraint_used(p_model->p_maxminSystem, p_constraint);
+  return lmm_constraint_used(getModel()->getMaxminSystem(), constraint());
 }
 
 void CpuCas01Lmm::updateState(tmgr_trace_event_t event_type, double value, double date)
 }
 
 void CpuCas01Lmm::updateState(tmgr_trace_event_t event_type, double value, double date)
@@ -246,20 +244,20 @@ void CpuCas01Lmm::updateState(tmgr_trace_event_t event_type, double value, doubl
        xbt_assert(m_core == 1, "FIXME: add power scaling code also for constraint_core[i]");
 
     m_powerScale = value;
        xbt_assert(m_core == 1, "FIXME: add power scaling code also for constraint_core[i]");
 
     m_powerScale = value;
-    lmm_update_constraint_bound(surf_cpu_model_pm->p_maxminSystem, p_constraint,
+    lmm_update_constraint_bound(surf_cpu_model_pm->getMaxminSystem(), constraint(),
                                 m_core * m_powerScale *
                                 m_powerPeak);
 #ifdef HAVE_TRACING
                                 m_core * m_powerScale *
                                 m_powerPeak);
 #ifdef HAVE_TRACING
-    TRACE_surf_host_set_power(date, m_name,
+    TRACE_surf_host_set_power(date, getName(),
                               m_core * m_powerScale *
                               m_powerPeak);
 #endif
     while ((var = lmm_get_var_from_cnst
                               m_core * m_powerScale *
                               m_powerPeak);
 #endif
     while ((var = lmm_get_var_from_cnst
-            (surf_cpu_model_pm->p_maxminSystem, p_constraint, &elem))) {
+            (surf_cpu_model_pm->getMaxminSystem(), constraint(), &elem))) {
       CpuCas01ActionLmmPtr action = static_cast<CpuCas01ActionLmmPtr>(static_cast<ActionLmmPtr>(lmm_variable_id(var)));
 
       CpuCas01ActionLmmPtr action = static_cast<CpuCas01ActionLmmPtr>(static_cast<ActionLmmPtr>(lmm_variable_id(var)));
 
-      lmm_update_variable_bound(surf_cpu_model_pm->p_maxminSystem,
-                                action->p_variable,
+      lmm_update_variable_bound(surf_cpu_model_pm->getMaxminSystem(),
+                                action->getVariable(),
                                 m_powerScale * m_powerPeak);
     }
     if (tmgr_trace_event_free(event_type))
                                 m_powerScale * m_powerPeak);
     }
     if (tmgr_trace_event_free(event_type))
@@ -269,21 +267,21 @@ void CpuCas01Lmm::updateState(tmgr_trace_event_t event_type, double value, doubl
     xbt_assert(m_core == 1, "FIXME: add state change code also for constraint_core[i]");
 
     if (value > 0) {
     xbt_assert(m_core == 1, "FIXME: add state change code also for constraint_core[i]");
 
     if (value > 0) {
-      if(p_stateCurrent == SURF_RESOURCE_OFF)
-        xbt_dynar_push_as(host_that_restart, char*, (char *)m_name);
-      p_stateCurrent = SURF_RESOURCE_ON;
+      if(m_stateCurrent == SURF_RESOURCE_OFF)
+        xbt_dynar_push_as(host_that_restart, char*, (char *)getName());
+      m_stateCurrent = SURF_RESOURCE_ON;
     } else {
     } else {
-      lmm_constraint_t cnst = p_constraint;
+      lmm_constraint_t cnst = constraint();
 
 
-      p_stateCurrent = SURF_RESOURCE_OFF;
+      m_stateCurrent = SURF_RESOURCE_OFF;
 
 
-      while ((var = lmm_get_var_from_cnst(surf_cpu_model_pm->p_maxminSystem, cnst, &elem))) {
+      while ((var = lmm_get_var_from_cnst(surf_cpu_model_pm->getMaxminSystem(), cnst, &elem))) {
         ActionLmmPtr action = static_cast<ActionLmmPtr>(lmm_variable_id(var));
 
         if (action->getState() == SURF_ACTION_RUNNING ||
             action->getState() == SURF_ACTION_READY ||
             action->getState() == SURF_ACTION_NOT_IN_THE_SYSTEM) {
         ActionLmmPtr action = static_cast<ActionLmmPtr>(lmm_variable_id(var));
 
         if (action->getState() == SURF_ACTION_RUNNING ||
             action->getState() == SURF_ACTION_READY ||
             action->getState() == SURF_ACTION_NOT_IN_THE_SYSTEM) {
-          action->m_finish = date;
+          action->setFinishTime(date);
           action->setState(SURF_ACTION_FAILED);
         }
       }
           action->setState(SURF_ACTION_FAILED);
         }
       }
@@ -298,37 +296,26 @@ void CpuCas01Lmm::updateState(tmgr_trace_event_t event_type, double value, doubl
   return;
 }
 
   return;
 }
 
-ActionPtr CpuCas01Lmm::execute(double size)
+CpuActionPtr CpuCas01Lmm::execute(double size)
 {
 
 {
 
-  XBT_IN("(%s,%g)", m_name, size);
-  CpuCas01ActionLmmPtr action = new CpuCas01ActionLmm(surf_cpu_model_pm, size, p_stateCurrent != SURF_RESOURCE_ON);
-
-  action->m_suspended = 0;     /* Should be useless because of the
-                                                   calloc but it seems to help valgrind... */
+  XBT_IN("(%s,%g)", getName(), size);
+  CpuCas01ActionLmmPtr action = new CpuCas01ActionLmm(surf_cpu_model_pm, size, m_stateCurrent != SURF_RESOURCE_ON,
+                                                             m_powerScale * m_powerPeak, constraint());
 
 
-  action->p_variable =
-      lmm_variable_new(surf_cpu_model_pm->p_maxminSystem, static_cast<ActionLmmPtr>(action),
-                       action->m_priority,
-                       m_powerScale * m_powerPeak, 1);
-  if (surf_cpu_model_pm->p_updateMechanism == UM_LAZY) {
-    action->m_indexHeap = -1;
-    action->m_lastUpdate = surf_get_clock();
-    action->m_lastValue = 0.0;
-  }
-  lmm_expand(surf_cpu_model_pm->p_maxminSystem, p_constraint,
-             action->p_variable, 1.0);
   XBT_OUT();
   return action;
 }
 
   XBT_OUT();
   return action;
 }
 
-ActionPtr CpuCas01Lmm::sleep(double duration)
+CpuActionPtr CpuCas01Lmm::sleep(double duration)
 {
   if (duration > 0)
     duration = MAX(duration, MAXMIN_PRECISION);
 
 {
   if (duration > 0)
     duration = MAX(duration, MAXMIN_PRECISION);
 
-  XBT_IN("(%s,%g)", m_name, duration);
-  CpuCas01ActionLmmPtr action = dynamic_cast<CpuCas01ActionLmmPtr>(execute(1.0));
+  XBT_IN("(%s,%g)", getName(), duration);
+  CpuCas01ActionLmmPtr action = new CpuCas01ActionLmm(surf_cpu_model_pm, 1.0, m_stateCurrent != SURF_RESOURCE_ON,
+                                                      m_powerScale * m_powerPeak, constraint());
+
 
   // FIXME: sleep variables should not consume 1.0 in lmm_expand
   action->m_maxDuration = duration;
 
   // FIXME: sleep variables should not consume 1.0 in lmm_expand
   action->m_maxDuration = duration;
@@ -336,19 +323,19 @@ ActionPtr CpuCas01Lmm::sleep(double duration)
   if (duration == NO_MAX_DURATION) {
     /* Move to the *end* of the corresponding action set. This convention
        is used to speed up update_resource_state  */
   if (duration == NO_MAX_DURATION) {
     /* Move to the *end* of the corresponding action set. This convention
        is used to speed up update_resource_state  */
-    xbt_swag_remove(static_cast<ActionPtr>(action), action->p_stateSet);
-    action->p_stateSet = static_cast<CpuCas01ModelPtr>(p_model)->p_cpuRunningActionSetThatDoesNotNeedBeingChecked;
-    xbt_swag_insert(static_cast<ActionPtr>(action), action->p_stateSet);
+    xbt_swag_remove(static_cast<ActionPtr>(action), action->getStateSet());
+    action->p_stateSet = static_cast<CpuCas01ModelPtr>(getModel())->p_cpuRunningActionSetThatDoesNotNeedBeingChecked;
+    xbt_swag_insert(static_cast<ActionPtr>(action), action->getStateSet());
   }
 
   }
 
-  lmm_update_variable_weight(surf_cpu_model_pm->p_maxminSystem,
-                             action->p_variable, 0.0);
-  if (surf_cpu_model_pm->p_updateMechanism == UM_LAZY) {     // remove action from the heap
-    action->heapRemove(surf_cpu_model_pm->p_actionHeap);
+  lmm_update_variable_weight(surf_cpu_model_pm->getMaxminSystem(),
+                             action->getVariable(), 0.0);
+  if (surf_cpu_model_pm->getUpdateMechanism() == UM_LAZY) {     // remove action from the heap
+    action->heapRemove(surf_cpu_model_pm->getActionHeap());
     // this is necessary for a variable with weight 0 since such
     // variables are ignored in lmm and we need to set its max_duration
     // correctly at the next call to share_resources
     // this is necessary for a variable with weight 0 since such
     // variables are ignored in lmm and we need to set its max_duration
     // correctly at the next call to share_resources
-    xbt_swag_insert_at_head(static_cast<ActionLmmPtr>(action), surf_cpu_model_pm->p_modifiedSet);
+    xbt_swag_insert_at_head(static_cast<ActionLmmPtr>(action), surf_cpu_model_pm->getModifiedSet());
   }
 
   XBT_OUT();
   }
 
   XBT_OUT();
@@ -363,10 +350,10 @@ xbt_dynar_t CpuCas01Lmm::getWattsRangeList()
        xbt_dynar_t current_power_values;
        double min_power, max_power;
 
        xbt_dynar_t current_power_values;
        double min_power, max_power;
 
-       if (m_properties == NULL)
+       if (getProperties() == NULL)
                return NULL;
 
                return NULL;
 
-       char* all_power_values_str = (char*)xbt_dict_get_or_null(m_properties, "power_per_state");
+       char* all_power_values_str = (char*)xbt_dict_get_or_null(getProperties(), "power_per_state");
 
        if (all_power_values_str == NULL)
                return NULL;
 
        if (all_power_values_str == NULL)
                return NULL;
@@ -382,7 +369,7 @@ xbt_dynar_t CpuCas01Lmm::getWattsRangeList()
                current_power_values = xbt_str_split(xbt_dynar_get_as(all_power_values, i, char*), ":");
                xbt_assert(xbt_dynar_length(current_power_values) > 1,
                                "Power properties incorrectly defined - could not retrieve min and max power values for host %s",
                current_power_values = xbt_str_split(xbt_dynar_get_as(all_power_values, i, char*), ":");
                xbt_assert(xbt_dynar_length(current_power_values) > 1,
                                "Power properties incorrectly defined - could not retrieve min and max power values for host %s",
-                               m_name);
+                               getName());
 
                /* min_power corresponds to the idle power (cpu load = 0) */
                /* max_power is the power consumed at 100% cpu load       */
 
                /* min_power corresponds to the idle power (cpu load = 0) */
                /* max_power is the power consumed at 100% cpu load       */
@@ -410,12 +397,12 @@ double CpuCas01Lmm::getCurrentWattsValue(double cpu_load)
 
        if (power_range_list == NULL)
        {
 
        if (power_range_list == NULL)
        {
-               XBT_DEBUG("No power range properties specified for host %s", m_name);
+               XBT_DEBUG("No power range properties specified for host %s", getName());
                return 0;
        }
        xbt_assert(xbt_dynar_length(power_range_list) == xbt_dynar_length(p_powerPeakList),
                                                "The number of power ranges in the properties does not match the number of pstates for host %s",
                return 0;
        }
        xbt_assert(xbt_dynar_length(power_range_list) == xbt_dynar_length(p_powerPeakList),
                                                "The number of power ranges in the properties does not match the number of pstates for host %s",
-                                               m_name);
+                                               getName());
 
     /* retrieve the power values associated with the current pstate */
     xbt_dynar_t current_power_values = xbt_dynar_get_as(power_range_list, m_pstate, xbt_dynar_t);
 
     /* retrieve the power values associated with the current pstate */
     xbt_dynar_t current_power_values = xbt_dynar_get_as(power_range_list, m_pstate, xbt_dynar_t);
@@ -491,6 +478,24 @@ double CpuCas01Lmm::getConsumedEnergy()
  * Action *
  **********/
 
  * Action *
  **********/
 
+CpuCas01ActionLmm::CpuCas01ActionLmm(ModelPtr model_, double cost, bool failed, double power, lmm_constraint_t constraint)
+ : Action(model_, cost, failed)
+ , CpuActionLmm(lmm_variable_new(getModel()->getMaxminSystem(), static_cast<ActionLmmPtr>(this),
+                       m_priority,
+                power, 1))
+{
+  m_suspended = 0;     /* Should be useless because of the
+                                                          calloc but it seems to help valgrind... */
+
+  if (getModel()->getUpdateMechanism() == UM_LAZY) {
+    m_indexHeap = -1;
+    m_lastUpdate = surf_get_clock();
+    m_lastValue = 0.0;
+  }
+  lmm_expand(getModel()->getMaxminSystem(), constraint, getVariable(), 1.0);
+}
+
+
 /**
  * Update the CPU total energy for a finished action
  *
 /**
  * Update the CPU total energy for a finished action
  *
@@ -498,11 +503,11 @@ double CpuCas01Lmm::getConsumedEnergy()
 void CpuCas01ActionLmm::updateEnergy()
 {
   CpuCas01LmmPtr cpu  = static_cast<CpuCas01LmmPtr>(lmm_constraint_id(lmm_get_cnst_from_var
 void CpuCas01ActionLmm::updateEnergy()
 {
   CpuCas01LmmPtr cpu  = static_cast<CpuCas01LmmPtr>(lmm_constraint_id(lmm_get_cnst_from_var
-                                                                                 (p_model->p_maxminSystem,
-                                                                                                 p_variable, 0)));
+                                                                                 (getModel()->getMaxminSystem(),
+                                                                                                 getVariable(), 0)));
 
   if(cpu->p_energy->last_updated < surf_get_clock()) {
 
   if(cpu->p_energy->last_updated < surf_get_clock()) {
-       double load = lmm_constraint_get_usage(cpu->p_constraint) / cpu->m_powerPeak;
+       double load = lmm_constraint_get_usage(cpu->constraint()) / cpu->m_powerPeak;
     cpu->updateEnergy(load);
   }
 }
     cpu->updateEnergy(load);
   }
 }
index 5f52ef5..7fc07d0 100644 (file)
@@ -48,6 +48,8 @@ typedef struct energy_cpu_cas01 {
 } s_energy_cpu_cas01_t, *energy_cpu_cas01_t;
 
 class CpuCas01Lmm : public CpuLmm {
 } s_energy_cpu_cas01_t, *energy_cpu_cas01_t;
 
 class CpuCas01Lmm : public CpuLmm {
+public://FIXME:
+  tmgr_trace_event_t p_stateEvent;
 public:
   CpuCas01Lmm(CpuCas01ModelPtr model, const char *name, xbt_dynar_t power_peak,
         int pstate, double powerScale, tmgr_trace_t powerTrace, int core,
 public:
   CpuCas01Lmm(CpuCas01ModelPtr model, const char *name, xbt_dynar_t power_peak,
         int pstate, double powerScale, tmgr_trace_t powerTrace, int core,
@@ -55,8 +57,8 @@ public:
        xbt_dict_t properties) ;
   ~CpuCas01Lmm();
   void updateState(tmgr_trace_event_t event_type, double value, double date);
        xbt_dict_t properties) ;
   ~CpuCas01Lmm();
   void updateState(tmgr_trace_event_t event_type, double value, double date);
-  ActionPtr execute(double size);
-  ActionPtr sleep(double duration);
+  CpuActionPtr execute(double size);
+  CpuActionPtr sleep(double duration);
 
   xbt_dynar_t getWattsRangeList();
   double getCurrentWattsValue(double cpu_load);
 
   xbt_dynar_t getWattsRangeList();
   double getCurrentWattsValue(double cpu_load);
@@ -71,7 +73,6 @@ public:
   bool isUsed();
 
   tmgr_trace_event_t p_powerEvent;
   bool isUsed();
 
   tmgr_trace_event_t p_powerEvent;
-
   xbt_dynar_t p_powerPeakList;                         /*< List of supported CPU capacities */
   int m_pstate;                                                                /*< Current pstate (index in the power_peak_list)*/
   energy_cpu_cas01_t p_energy;                         /*< Structure with energy-consumption data */
   xbt_dynar_t p_powerPeakList;                         /*< List of supported CPU capacities */
   int m_pstate;                                                                /*< Current pstate (index in the power_peak_list)*/
   energy_cpu_cas01_t p_energy;                         /*< Structure with energy-consumption data */
@@ -81,9 +82,12 @@ public:
  * Action *
  **********/
 class CpuCas01ActionLmm: public CpuActionLmm {
  * Action *
  **********/
 class CpuCas01ActionLmm: public CpuActionLmm {
+  friend CpuActionPtr CpuCas01Lmm::execute(double size);
+  friend CpuActionPtr CpuCas01Lmm::sleep(double duration);
 public:
   CpuCas01ActionLmm() {};
 public:
   CpuCas01ActionLmm() {};
-  CpuCas01ActionLmm(ModelPtr model, double cost, bool failed): Action(model, cost, failed), CpuActionLmm(model, cost, failed) {};
+  CpuCas01ActionLmm(ModelPtr model, double cost, bool failed, double power, lmm_constraint_t constraint);
+
   ~CpuCas01ActionLmm() {};
   void updateEnergy();
 };
   ~CpuCas01ActionLmm() {};
   void updateEnergy();
 };
index 57d285a..dd9ee5a 100644 (file)
@@ -15,43 +15,44 @@ void CpuModel::updateActionsStateLazy(double now, double /*delta*/)
 {
   void *_action;
   CpuActionLmmPtr action;
 {
   void *_action;
   CpuActionLmmPtr action;
-  while ((xbt_heap_size(p_actionHeap) > 0)
-         && (double_equals(xbt_heap_maxkey(p_actionHeap), now))) {
-    action = dynamic_cast<CpuActionLmmPtr>(static_cast<ActionLmmPtr>(xbt_heap_pop(p_actionHeap)));
+  while ((xbt_heap_size(getActionHeap()) > 0)
+         && (double_equals(xbt_heap_maxkey(getActionHeap()), now))) {
+    action = dynamic_cast<CpuActionLmmPtr>(static_cast<ActionLmmPtr>(xbt_heap_pop(getActionHeap())));
     XBT_CDEBUG(surf_kernel, "Something happened to action %p", action);
 #ifdef HAVE_TRACING
     if (TRACE_is_enabled()) {
     XBT_CDEBUG(surf_kernel, "Something happened to action %p", action);
 #ifdef HAVE_TRACING
     if (TRACE_is_enabled()) {
-      CpuPtr cpu = (CpuPtr) lmm_constraint_id(lmm_get_cnst_from_var(p_maxminSystem, action->p_variable, 0));
-      TRACE_surf_host_set_utilization(cpu->m_name, action->p_category,
-                                      lmm_variable_getvalue(action->p_variable),
-                                      action->m_lastUpdate,
-                                      now - action->m_lastUpdate);
+      CpuPtr cpu = static_cast<CpuPtr>(lmm_constraint_id(lmm_get_cnst_from_var(getMaxminSystem(), action->getVariable(), 0)));
+      TRACE_surf_host_set_utilization(cpu->getName(), action->getCategory(),
+                                      lmm_variable_getvalue(action->getVariable()),
+                                      action->getLastUpdate(),
+                                      now - action->getLastUpdate());
     }
 #endif
 
     }
 #endif
 
-    action->m_finish = surf_get_clock();
+    action->finish();
     XBT_CDEBUG(surf_kernel, "Action %p finished", action);
 
     action->updateEnergy();
 
     /* set the remains to 0 due to precision problems when updating the remaining amount */
     XBT_CDEBUG(surf_kernel, "Action %p finished", action);
 
     action->updateEnergy();
 
     /* set the remains to 0 due to precision problems when updating the remaining amount */
-    action->m_remains = 0;
+    action->setRemains(0);
     action->setState(SURF_ACTION_DONE);
     action->setState(SURF_ACTION_DONE);
-    action->heapRemove(p_actionHeap); //FIXME: strange call since action was already popped
+    action->heapRemove(getActionHeap()); //FIXME: strange call since action was already popped
   }
 #ifdef HAVE_TRACING
   if (TRACE_is_enabled()) {
     //defining the last timestamp that we can safely dump to trace file
     //without losing the event ascending order (considering all CPU's)
     double smaller = -1;
   }
 #ifdef HAVE_TRACING
   if (TRACE_is_enabled()) {
     //defining the last timestamp that we can safely dump to trace file
     //without losing the event ascending order (considering all CPU's)
     double smaller = -1;
-    xbt_swag_foreach(_action, p_runningActionSet) {
+    xbt_swag_t actionSet = getRunningActionSet();
+    xbt_swag_foreach(_action, actionSet) {
       action = dynamic_cast<CpuActionLmmPtr>(static_cast<ActionPtr>(_action));
         if (smaller < 0) {
       action = dynamic_cast<CpuActionLmmPtr>(static_cast<ActionPtr>(_action));
         if (smaller < 0) {
-          smaller = action->m_lastUpdate;
+          smaller = action->getLastUpdate();
           continue;
         }
           continue;
         }
-        if (action->m_lastUpdate < smaller) {
-          smaller = action->m_lastUpdate;
+        if (action->getLastUpdate() < smaller) {
+          smaller = action->getLastUpdate();
         }
     }
     if (smaller > 0) {
         }
     }
     if (smaller > 0) {
@@ -66,40 +67,38 @@ void CpuModel::updateActionsStateFull(double now, double delta)
 {
   void *_action, *_next_action;
   CpuActionLmmPtr action = NULL;
 {
   void *_action, *_next_action;
   CpuActionLmmPtr action = NULL;
-  xbt_swag_t running_actions = p_runningActionSet;
+  xbt_swag_t running_actions = getRunningActionSet();
 
   xbt_swag_foreach_safe(_action, _next_action, running_actions) {
     action = dynamic_cast<CpuActionLmmPtr>(static_cast<ActionPtr>(_action));
 #ifdef HAVE_TRACING
     if (TRACE_is_enabled()) {
       CpuPtr x = (CpuPtr) lmm_constraint_id(lmm_get_cnst_from_var
 
   xbt_swag_foreach_safe(_action, _next_action, running_actions) {
     action = dynamic_cast<CpuActionLmmPtr>(static_cast<ActionPtr>(_action));
 #ifdef HAVE_TRACING
     if (TRACE_is_enabled()) {
       CpuPtr x = (CpuPtr) lmm_constraint_id(lmm_get_cnst_from_var
-                              (p_maxminSystem, action->p_variable, 0));
+                              (getMaxminSystem(), action->getVariable(), 0));
 
 
-      TRACE_surf_host_set_utilization(x->m_name,
-                                      action->p_category,
-                                      lmm_variable_getvalue(action->p_variable),
+      TRACE_surf_host_set_utilization(x->getName(),
+                                      action->getCategory(),
+                                      lmm_variable_getvalue(action->getVariable()),
                                       now - delta,
                                       delta);
       TRACE_last_timestamp_to_dump = now - delta;
     }
 #endif
 
                                       now - delta,
                                       delta);
       TRACE_last_timestamp_to_dump = now - delta;
     }
 #endif
 
-    double_update(&(action->m_remains),
-                  lmm_variable_getvalue(action->p_variable) * delta);
+    action->updateRemains(lmm_variable_getvalue(action->getVariable()) * delta);
 
 
 
 
-    if (action->m_maxDuration != NO_MAX_DURATION)
-      double_update(&(action->m_maxDuration), delta);
+    if (action->getMaxDuration() != NO_MAX_DURATION)
+      action->updateMaxDuration(delta);
 
 
 
 
-    if ((action->m_remains <= 0) &&
-        (lmm_get_variable_weight(action->p_variable) > 0)) {
-      action->m_finish = surf_get_clock();
+    if ((action->getRemains() <= 0) &&
+        (lmm_get_variable_weight(action->getVariable()) > 0)) {
+      action->finish();
       action->setState(SURF_ACTION_DONE);
       action->setState(SURF_ACTION_DONE);
-
-    } else if ((action->m_maxDuration != NO_MAX_DURATION) &&
-               (action->m_maxDuration <= 0)) {
-      action->m_finish = surf_get_clock();
+    } else if ((action->getMaxDuration() != NO_MAX_DURATION) &&
+               (action->getMaxDuration() <= 0)) {
+      action->finish();
       action->setState(SURF_ACTION_DONE);
     }
     action->updateEnergy();
       action->setState(SURF_ACTION_DONE);
     }
     action->updateEnergy();
@@ -112,6 +111,10 @@ void CpuModel::updateActionsStateFull(double now, double delta)
  * Resource *
  ************/
 
  * Resource *
  ************/
 
+Cpu::Cpu(int core, double powerPeak, double powerScale)
+ : m_core(core), m_powerPeak(powerPeak), m_powerScale(powerScale)
+{}
+
 double Cpu::getSpeed(double load)
 {
   return load * m_powerPeak;
 double Cpu::getSpeed(double load)
 {
   return load * m_powerPeak;
@@ -128,11 +131,18 @@ int Cpu::getCore()
   return m_core;
 }
 
   return m_core;
 }
 
-CpuLmm::CpuLmm(CpuModelPtr model, const char* name, xbt_dict_t properties, int core, double powerPeak, double powerScale)
-: ResourceLmm(), Cpu(model, name, properties, core, powerPeak, powerScale) {
+CpuLmm::CpuLmm(lmm_constraint_t constraint)
+: ResourceLmm(constraint), p_constraintCore(NULL), p_constraintCoreId(NULL)
+{}
+
+CpuLmm::CpuLmm(lmm_constraint_t constraint, int core, double powerPeak, double powerScale)
+ : ResourceLmm(constraint)
+ , Cpu(core, powerPeak, powerScale)
+{
   /* At now, we assume that a VM does not have a multicore CPU. */
   if (core > 1)
   /* At now, we assume that a VM does not have a multicore CPU. */
   if (core > 1)
-    xbt_assert(model == surf_cpu_model_pm);
+    xbt_assert(getModel() == surf_cpu_model_pm);
+
 
   p_constraintCore = xbt_new(lmm_constraint_t, core);
   p_constraintCoreId = xbt_new(void*, core);
 
   p_constraintCore = xbt_new(lmm_constraint_t, core);
   p_constraintCoreId = xbt_new(void*, core);
@@ -140,8 +150,8 @@ CpuLmm::CpuLmm(CpuModelPtr model, const char* name, xbt_dict_t properties, int c
   int i;
   for (i = 0; i < core; i++) {
     /* just for a unique id, never used as a string. */
   int i;
   for (i = 0; i < core; i++) {
     /* just for a unique id, never used as a string. */
-    p_constraintCoreId[i] = bprintf("%s:%i", name, i);
-    p_constraintCore[i] = lmm_constraint_new(p_model->p_maxminSystem, p_constraintCoreId[i], m_powerScale * m_powerPeak);
+    p_constraintCoreId[i] = bprintf("%s:%i", getName(), i);
+    p_constraintCore[i] = lmm_constraint_new(getModel()->getMaxminSystem(), p_constraintCoreId[i], m_powerScale * m_powerPeak);
   }
 }
 
   }
 }
 
@@ -163,11 +173,11 @@ void CpuActionLmm::updateRemainingLazy(double now)
 {
   double delta = 0.0;
 
 {
   double delta = 0.0;
 
-  xbt_assert(p_stateSet == p_model->p_runningActionSet,
+  xbt_assert(getStateSet() == getModel()->getRunningActionSet(),
       "You're updating an action that is not running.");
 
   /* bogus priority, skip it */
       "You're updating an action that is not running.");
 
   /* bogus priority, skip it */
-  xbt_assert(m_priority > 0,
+  xbt_assert(getPriority() > 0,
       "You're updating an action that seems suspended.");
 
   delta = now - m_lastUpdate;
       "You're updating an action that seems suspended.");
 
   delta = now - m_lastUpdate;
@@ -178,25 +188,25 @@ void CpuActionLmm::updateRemainingLazy(double now)
 
 #ifdef HAVE_TRACING
     if (TRACE_is_enabled()) {
 
 #ifdef HAVE_TRACING
     if (TRACE_is_enabled()) {
-      CpuPtr cpu = (CpuPtr) lmm_constraint_id(lmm_get_cnst_from_var(p_model->p_maxminSystem, p_variable, 0));
-      TRACE_surf_host_set_utilization(cpu->m_name, p_category, m_lastValue, m_lastUpdate, now - m_lastUpdate);
+      CpuPtr cpu = static_cast<CpuPtr>(lmm_constraint_id(lmm_get_cnst_from_var(getModel()->getMaxminSystem(), getVariable(), 0)));
+      TRACE_surf_host_set_utilization(cpu->getName(), getCategory(), m_lastValue, m_lastUpdate, now - m_lastUpdate);
     }
 #endif
     XBT_CDEBUG(surf_kernel, "Updating action(%p): remains is now %lf", this, m_remains);
   }
 
   m_lastUpdate = now;
     }
 #endif
     XBT_CDEBUG(surf_kernel, "Updating action(%p): remains is now %lf", this, m_remains);
   }
 
   m_lastUpdate = now;
-  m_lastValue = lmm_variable_getvalue(p_variable);
+  m_lastValue = lmm_variable_getvalue(getVariable());
 }
 
 void CpuActionLmm::setBound(double bound)
 {
   XBT_IN("(%p,%g)", this, bound);
   m_bound = bound;
 }
 
 void CpuActionLmm::setBound(double bound)
 {
   XBT_IN("(%p,%g)", this, bound);
   m_bound = bound;
-  lmm_update_variable_bound(p_model->p_maxminSystem, p_variable, bound);
+  lmm_update_variable_bound(getModel()->getMaxminSystem(), getVariable(), bound);
 
 
-  if (p_model->p_updateMechanism == UM_LAZY)
-       heapRemove(p_model->p_actionHeap);
+  if (getModel()->getUpdateMechanism() == UM_LAZY)
+       heapRemove(getModel()->getActionHeap());
   XBT_OUT();
 }
 
   XBT_OUT();
 }
 
@@ -222,7 +232,7 @@ void CpuActionLmm::setBound(double bound)
  */
 void CpuActionLmm::setAffinity(CpuPtr _cpu, unsigned long mask)
 {
  */
 void CpuActionLmm::setAffinity(CpuPtr _cpu, unsigned long mask)
 {
-  lmm_variable_t var_obj = p_variable;
+  lmm_variable_t var_obj = getVariable();
   CpuLmmPtr cpu = reinterpret_cast<CpuLmmPtr>(_cpu);
   XBT_IN("(%p,%lx)", this, mask);
 
   CpuLmmPtr cpu = reinterpret_cast<CpuLmmPtr>(_cpu);
   XBT_IN("(%p,%lx)", this, mask);
 
@@ -244,8 +254,8 @@ void CpuActionLmm::setAffinity(CpuPtr _cpu, unsigned long mask)
   }
 
   for (int i = 0; i < cpu->m_core; i++) {
   }
 
   for (int i = 0; i < cpu->m_core; i++) {
-    XBT_DEBUG("clear affinity %p to cpu-%d@%s", this, i,  cpu->m_name);
-    lmm_shrink(cpu->p_model->p_maxminSystem, cpu->p_constraintCore[i], var_obj);
+    XBT_DEBUG("clear affinity %p to cpu-%d@%s", this, i,  cpu->getName());
+    lmm_shrink(cpu->getModel()->getMaxminSystem(), cpu->p_constraintCore[i], var_obj);
 
     unsigned long has_affinity = (1UL << i) & mask;
     if (has_affinity) {
 
     unsigned long has_affinity = (1UL << i) & mask;
     if (has_affinity) {
@@ -258,12 +268,12 @@ void CpuActionLmm::setAffinity(CpuPtr _cpu, unsigned long mask)
        * accept affinity settings on a future host. We might be able to assign
        * zero to elem->value to maintain such inactive affinity settings in the
        * system. But, this will make the system complex. */
        * accept affinity settings on a future host. We might be able to assign
        * zero to elem->value to maintain such inactive affinity settings in the
        * system. But, this will make the system complex. */
-      XBT_DEBUG("set affinity %p to cpu-%d@%s", this, i, cpu->m_name);
-      lmm_expand(cpu->p_model->p_maxminSystem, cpu->p_constraintCore[i], var_obj, 1.0);
+      XBT_DEBUG("set affinity %p to cpu-%d@%s", this, i, cpu->getName());
+      lmm_expand(cpu->getModel()->getMaxminSystem(), cpu->p_constraintCore[i], var_obj, 1.0);
     }
   }
 
     }
   }
 
-  if (cpu->p_model->p_updateMechanism == UM_LAZY) {
+  if (cpu->getModel()->getUpdateMechanism() == UM_LAZY) {
     /* FIXME (hypervisor): Do we need to do something for the LAZY mode? */
   }
 
     /* FIXME (hypervisor): Do we need to do something for the LAZY mode? */
   }
 
index 7beb425..7cc5905 100644 (file)
@@ -27,7 +27,7 @@ typedef CpuActionLmm *CpuActionLmmPtr;
  *********/
 class CpuModel : public Model {
 public:
  *********/
 class CpuModel : public Model {
 public:
-  CpuModel(string name) : Model(name) {};
+  CpuModel(const char *name) : Model(name) {};
   CpuPtr createResource(string name);
   void updateActionsStateLazy(double now, double delta);
   void updateActionsStateFull(double now, double delta);
   CpuPtr createResource(string name);
   void updateActionsStateLazy(double now, double delta);
   void updateActionsStateFull(double now, double delta);
@@ -41,11 +41,9 @@ public:
 class Cpu : virtual public Resource {
 public:
   Cpu(){};
 class Cpu : virtual public Resource {
 public:
   Cpu(){};
-  Cpu(CpuModelPtr model, const char* name, xbt_dict_t properties, int core, double powerPeak, double powerScale)
-   : Resource(model, name, properties), m_core(core), m_powerPeak(powerPeak), m_powerScale(powerScale)
-   {};
-  virtual ActionPtr execute(double size)=0;
-  virtual ActionPtr sleep(double duration)=0;
+  Cpu(int core, double powerPeak, double powerScale);
+  virtual CpuActionPtr execute(double size)=0;
+  virtual CpuActionPtr sleep(double duration)=0;
   virtual int getCore();
   virtual double getSpeed(double load);
   virtual double getAvailableSpeed();
   virtual int getCore();
   virtual double getSpeed(double load);
   virtual double getAvailableSpeed();
@@ -68,8 +66,8 @@ protected:
 
 class CpuLmm : public ResourceLmm, public Cpu {
 public:
 
 class CpuLmm : public ResourceLmm, public Cpu {
 public:
-  CpuLmm() : p_constraintCore(NULL), p_constraintCoreId(NULL) {};
-  CpuLmm(CpuModelPtr model, const char* name, xbt_dict_t properties, int core, double powerPeak, double powerScale);
+  CpuLmm(lmm_constraint_t constraint);
+  CpuLmm(lmm_constraint_t constraint, int core, double powerPeak, double powerScale);
   ~CpuLmm();
   /* Note (hypervisor): */
   lmm_constraint_t *p_constraintCore;
   ~CpuLmm();
   /* Note (hypervisor): */
   lmm_constraint_t *p_constraintCore;
@@ -84,7 +82,7 @@ class CpuAction : virtual public Action {
 public:
   CpuAction(){};
   CpuAction(ModelPtr model, double cost, bool failed)
 public:
   CpuAction(){};
   CpuAction(ModelPtr model, double cost, bool failed)
-  : Action(model, cost, failed) {};
+  : Action(model, cost, failed) {};//FIXME:REMOVE
   virtual void setAffinity(CpuPtr cpu, unsigned long mask)=0;
   virtual void setBound(double bound)=0;
 };
   virtual void setAffinity(CpuPtr cpu, unsigned long mask)=0;
   virtual void setBound(double bound)=0;
 };
@@ -92,8 +90,8 @@ public:
 class CpuActionLmm : public ActionLmm, public CpuAction {
 public:
   CpuActionLmm(){};
 class CpuActionLmm : public ActionLmm, public CpuAction {
 public:
   CpuActionLmm(){};
-  CpuActionLmm(ModelPtr model, double cost, bool failed)
-  : Action(model, cost, failed), ActionLmm(model, cost, failed), CpuAction(model, cost, failed) {};
+  CpuActionLmm(lmm_variable_t var)
+  : ActionLmm(var), CpuAction() {};
   void updateRemainingLazy(double now);
   virtual void updateEnergy()=0;
   void setAffinity(CpuPtr cpu, unsigned long mask);
   void updateRemainingLazy(double now);
   virtual void updateEnergy()=0;
   void setAffinity(CpuPtr cpu, unsigned long mask);
index 04b2cb4..b7e0362 100644 (file)
@@ -476,7 +476,7 @@ double CpuTiModel::shareResources(double now)
 
 /* iterates over modified cpus to update share resources */
   xbt_swag_foreach_safe(_cpu, _cpu_next, p_modifiedCpu) {
 
 /* iterates over modified cpus to update share resources */
   xbt_swag_foreach_safe(_cpu, _cpu_next, p_modifiedCpu) {
-    static_cast<CpuTiPtr>(_cpu)->updateActionFinishDate(now);
+    static_cast<CpuTiPtr>(_cpu)->updateActionsFinishTime(now);
   }
 /* get the min next event if heap not empty */
   if (xbt_heap_size(p_tiActionHeap) > 0)
   }
 /* get the min next event if heap not empty */
   if (xbt_heap_size(p_tiActionHeap) > 0)
@@ -493,9 +493,9 @@ void CpuTiModel::updateActionsState(double now, double /*delta*/)
          && (xbt_heap_maxkey(p_tiActionHeap) <= now)) {
     CpuTiActionPtr action = (CpuTiActionPtr) xbt_heap_pop(p_tiActionHeap);
     XBT_DEBUG("Action %p: finish", action);
          && (xbt_heap_maxkey(p_tiActionHeap) <= now)) {
     CpuTiActionPtr action = (CpuTiActionPtr) xbt_heap_pop(p_tiActionHeap);
     XBT_DEBUG("Action %p: finish", action);
-    action->m_finish = surf_get_clock();
+    action->finish();
     /* set the remains to 0 due to precision problems when updating the remaining amount */
     /* set the remains to 0 due to precision problems when updating the remaining amount */
-    action->m_remains = 0;
+    action->setRemains(0);
     action->setState(SURF_ACTION_DONE);
     /* update remaining amount of all actions */
     action->p_cpu->updateRemainingAmount(surf_get_clock());
     action->setState(SURF_ACTION_DONE);
     /* update remaining amount of all actions */
     action->p_cpu->updateRemainingAmount(surf_get_clock());
@@ -567,9 +567,9 @@ CpuTi::CpuTi(CpuTiModelPtr model, const char *name, xbt_dynar_t powerPeak,
         e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace,
        xbt_dict_t properties)
 : Resource(model, name, properties)
         e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace,
        xbt_dict_t properties)
 : Resource(model, name, properties)
-, Cpu(model, name, properties, core, 0, powerScale) {
+, Cpu(core, 0, powerScale) {
   p_powerEvent = NULL;
   p_powerEvent = NULL;
-  p_stateCurrent = stateInitial;
+  m_stateCurrent = stateInitial;
   m_powerScale = powerScale;
   m_core = core;
   tmgr_trace_t empty_trace;            
   m_powerScale = powerScale;
   m_core = core;
   tmgr_trace_t empty_trace;            
@@ -626,7 +626,7 @@ void CpuTi::updateState(tmgr_trace_event_t event_type,
            value, date);
     /* update remaining of actions and put in modified cpu swag */
     updateRemainingAmount(date);
            value, date);
     /* update remaining of actions and put in modified cpu swag */
     updateRemainingAmount(date);
-    xbt_swag_insert(this, reinterpret_cast<CpuTiModelPtr>(p_model)->p_modifiedCpu);
+    xbt_swag_insert(this, reinterpret_cast<CpuTiModelPtr>(getModel())->p_modifiedCpu);
 
     power_trace = p_availTrace->p_powerTrace;
     xbt_dynar_get_cpy(power_trace->s_list.event_list,
 
     power_trace = p_availTrace->p_powerTrace;
     xbt_dynar_get_cpy(power_trace->s_list.event_list,
@@ -645,11 +645,11 @@ void CpuTi::updateState(tmgr_trace_event_t event_type,
 
   } else if (event_type == p_stateEvent) {
     if (value > 0) {
 
   } else if (event_type == p_stateEvent) {
     if (value > 0) {
-      if(p_stateCurrent == SURF_RESOURCE_OFF)
-        xbt_dynar_push_as(host_that_restart, char*, (char *)m_name);
-      p_stateCurrent = SURF_RESOURCE_ON;
+      if(m_stateCurrent == SURF_RESOURCE_OFF)
+        xbt_dynar_push_as(host_that_restart, char*, (char *)getName());
+      m_stateCurrent = SURF_RESOURCE_ON;
     } else {
     } else {
-      p_stateCurrent = SURF_RESOURCE_OFF;
+      m_stateCurrent = SURF_RESOURCE_OFF;
 
       /* put all action running on cpu to failed */
       xbt_swag_foreach(_action, p_actionSet) {
 
       /* put all action running on cpu to failed */
       xbt_swag_foreach(_action, p_actionSet) {
@@ -657,11 +657,11 @@ void CpuTi::updateState(tmgr_trace_event_t event_type,
         if (action->getState() == SURF_ACTION_RUNNING
          || action->getState() == SURF_ACTION_READY
          || action->getState() == SURF_ACTION_NOT_IN_THE_SYSTEM) {
         if (action->getState() == SURF_ACTION_RUNNING
          || action->getState() == SURF_ACTION_READY
          || action->getState() == SURF_ACTION_NOT_IN_THE_SYSTEM) {
-          action->m_finish = date;
+          action->setFinishTime(date);
           action->setState(SURF_ACTION_FAILED);
           if (action->m_indexHeap >= 0) {
             CpuTiActionPtr heap_act = (CpuTiActionPtr)
           action->setState(SURF_ACTION_FAILED);
           if (action->m_indexHeap >= 0) {
             CpuTiActionPtr heap_act = (CpuTiActionPtr)
-                xbt_heap_remove(reinterpret_cast<CpuTiModelPtr>(p_model)->p_tiActionHeap, action->m_indexHeap);
+                xbt_heap_remove(reinterpret_cast<CpuTiModelPtr>(getModel())->p_tiActionHeap, action->m_indexHeap);
             if (heap_act != action)
               DIE_IMPOSSIBLE;
           }
             if (heap_act != action)
               DIE_IMPOSSIBLE;
           }
@@ -678,7 +678,7 @@ void CpuTi::updateState(tmgr_trace_event_t event_type,
   return;
 }
 
   return;
 }
 
-void CpuTi::updateActionFinishDate(double now)
+void CpuTi::updateActionsFinishTime(double now)
 {
   void *_action;
   CpuTiActionPtr action;
 {
   void *_action;
   CpuTiActionPtr action;
@@ -690,19 +690,19 @@ updateRemainingAmount(now);
   xbt_swag_foreach(_action, p_actionSet) {
     action = static_cast<CpuTiActionPtr>(_action);
     /* action not running, skip it */
   xbt_swag_foreach(_action, p_actionSet) {
     action = static_cast<CpuTiActionPtr>(_action);
     /* action not running, skip it */
-    if (action->p_stateSet !=
-        surf_cpu_model_pm->p_runningActionSet)
+    if (action->getStateSet() !=
+        surf_cpu_model_pm->getRunningActionSet())
       continue;
 
     /* bogus priority, skip it */
       continue;
 
     /* bogus priority, skip it */
-    if (action->m_priority <= 0)
+    if (action->getPriority() <= 0)
       continue;
 
     /* action suspended, skip it */
     if (action->m_suspended != 0)
       continue;
 
       continue;
 
     /* action suspended, skip it */
     if (action->m_suspended != 0)
       continue;
 
-    sum_priority += 1.0 / action->m_priority;
+    sum_priority += 1.0 / action->getPriority();
   }
   m_sumPriority = sum_priority;
 
   }
   m_sumPriority = sum_priority;
 
@@ -710,50 +710,50 @@ updateRemainingAmount(now);
     action = static_cast<CpuTiActionPtr>(_action);
     min_finish = -1;
     /* action not running, skip it */
     action = static_cast<CpuTiActionPtr>(_action);
     min_finish = -1;
     /* action not running, skip it */
-    if (action->p_stateSet !=
-        surf_cpu_model_pm->p_runningActionSet)
+    if (action->getStateSet() !=
+        surf_cpu_model_pm->getRunningActionSet())
       continue;
 
     /* verify if the action is really running on cpu */
       continue;
 
     /* verify if the action is really running on cpu */
-    if (action->m_suspended == 0 && action->m_priority > 0) {
+    if (action->m_suspended == 0 && action->getPriority() > 0) {
       /* total area needed to finish the action. Used in trace integration */
       total_area =
       /* total area needed to finish the action. Used in trace integration */
       total_area =
-          (action->m_remains) * sum_priority *
-           action->m_priority;
+          (action->getRemains()) * sum_priority *
+           action->getPriority();
 
       total_area /= m_powerPeak;
 
 
       total_area /= m_powerPeak;
 
-      action->m_finish = p_availTrace->solve(now, total_area);
+      action->setFinishTime(p_availTrace->solve(now, total_area));
       /* verify which event will happen before (max_duration or finish time) */
       /* verify which event will happen before (max_duration or finish time) */
-      if (action->m_maxDuration != NO_MAX_DURATION &&
-          action->m_start + action->m_maxDuration < action->m_finish)
-        min_finish = action->m_start + action->m_maxDuration;
+      if (action->getMaxDuration() != NO_MAX_DURATION &&
+          action->getStartTime() + action->getMaxDuration() < action->m_finish)
+        min_finish = action->getStartTime() + action->getMaxDuration();
       else
         min_finish = action->m_finish;
     } else {
       /* put the max duration time on heap */
       else
         min_finish = action->m_finish;
     } else {
       /* put the max duration time on heap */
-      if (action->m_maxDuration != NO_MAX_DURATION)
-        min_finish = action->m_start + action->m_maxDuration;
+      if (action->getMaxDuration() != NO_MAX_DURATION)
+        min_finish = action->getStartTime() + action->getMaxDuration();
     }
     /* add in action heap */
     XBT_DEBUG("action(%p) index %d", action, action->m_indexHeap);
     if (action->m_indexHeap >= 0) {
       CpuTiActionPtr heap_act = (CpuTiActionPtr)
     }
     /* add in action heap */
     XBT_DEBUG("action(%p) index %d", action, action->m_indexHeap);
     if (action->m_indexHeap >= 0) {
       CpuTiActionPtr heap_act = (CpuTiActionPtr)
-          xbt_heap_remove(reinterpret_cast<CpuTiModelPtr>(p_model)->p_tiActionHeap, action->m_indexHeap);
+          xbt_heap_remove(reinterpret_cast<CpuTiModelPtr>(getModel())->p_tiActionHeap, action->m_indexHeap);
       if (heap_act != action)
         DIE_IMPOSSIBLE;
     }
     if (min_finish != NO_MAX_DURATION)
       if (heap_act != action)
         DIE_IMPOSSIBLE;
     }
     if (min_finish != NO_MAX_DURATION)
-      xbt_heap_push(reinterpret_cast<CpuTiModelPtr>(p_model)->p_tiActionHeap, action, min_finish);
+      xbt_heap_push(reinterpret_cast<CpuTiModelPtr>(getModel())->p_tiActionHeap, action, min_finish);
 
     XBT_DEBUG
         ("Update finish time: Cpu(%s) Action: %p, Start Time: %f Finish Time: %f Max duration %f",
 
     XBT_DEBUG
         ("Update finish time: Cpu(%s) Action: %p, Start Time: %f Finish Time: %f Max duration %f",
-         m_name, action, action->m_start,
+         getName(), action, action->getStartTime(),
          action->m_finish,
          action->m_finish,
-         action->m_maxDuration);
+         action->getMaxDuration());
   }
 /* remove from modified cpu */
   }
 /* remove from modified cpu */
-  xbt_swag_remove(this, reinterpret_cast<CpuTiModelPtr>(p_model)->p_modifiedCpu);
+  xbt_swag_remove(this, reinterpret_cast<CpuTiModelPtr>(getModel())->p_modifiedCpu);
 }
 
 bool CpuTi::isUsed()
 }
 
 bool CpuTi::isUsed()
@@ -792,12 +792,12 @@ void CpuTi::updateRemainingAmount(double now)
   xbt_swag_foreach(_action, p_actionSet) {
     action = static_cast<CpuTiActionPtr>(_action);
     /* action not running, skip it */
   xbt_swag_foreach(_action, p_actionSet) {
     action = static_cast<CpuTiActionPtr>(_action);
     /* action not running, skip it */
-    if (action->p_stateSet !=
-        getModel()->p_runningActionSet)
+    if (action->getStateSet() !=
+        getModel()->getRunningActionSet())
       continue;
 
     /* bogus priority, skip it */
       continue;
 
     /* bogus priority, skip it */
-    if (action->m_priority <= 0)
+    if (action->getPriority() <= 0)
       continue;
 
     /* action suspended, skip it */
       continue;
 
     /* action suspended, skip it */
@@ -805,7 +805,7 @@ void CpuTi::updateRemainingAmount(double now)
       continue;
 
     /* action don't need update */
       continue;
 
     /* action don't need update */
-    if (action->m_start >= now)
+    if (action->getStartTime() >= now)
       continue;
 
     /* skip action that are finishing now */
       continue;
 
     /* skip action that are finishing now */
@@ -814,9 +814,7 @@ void CpuTi::updateRemainingAmount(double now)
       continue;
 
     /* update remaining */
       continue;
 
     /* update remaining */
-    double_update(&(action->m_remains),
-                  area_total / (m_sumPriority *
-                                action->m_priority));
+    action->updateRemains(area_total / (m_sumPriority * action->getPriority()));
     XBT_DEBUG("Update remaining action(%p) remaining %f", action,
            action->m_remains);
   }
     XBT_DEBUG("Update remaining action(%p) remaining %f", action,
            action->m_remains);
   }
@@ -825,24 +823,11 @@ void CpuTi::updateRemainingAmount(double now)
 
 CpuActionPtr CpuTi::execute(double size)
 {
 
 CpuActionPtr CpuTi::execute(double size)
 {
-  return _execute(size);
-}
-
-CpuTiActionPtr CpuTi::_execute(double size)
-{
-  XBT_IN("(%s,%g)", m_name, size);
-  CpuTiActionPtr action = new CpuTiAction(static_cast<CpuTiModelPtr>(p_model), size, p_stateCurrent != SURF_RESOURCE_ON);
-
-  action->p_cpu = this;
-  action->m_indexHeap = -1;
-
-  xbt_swag_insert(this, reinterpret_cast<CpuTiModelPtr>(p_model)->p_modifiedCpu);
+  XBT_IN("(%s,%g)", getName(), size);
+  CpuTiActionPtr action = new CpuTiAction(static_cast<CpuTiModelPtr>(getModel()), size, m_stateCurrent != SURF_RESOURCE_ON, this);
 
   xbt_swag_insert(action, p_actionSet);
 
 
   xbt_swag_insert(action, p_actionSet);
 
-  action->m_suspended = 0;        /* Should be useless because of the
-              »                     calloc but it seems to help valgrind... */
-
   XBT_OUT();
   return action;
 }
   XBT_OUT();
   return action;
 }
@@ -853,33 +838,49 @@ CpuActionPtr CpuTi::sleep(double duration)
   if (duration > 0)
     duration = MAX(duration, MAXMIN_PRECISION);
 
   if (duration > 0)
     duration = MAX(duration, MAXMIN_PRECISION);
 
-  XBT_IN("(%s,%g)", m_name, duration);
-  CpuTiActionPtr action = _execute(1.0);
+  XBT_IN("(%s,%g)", getName(), duration);
+  CpuTiActionPtr action = new CpuTiAction(static_cast<CpuTiModelPtr>(getModel()), 1.0, m_stateCurrent != SURF_RESOURCE_ON, this);
+
   action->m_maxDuration = duration;
   action->m_suspended = 2;
   if (duration == NO_MAX_DURATION) {
   action->m_maxDuration = duration;
   action->m_suspended = 2;
   if (duration == NO_MAX_DURATION) {
-    /* Move to the *end* of the corresponding action set. This convention
-       is used to speed up update_resource_state  */
-    xbt_swag_remove(static_cast<ActionPtr>(action), action->p_stateSet);
-    action->p_stateSet = reinterpret_cast<CpuTiModelPtr>(p_model)->p_runningActionSetThatDoesNotNeedBeingChecked;
-    xbt_swag_insert(static_cast<ActionPtr>(action), action->p_stateSet);
+   /* Move to the *end* of the corresponding action set. This convention
+      is used to speed up update_resource_state  */
+    xbt_swag_remove(static_cast<ActionPtr>(action), action->getStateSet());
+    action->p_stateSet = reinterpret_cast<CpuTiModelPtr>(getModel())->p_runningActionSetThatDoesNotNeedBeingChecked;
+    xbt_swag_insert(static_cast<ActionPtr>(action), action->getStateSet());
   }
   }
+
+  xbt_swag_insert(action, p_actionSet);
+
   XBT_OUT();
   return action;
 }
 
   XBT_OUT();
   return action;
 }
 
-void CpuTi::printCpuTiModel()
-{
-  std::cout << getModel()->getName() << "<<plop"<< std::endl;
-};
-
 /**********
  * Action *
  **********/
 /**********
  * Action *
  **********/
+
 static void cpu_ti_action_update_index_heap(void *action, int i)
 {
 static void cpu_ti_action_update_index_heap(void *action, int i)
 {
-  ((CpuTiActionPtr)action)->updateIndexHeap(i); 
+((CpuTiActionPtr)action)->updateIndexHeap(i);
 }
 }
+
+CpuTiAction::CpuTiAction(CpuTiModelPtr model_, double cost, bool failed,
+                                CpuTiPtr cpu)
+ : Action(model_, cost, failed)
+ , CpuAction(model_, cost, failed)
+{
+  p_cpuListHookup.next = 0;
+  p_cpuListHookup.prev = 0;
+
+  m_suspended = 0;        /* Should be useless because of the
+                                calloc but it seems to help valgrind... */
+  p_cpu = cpu;
+  m_indexHeap = -1;
+  xbt_swag_insert(cpu, reinterpret_cast<CpuTiModelPtr>(getModel())->p_modifiedCpu);
+}
+
 void CpuTiAction::updateIndexHeap(int i)
 {
   m_indexHeap = i;
 void CpuTiAction::updateIndexHeap(int i)
 {
   m_indexHeap = i;
@@ -888,19 +889,19 @@ void CpuTiAction::updateIndexHeap(int i)
 void CpuTiAction::setState(e_surf_action_state_t state)
 {
   Action::setState(state);
 void CpuTiAction::setState(e_surf_action_state_t state)
 {
   Action::setState(state);
-  xbt_swag_insert(p_cpu, reinterpret_cast<CpuTiModelPtr>(p_model)->p_modifiedCpu);
+  xbt_swag_insert(p_cpu, reinterpret_cast<CpuTiModelPtr>(getModel())->p_modifiedCpu);
 }
 
 int CpuTiAction::unref()
 {
   m_refcount--;
   if (!m_refcount) {
 }
 
 int CpuTiAction::unref()
 {
   m_refcount--;
   if (!m_refcount) {
-    xbt_swag_remove(static_cast<ActionPtr>(this), p_stateSet);
+    xbt_swag_remove(static_cast<ActionPtr>(this), getStateSet());
     /* remove from action_set */
     xbt_swag_remove(this, p_cpu->p_actionSet);
     /* remove from heap */
     /* remove from action_set */
     xbt_swag_remove(this, p_cpu->p_actionSet);
     /* remove from heap */
-    xbt_heap_remove(reinterpret_cast<CpuTiModelPtr>(p_model)->p_tiActionHeap, this->m_indexHeap);
-    xbt_swag_insert(p_cpu, reinterpret_cast<CpuTiModelPtr>(p_model)->p_modifiedCpu);
+    xbt_heap_remove(reinterpret_cast<CpuTiModelPtr>(getModel())->p_tiActionHeap, this->m_indexHeap);
+    xbt_swag_insert(p_cpu, reinterpret_cast<CpuTiModelPtr>(getModel())->p_modifiedCpu);
     delete this;
     return 1;
   }
     delete this;
     return 1;
   }
@@ -910,8 +911,8 @@ int CpuTiAction::unref()
 void CpuTiAction::cancel()
 {
   this->setState(SURF_ACTION_FAILED);
 void CpuTiAction::cancel()
 {
   this->setState(SURF_ACTION_FAILED);
-  xbt_heap_remove(p_model->p_actionHeap, this->m_indexHeap);
-  xbt_swag_insert(p_cpu, reinterpret_cast<CpuTiModelPtr>(p_model)->p_modifiedCpu);
+  xbt_heap_remove(getModel()->getActionHeap(), this->m_indexHeap);
+  xbt_swag_insert(p_cpu, reinterpret_cast<CpuTiModelPtr>(getModel())->p_modifiedCpu);
   return;
 }
 
   return;
 }
 
@@ -925,8 +926,8 @@ void CpuTiAction::suspend()
   XBT_IN("(%p)", this);
   if (m_suspended != 2) {
     m_suspended = 1;
   XBT_IN("(%p)", this);
   if (m_suspended != 2) {
     m_suspended = 1;
-    xbt_heap_remove(p_model->p_actionHeap, m_indexHeap);
-    xbt_swag_insert(p_cpu, reinterpret_cast<CpuTiModelPtr>(p_model)->p_modifiedCpu);
+    xbt_heap_remove(getModel()->getActionHeap(), m_indexHeap);
+    xbt_swag_insert(p_cpu, reinterpret_cast<CpuTiModelPtr>(getModel())->p_modifiedCpu);
   }
   XBT_OUT();
 }
   }
   XBT_OUT();
 }
@@ -936,7 +937,7 @@ void CpuTiAction::resume()
   XBT_IN("(%p)", this);
   if (m_suspended != 2) {
     m_suspended = 0;
   XBT_IN("(%p)", this);
   if (m_suspended != 2) {
     m_suspended = 0;
-    xbt_swag_insert(p_cpu, reinterpret_cast<CpuTiModelPtr>(p_model)->p_modifiedCpu);
+    xbt_swag_insert(p_cpu, reinterpret_cast<CpuTiModelPtr>(getModel())->p_modifiedCpu);
   }
   XBT_OUT();
 }
   }
   XBT_OUT();
 }
@@ -955,19 +956,19 @@ void CpuTiAction::setMaxDuration(double duration)
   m_maxDuration = duration;
 
   if (duration >= 0)
   m_maxDuration = duration;
 
   if (duration >= 0)
-    min_finish = (m_start + m_maxDuration) < m_finish ?
-                 (m_start + m_maxDuration) : m_finish;
+    min_finish = (getStartTime() + getMaxDuration()) < getFinishTime() ?
+                 (getStartTime() + getMaxDuration()) : getFinishTime();
   else
   else
-    min_finish = m_finish;
+    min_finish = getFinishTime();
 
 /* add in action heap */
   if (m_indexHeap >= 0) {
     CpuTiActionPtr heap_act = (CpuTiActionPtr)
 
 /* add in action heap */
   if (m_indexHeap >= 0) {
     CpuTiActionPtr heap_act = (CpuTiActionPtr)
-        xbt_heap_remove(p_model->p_actionHeap, m_indexHeap);
+        xbt_heap_remove(getModel()->getActionHeap(), m_indexHeap);
     if (heap_act != this)
       DIE_IMPOSSIBLE;
   }
     if (heap_act != this)
       DIE_IMPOSSIBLE;
   }
-  xbt_heap_push(p_model->p_actionHeap, this, min_finish);
+  xbt_heap_push(getModel()->getActionHeap(), this, min_finish);
 
   XBT_OUT();
 }
 
   XBT_OUT();
 }
@@ -976,7 +977,7 @@ void CpuTiAction::setPriority(double priority)
 {
   XBT_IN("(%p,%g)", this, priority);
   m_priority = priority;
 {
   XBT_IN("(%p,%g)", this, priority);
   m_priority = priority;
-  xbt_swag_insert(p_cpu, reinterpret_cast<CpuTiModelPtr>(p_model)->p_modifiedCpu);
+  xbt_swag_insert(p_cpu, reinterpret_cast<CpuTiModelPtr>(getModel())->p_modifiedCpu);
   XBT_OUT();
 }
 
   XBT_OUT();
 }
 
index 9a14110..7e27e52 100644 (file)
@@ -118,11 +118,10 @@ public:
   ~CpuTi();
 
   void updateState(tmgr_trace_event_t event_type, double value, double date);  
   ~CpuTi();
 
   void updateState(tmgr_trace_event_t event_type, double value, double date);  
-  void updateActionFinishDate(double now);
+  void updateActionsFinishTime(double now);
   bool isUsed();
   void printCpuTiModel();
   CpuActionPtr execute(double size);
   bool isUsed();
   void printCpuTiModel();
   CpuActionPtr execute(double size);
-  CpuTiActionPtr _execute(double size);
   CpuActionPtr sleep(double duration);
   double getAvailableSpeed();
 
   CpuActionPtr sleep(double duration);
   double getAvailableSpeed();
 
@@ -155,13 +154,15 @@ public:
  **********/
 
 class CpuTiAction: public CpuAction {
  **********/
 
 class CpuTiAction: public CpuAction {
+  friend CpuActionPtr CpuTi::execute(double size);
+  friend CpuActionPtr CpuTi::sleep(double duration);
+  friend void CpuTi::updateActionsFinishTime(double now);//FIXME
+  friend void CpuTi::updateRemainingAmount(double now);//FIXME
+
 public:
   CpuTiAction() {};
 public:
   CpuTiAction() {};
-  CpuTiAction(CpuTiModelPtr model, double cost, bool failed)
-  : Action(model, cost, failed), CpuAction(model, cost, failed) {
-       p_cpuListHookup.next = 0;
-       p_cpuListHookup.prev = 0;
-  };
+  CpuTiAction(CpuTiModelPtr model, double cost, bool failed,
+                                CpuTiPtr cpu);
 
   void setState(e_surf_action_state_t state);
   int unref();
 
   void setState(e_surf_action_state_t state);
   int unref();
index 8e82411..00df321 100644 (file)
@@ -319,41 +319,40 @@ void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/)
     XBT_DEBUG("Something happened to action %p", action);
 #ifdef HAVE_TRACING
     if (TRACE_is_enabled()) {
     XBT_DEBUG("Something happened to action %p", action);
 #ifdef HAVE_TRACING
     if (TRACE_is_enabled()) {
-      int n = lmm_get_number_of_cnst_from_var(p_maxminSystem, action->p_variable);
+      int n = lmm_get_number_of_cnst_from_var(p_maxminSystem, action->getVariable());
       int i;
       for (i = 0; i < n; i++){
         lmm_constraint_t constraint = lmm_get_cnst_from_var(p_maxminSystem,
       int i;
       for (i = 0; i < n; i++){
         lmm_constraint_t constraint = lmm_get_cnst_from_var(p_maxminSystem,
-                                                            action->p_variable,
+                                                            action->getVariable(),
                                                             i);
         NetworkCm02LinkLmmPtr link = static_cast<NetworkCm02LinkLmmPtr>(lmm_constraint_id(constraint));
                                                             i);
         NetworkCm02LinkLmmPtr link = static_cast<NetworkCm02LinkLmmPtr>(lmm_constraint_id(constraint));
-        TRACE_surf_link_set_utilization(link->m_name,
-                                        action->p_category,
-                                        (lmm_variable_getvalue(action->p_variable)*
+        TRACE_surf_link_set_utilization(link->getName(),
+                                        action->getCategory(),
+                                        (lmm_variable_getvalue(action->getVariable())*
                                             lmm_get_cnst_weight_from_var(p_maxminSystem,
                                             lmm_get_cnst_weight_from_var(p_maxminSystem,
-                                                action->p_variable,
+                                                action->getVariable(),
                                                 i)),
                                                 i)),
-                                        action->m_lastUpdate,
-                                        now - action->m_lastUpdate);
+                                        action->getLastUpdate(),
+                                        now - action->getLastUpdate());
       }
     }
 #endif
 
     // if I am wearing a latency hat
       }
     }
 #endif
 
     // if I am wearing a latency hat
-    if (action->m_hat == LATENCY) {
+    if (action->getHat() == LATENCY) {
       XBT_DEBUG("Latency paid for action %p. Activating", action);
       XBT_DEBUG("Latency paid for action %p. Activating", action);
-      lmm_update_variable_weight(p_maxminSystem, action->p_variable, action->m_weight);
+      lmm_update_variable_weight(p_maxminSystem, action->getVariable(), action->m_weight);
       action->heapRemove(p_actionHeap);
       action->heapRemove(p_actionHeap);
-      action->m_lastUpdate = surf_get_clock();
+      action->refreshLastUpdate();
 
         // if I am wearing a max_duration or normal hat
 
         // if I am wearing a max_duration or normal hat
-    } else if (action->m_hat == MAX_DURATION ||
-        action->m_hat == NORMAL) {
+    } else if (action->getHat() == MAX_DURATION ||
+        action->getHat() == NORMAL) {
         // no need to communicate anymore
         // assume that flows that reached max_duration have remaining of 0
         // no need to communicate anymore
         // assume that flows that reached max_duration have remaining of 0
-      action->m_finish = surf_get_clock();
       XBT_DEBUG("Action %p finished", action);
       XBT_DEBUG("Action %p finished", action);
-      action->m_remains = 0;
-      action->m_finish = surf_get_clock();
+      action->setRemains(0);
+      action->finish();
       action->setState(SURF_ACTION_DONE);
       action->heapRemove(p_actionHeap);
 
       action->setState(SURF_ACTION_DONE);
       action->heapRemove(p_actionHeap);
 
@@ -387,7 +386,7 @@ ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEdgePtr dst,
 
   xbt_dynar_foreach(route, i, _link) {
        link = dynamic_cast<NetworkCm02LinkLmmPtr>(static_cast<ResourcePtr>(_link));
 
   xbt_dynar_foreach(route, i, _link) {
        link = dynamic_cast<NetworkCm02LinkLmmPtr>(static_cast<ResourcePtr>(_link));
-    if (link->p_stateCurrent == SURF_RESOURCE_OFF) {
+    if (link->getState() == SURF_RESOURCE_OFF) {
       failed = 1;
       break;
     }
       failed = 1;
       break;
     }
@@ -396,7 +395,7 @@ ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEdgePtr dst,
          routing_platf->getRouteAndLatency(dst, src, &back_route, NULL);
     xbt_dynar_foreach(back_route, i, _link) {
       link = dynamic_cast<NetworkCm02LinkLmmPtr>(static_cast<ResourcePtr>(_link));
          routing_platf->getRouteAndLatency(dst, src, &back_route, NULL);
     xbt_dynar_foreach(back_route, i, _link) {
       link = dynamic_cast<NetworkCm02LinkLmmPtr>(static_cast<ResourcePtr>(_link));
-      if (link->p_stateCurrent == SURF_RESOURCE_OFF) {
+      if (link->getState() == SURF_RESOURCE_OFF) {
         failed = 1;
         break;
       }
         failed = 1;
         break;
       }
@@ -421,14 +420,12 @@ ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEdgePtr dst,
   if (sg_weight_S_parameter > 0) {
     xbt_dynar_foreach(route, i, _link) {
       link = dynamic_cast<NetworkCm02LinkLmmPtr>(static_cast<ResourcePtr>(_link));
   if (sg_weight_S_parameter > 0) {
     xbt_dynar_foreach(route, i, _link) {
       link = dynamic_cast<NetworkCm02LinkLmmPtr>(static_cast<ResourcePtr>(_link));
-      action->m_weight +=
-         sg_weight_S_parameter /
-         (link->p_power.peak * link->p_power.scale);
+      action->m_weight += sg_weight_S_parameter / link->getBandwidth();
     }
   }
   xbt_dynar_foreach(route, i, _link) {
        link = dynamic_cast<NetworkCm02LinkLmmPtr>(static_cast<ResourcePtr>(_link));
     }
   }
   xbt_dynar_foreach(route, i, _link) {
        link = dynamic_cast<NetworkCm02LinkLmmPtr>(static_cast<ResourcePtr>(_link));
-    double bb = bandwidthFactor(size) * (link->p_power.peak * link->p_power.scale);
+    double bb = bandwidthFactor(size) * link->getBandwidth(); //(link->p_power.peak * link->p_power.scale);
     bandwidth_bound =
         (bandwidth_bound < 0.0) ? bb : min(bandwidth_bound, bb);
   }
     bandwidth_bound =
         (bandwidth_bound < 0.0) ? bb : min(bandwidth_bound, bb);
   }
@@ -465,21 +462,21 @@ ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEdgePtr dst,
     action->p_variable = lmm_variable_new(p_maxminSystem, action, 1.0, -1.0, constraints_per_variable);
 
   if (action->m_rate < 0) {
     action->p_variable = lmm_variable_new(p_maxminSystem, action, 1.0, -1.0, constraints_per_variable);
 
   if (action->m_rate < 0) {
-    lmm_update_variable_bound(p_maxminSystem, action->p_variable, (action->m_latCurrent > 0) ? sg_tcp_gamma / (2.0 * action->m_latCurrent) : -1.0);
+    lmm_update_variable_bound(p_maxminSystem, action->getVariable(), (action->m_latCurrent > 0) ? sg_tcp_gamma / (2.0 * action->m_latCurrent) : -1.0);
   } else {
   } else {
-    lmm_update_variable_bound(p_maxminSystem, action->p_variable, (action->m_latCurrent > 0) ? min(action->m_rate, sg_tcp_gamma / (2.0 * action->m_latCurrent)) : action->m_rate);
+    lmm_update_variable_bound(p_maxminSystem, action->getVariable(), (action->m_latCurrent > 0) ? min(action->m_rate, sg_tcp_gamma / (2.0 * action->m_latCurrent)) : action->m_rate);
   }
 
   xbt_dynar_foreach(route, i, _link) {
        link = dynamic_cast<NetworkCm02LinkLmmPtr>(static_cast<ResourcePtr>(_link));
   }
 
   xbt_dynar_foreach(route, i, _link) {
        link = dynamic_cast<NetworkCm02LinkLmmPtr>(static_cast<ResourcePtr>(_link));
-    lmm_expand(p_maxminSystem, link->p_constraint, action->p_variable, 1.0);
+    lmm_expand(p_maxminSystem, link->constraint(), action->getVariable(), 1.0);
   }
 
   if (sg_network_crosstraffic == 1) {
     XBT_DEBUG("Fullduplex active adding backward flow using 5%%");
     xbt_dynar_foreach(back_route, i, _link) {
       link = dynamic_cast<NetworkCm02LinkLmmPtr>(static_cast<ResourcePtr>(_link));
   }
 
   if (sg_network_crosstraffic == 1) {
     XBT_DEBUG("Fullduplex active adding backward flow using 5%%");
     xbt_dynar_foreach(back_route, i, _link) {
       link = dynamic_cast<NetworkCm02LinkLmmPtr>(static_cast<ResourcePtr>(_link));
-      lmm_expand(p_maxminSystem, link->p_constraint, action->p_variable, .05);
+      lmm_expand(p_maxminSystem, link->constraint(), action->getVariable(), .05);
     }
   }
 
     }
   }
 
@@ -506,14 +503,23 @@ NetworkCm02LinkLmm::NetworkCm02LinkLmm(NetworkCm02ModelPtr model, const char *na
                                   tmgr_trace_t lat_trace,
                                   e_surf_link_sharing_policy_t policy)
 : Resource(model, name, props),
                                   tmgr_trace_t lat_trace,
                                   e_surf_link_sharing_policy_t policy)
 : Resource(model, name, props),
-  NetworkLinkLmm(system, constraint_value, history, state_init, state_trace, metric_peak, metric_trace)
+  NetworkLinkLmm(lmm_constraint_new(system, this, constraint_value), history, state_trace)
 {
 {
+  m_stateCurrent = state_init;
+
+  p_power.scale = 1.0;
+  p_power.peak = metric_peak;
+  if (metric_trace)
+    p_power.event = tmgr_history_add_trace(history, metric_trace, 0.0, 0, static_cast<ResourcePtr>(this));
+  else
+    p_power.event = NULL;
+
   m_latCurrent = lat_initial;
   if (lat_trace)
        p_latEvent = tmgr_history_add_trace(history, lat_trace, 0.0, 0, static_cast<ResourcePtr>(this));
 
   if (policy == SURF_LINK_FATPIPE)
   m_latCurrent = lat_initial;
   if (lat_trace)
        p_latEvent = tmgr_history_add_trace(history, lat_trace, 0.0, 0, static_cast<ResourcePtr>(this));
 
   if (policy == SURF_LINK_FATPIPE)
-       lmm_constraint_shared(p_constraint);
+       lmm_constraint_shared(constraint());
 }
 
 
 }
 
 
@@ -534,19 +540,19 @@ void NetworkCm02LinkLmm::updateState(tmgr_trace_event_t event_type,
     NetworkCm02ActionLmmPtr action = NULL;
 
     p_power.peak = value;
     NetworkCm02ActionLmmPtr action = NULL;
 
     p_power.peak = value;
-    lmm_update_constraint_bound(p_model->p_maxminSystem,
-                                p_constraint,
+    lmm_update_constraint_bound(getModel()->getMaxminSystem(),
+                                constraint(),
                                 sg_bandwidth_factor *
                                 (p_power.peak * p_power.scale));
 #ifdef HAVE_TRACING
                                 sg_bandwidth_factor *
                                 (p_power.peak * p_power.scale));
 #ifdef HAVE_TRACING
-    TRACE_surf_link_set_bandwidth(date, m_name, sg_bandwidth_factor * p_power.peak * p_power.scale);
+    TRACE_surf_link_set_bandwidth(date, getName(), sg_bandwidth_factor * p_power.peak * p_power.scale);
 #endif
     if (sg_weight_S_parameter > 0) {
 #endif
     if (sg_weight_S_parameter > 0) {
-      while ((var = lmm_get_var_from_cnst(p_model->p_maxminSystem, p_constraint, &elem))) {
+      while ((var = lmm_get_var_from_cnst(getModel()->getMaxminSystem(), constraint(), &elem))) {
         action = (NetworkCm02ActionLmmPtr) lmm_variable_id(var);
         action->m_weight += delta;
         action = (NetworkCm02ActionLmmPtr) lmm_variable_id(var);
         action->m_weight += delta;
-        if (!action->m_suspended)
-          lmm_update_variable_weight(p_model->p_maxminSystem, action->p_variable, action->m_weight);
+        if (!action->isSuspended())
+          lmm_update_variable_weight(getModel()->getMaxminSystem(), action->getVariable(), action->m_weight);
       }
     }
     if (tmgr_trace_event_free(event_type))
       }
     }
     if (tmgr_trace_event_free(event_type))
@@ -558,14 +564,14 @@ void NetworkCm02LinkLmm::updateState(tmgr_trace_event_t event_type,
     NetworkCm02ActionLmmPtr action = NULL;
 
     m_latCurrent = value;
     NetworkCm02ActionLmmPtr action = NULL;
 
     m_latCurrent = value;
-    while ((var = lmm_get_var_from_cnst(p_model->p_maxminSystem, p_constraint, &elem))) {
+    while ((var = lmm_get_var_from_cnst(getModel()->getMaxminSystem(), constraint(), &elem))) {
       action = (NetworkCm02ActionLmmPtr) lmm_variable_id(var);
       action->m_latCurrent += delta;
       action->m_weight += delta;
       if (action->m_rate < 0)
       action = (NetworkCm02ActionLmmPtr) lmm_variable_id(var);
       action->m_latCurrent += delta;
       action->m_weight += delta;
       if (action->m_rate < 0)
-        lmm_update_variable_bound(p_model->p_maxminSystem, action->p_variable, sg_tcp_gamma / (2.0 * action->m_latCurrent));
+        lmm_update_variable_bound(getModel()->getMaxminSystem(), action->getVariable(), sg_tcp_gamma / (2.0 * action->m_latCurrent));
       else {
       else {
-        lmm_update_variable_bound(p_model->p_maxminSystem, action->p_variable,
+        lmm_update_variable_bound(getModel()->getMaxminSystem(), action->getVariable(),
                                   min(action->m_rate, sg_tcp_gamma / (2.0 * action->m_latCurrent)));
 
         if (action->m_rate < sg_tcp_gamma / (2.0 * action->m_latCurrent)) {
                                   min(action->m_rate, sg_tcp_gamma / (2.0 * action->m_latCurrent)));
 
         if (action->m_rate < sg_tcp_gamma / (2.0 * action->m_latCurrent)) {
@@ -575,27 +581,27 @@ void NetworkCm02LinkLmm::updateState(tmgr_trace_event_t event_type,
                    action->m_latCurrent);
         }
       }
                    action->m_latCurrent);
         }
       }
-      if (!action->m_suspended)
-        lmm_update_variable_weight(p_model->p_maxminSystem, action->p_variable, action->m_weight);
+      if (!action->isSuspended())
+        lmm_update_variable_weight(getModel()->getMaxminSystem(), action->getVariable(), action->m_weight);
 
     }
     if (tmgr_trace_event_free(event_type))
       p_latEvent = NULL;
   } else if (event_type == p_stateEvent) {
     if (value > 0)
 
     }
     if (tmgr_trace_event_free(event_type))
       p_latEvent = NULL;
   } else if (event_type == p_stateEvent) {
     if (value > 0)
-      p_stateCurrent = SURF_RESOURCE_ON;
+      m_stateCurrent = SURF_RESOURCE_ON;
     else {
     else {
-      lmm_constraint_t cnst = p_constraint;
+      lmm_constraint_t cnst = constraint();
       lmm_variable_t var = NULL;
       lmm_element_t elem = NULL;
 
       lmm_variable_t var = NULL;
       lmm_element_t elem = NULL;
 
-      p_stateCurrent = SURF_RESOURCE_OFF;
-      while ((var = lmm_get_var_from_cnst(p_model->p_maxminSystem, cnst, &elem))) {
+      m_stateCurrent = SURF_RESOURCE_OFF;
+      while ((var = lmm_get_var_from_cnst(getModel()->getMaxminSystem(), cnst, &elem))) {
         ActionPtr action = (ActionPtr) lmm_variable_id(var);
 
         if (action->getState() == SURF_ACTION_RUNNING ||
             action->getState() == SURF_ACTION_READY) {
         ActionPtr action = (ActionPtr) lmm_variable_id(var);
 
         if (action->getState() == SURF_ACTION_RUNNING ||
             action->getState() == SURF_ACTION_READY) {
-          action->m_finish = date;
+          action->setFinishTime(date);
           action->setState(SURF_ACTION_FAILED);
         }
       }
           action->setState(SURF_ACTION_FAILED);
         }
       }
@@ -609,7 +615,7 @@ void NetworkCm02LinkLmm::updateState(tmgr_trace_event_t event_type,
 
   XBT_DEBUG
       ("There were a resource state event, need to update actions related to the constraint (%p)",
 
   XBT_DEBUG
       ("There were a resource state event, need to update actions related to the constraint (%p)",
-       p_constraint);
+       constraint());
   return;
 }
 
   return;
 }
 
@@ -636,20 +642,20 @@ void NetworkCm02ActionLmm::updateRemainingLazy(double now)
     double_update(&m_maxDuration, delta);
 
   if (m_remains <= 0 &&
     double_update(&m_maxDuration, delta);
 
   if (m_remains <= 0 &&
-      (lmm_get_variable_weight(p_variable) > 0)) {
-    m_finish = surf_get_clock();
+      (lmm_get_variable_weight(getVariable()) > 0)) {
+    finish();
     setState(SURF_ACTION_DONE);
 
     setState(SURF_ACTION_DONE);
 
-    heapRemove(p_model->p_actionHeap);
+    heapRemove(getModel()->getActionHeap());
   } else if (((m_maxDuration != NO_MAX_DURATION)
       && (m_maxDuration <= 0))) {
   } else if (((m_maxDuration != NO_MAX_DURATION)
       && (m_maxDuration <= 0))) {
-    m_finish = surf_get_clock();
+    finish();
     setState(SURF_ACTION_DONE);
     setState(SURF_ACTION_DONE);
-    heapRemove(p_model->p_actionHeap);
+    heapRemove(getModel()->getActionHeap());
   }
 
   m_lastUpdate = now;
   }
 
   m_lastUpdate = now;
-  m_lastValue = lmm_variable_getvalue(p_variable);
+  m_lastValue = lmm_variable_getvalue(getVariable());
 }
 void NetworkCm02ActionLmm::recycle()
 {
 }
 void NetworkCm02ActionLmm::recycle()
 {
index fe939b6..67a2085 100644 (file)
@@ -34,7 +34,7 @@ public:
        f_networkSolve = lmm_solve;
        m_haveGap = false;
   };//FIXME: add network clean interface
        f_networkSolve = lmm_solve;
        m_haveGap = false;
   };//FIXME: add network clean interface
-  NetworkCm02Model(string name) : NetworkModel(name) {
+  NetworkCm02Model(const char *name) : NetworkModel(name) {
     this->initialize();
   }
   NetworkCm02Model() : NetworkModel("network") {
     this->initialize();
   }
   NetworkCm02Model() : NetworkModel("network") {
@@ -82,6 +82,8 @@ public:
  **********/
 
 class NetworkCm02ActionLmm : public NetworkActionLmm {
  **********/
 
 class NetworkCm02ActionLmm : public NetworkActionLmm {
+  friend ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEdgePtr dst, double size, double rate);
+
 public:
   NetworkCm02ActionLmm(ModelPtr model, double cost, bool failed)
  : Action(model, cost, failed) {};
 public:
   NetworkCm02ActionLmm(ModelPtr model, double cost, bool failed)
  : Action(model, cost, failed) {};
index 00d100a..ce29ef0 100644 (file)
@@ -28,7 +28,8 @@ double NetworkConstantModel::shareResources(double /*now*/)
   NetworkConstantActionLmmPtr action = NULL;
   double min = -1.0;
 
   NetworkConstantActionLmmPtr action = NULL;
   double min = -1.0;
 
-  xbt_swag_foreach(_action, p_runningActionSet) {
+  xbt_swag_t actionSet = getRunningActionSet();
+  xbt_swag_foreach(_action, actionSet) {
        action = dynamic_cast<NetworkConstantActionLmmPtr>(static_cast<ActionPtr>(_action));
     if (action->m_latency > 0) {
       if (min < 0)
        action = dynamic_cast<NetworkConstantActionLmmPtr>(static_cast<ActionPtr>(_action));
     if (action->m_latency > 0) {
       if (min < 0)
@@ -45,8 +46,8 @@ void NetworkConstantModel::updateActionsState(double /*now*/, double delta)
 {
   void *_action, *_next_action;
   NetworkConstantActionLmmPtr action = NULL;
 {
   void *_action, *_next_action;
   NetworkConstantActionLmmPtr action = NULL;
-
-  xbt_swag_foreach_safe(_action, _next_action, p_runningActionSet) {
+  xbt_swag_t actionSet = getRunningActionSet();
+  xbt_swag_foreach_safe(_action, _next_action, actionSet) {
        action = dynamic_cast<NetworkConstantActionLmmPtr>(static_cast<ActionPtr>(_action));
     if (action->m_latency > 0) {
       if (action->m_latency > delta) {
        action = dynamic_cast<NetworkConstantActionLmmPtr>(static_cast<ActionPtr>(_action));
     if (action->m_latency > 0) {
       if (action->m_latency > delta) {
@@ -55,17 +56,16 @@ void NetworkConstantModel::updateActionsState(double /*now*/, double delta)
         action->m_latency = 0.0;
       }
     }
         action->m_latency = 0.0;
       }
     }
-    double_update(&(action->m_remains),
-                  action->m_cost * delta / action->m_latInit);
-    if (action->m_maxDuration != NO_MAX_DURATION)
-      double_update(&(action->m_maxDuration), delta);
+    action->updateRemains(action->getCost() * delta / action->m_latInit);
+    if (action->getMaxDuration() != NO_MAX_DURATION)
+      action->updateMaxDuration(delta);
 
 
-    if (action->m_remains <= 0) {
-      action->m_finish = surf_get_clock();
+    if (action->getRemains() <= 0) {
+      action->finish();
       action->setState(SURF_ACTION_DONE);
       action->setState(SURF_ACTION_DONE);
-    } else if ((action->m_maxDuration != NO_MAX_DURATION)
-               && (action->m_maxDuration <= 0)) {
-      action->m_finish = surf_get_clock();
+    } else if ((action->getMaxDuration() != NO_MAX_DURATION)
+               && (action->getMaxDuration() <= 0)) {
+      action->finish();
       action->setState(SURF_ACTION_DONE);
     }
   }
       action->setState(SURF_ACTION_DONE);
     }
   }
index 30958fd..9847795 100644 (file)
@@ -47,11 +47,11 @@ public:
  **********/
 class NetworkConstantActionLmm : public NetworkCm02ActionLmm {
 public:
  **********/
 class NetworkConstantActionLmm : public NetworkCm02ActionLmm {
 public:
-  NetworkConstantActionLmm(NetworkConstantModelPtr model, double size, double latency):
-         Action(model, size, false), NetworkCm02ActionLmm(model, 0, false), m_latInit(latency) {
+  NetworkConstantActionLmm(NetworkConstantModelPtr model_, double size, double latency):
+         Action(model_, size, false), NetworkCm02ActionLmm(model_, 0, false), m_latInit(latency) {
        m_latency = latency;
        if (m_latency <= 0.0) {
        m_latency = latency;
        if (m_latency <= 0.0) {
-         p_stateSet = p_model->p_doneActionSet;
+         p_stateSet = getModel()->getDoneActionSet();
          xbt_swag_insert(static_cast<ActionPtr>(this), p_stateSet);
        }
   };
          xbt_swag_insert(static_cast<ActionPtr>(this), p_stateSet);
        }
   };
index a7767aa..6bc4328 100644 (file)
@@ -34,9 +34,18 @@ double NetworkModel::bandwidthConstraint(double rate, double /*bound*/, double /
   return rate;
 }
 
   return rate;
 }
 
+NetworkLinkLmm::NetworkLinkLmm(lmm_constraint_t constraint,
+                                  tmgr_history_t history,
+                                  tmgr_trace_t state_trace)
+: ResourceLmm(constraint)
+{
+  if (state_trace)
+    p_stateEvent = tmgr_history_add_trace(history, state_trace, 0.0, 0, static_cast<ResourcePtr>(this));
+}
+
 bool NetworkLinkLmm::isUsed()
 {
 bool NetworkLinkLmm::isUsed()
 {
-  return lmm_constraint_used(p_model->p_maxminSystem, p_constraint);
+  return lmm_constraint_used(getModel()->getMaxminSystem(), constraint());
 }
 
 double NetworkLink::getLatency()
 }
 
 double NetworkLink::getLatency()
@@ -51,7 +60,7 @@ double NetworkLinkLmm::getBandwidth()
 
 bool NetworkLinkLmm::isShared()
 {
 
 bool NetworkLinkLmm::isShared()
 {
-  return lmm_constraint_is_shared(p_constraint);
+  return lmm_constraint_is_shared(constraint());
 }
 
 #endif /* NETWORK_INTERFACE_CPP_ */
 }
 
 #endif /* NETWORK_INTERFACE_CPP_ */
index 81ebd14..bd5543f 100644 (file)
@@ -41,7 +41,7 @@ class NetworkModel : public Model {
 public:
   NetworkModel() : Model("network") {
   };
 public:
   NetworkModel() : Model("network") {
   };
-  NetworkModel(string name) : Model(name) {
+  NetworkModel(const char *name) : Model(name) {
        f_networkSolve = lmm_solve;
        m_haveGap = false;
   };
        f_networkSolve = lmm_solve;
        m_haveGap = false;
   };
@@ -94,21 +94,15 @@ public:
 };
 
 class NetworkLinkLmm : public ResourceLmm, public NetworkLink {
 };
 
 class NetworkLinkLmm : public ResourceLmm, public NetworkLink {
+protected:
 public:
   NetworkLinkLmm() {};
 public:
   NetworkLinkLmm() {};
-  NetworkLinkLmm(lmm_system_t system,
-                    double constraint_value,
-                    tmgr_history_t history,
-                    e_surf_resource_state_t state_init,
-                    tmgr_trace_t state_trace,
-                    double metric_peak,
-                    tmgr_trace_t metric_trace)
- : ResourceLmm(system, constraint_value, history, state_init, state_trace, metric_peak, metric_trace)
-{
-}
+  NetworkLinkLmm(lmm_constraint_t constraint, tmgr_history_t history, tmgr_trace_t state_trace);
   bool isShared();
   bool isUsed();
   double getBandwidth();
   bool isShared();
   bool isUsed();
   double getBandwidth();
+  tmgr_trace_event_t p_stateEvent;
+  s_surf_metric_t p_power;
 };
 
 /**********
 };
 
 /**********
index 6d52fc7..a023019 100644 (file)
@@ -101,7 +101,7 @@ NetworkSmpiModel::~NetworkSmpiModel(){
 
 void NetworkSmpiModel::gapAppend(double size, const NetworkLinkLmmPtr link, NetworkActionLmmPtr action)
 {
 
 void NetworkSmpiModel::gapAppend(double size, const NetworkLinkLmmPtr link, NetworkActionLmmPtr action)
 {
-  const char *src = link->m_name;
+  const char *src = link->getName();
   xbt_fifo_t fifo;
   //surf_action_network_CM02_t last_action;
   //double bw;
   xbt_fifo_t fifo;
   //surf_action_network_CM02_t last_action;
   //double bw;
index 43b07fd..dd50e5a 100644 (file)
@@ -39,7 +39,7 @@ Storage::Storage(const char* type_id, char *content_name, char *content_type, sg
    m_size(size), m_usedSize(0), p_typeId(xbt_strdup(type_id)), p_writeActions(xbt_dynar_new(sizeof(ActionPtr),NULL))
 {
   p_content = parseContent(content_name);
    m_size(size), m_usedSize(0), p_typeId(xbt_strdup(type_id)), p_writeActions(xbt_dynar_new(sizeof(ActionPtr),NULL))
 {
   p_content = parseContent(content_name);
-  p_stateCurrent = SURF_RESOURCE_ON;
+  m_stateCurrent = SURF_RESOURCE_ON;
 }
 
 Storage::~Storage(){
 }
 
 Storage::~Storage(){
@@ -119,10 +119,8 @@ sg_size_t Storage::getSize(){
 
 StorageLmm::StorageLmm(lmm_system_t maxminSystem, double bread, double bwrite, double bconnection,
             const char* type_id, char *content_name, char *content_type, sg_size_t size)
 
 StorageLmm::StorageLmm(lmm_system_t maxminSystem, double bread, double bwrite, double bconnection,
             const char* type_id, char *content_name, char *content_type, sg_size_t size)
- :  ResourceLmm(), Storage(type_id, content_name, content_type, size) {
+ :  ResourceLmm(lmm_constraint_new(maxminSystem, this, bconnection)), Storage(type_id, content_name, content_type, size) {
   XBT_DEBUG("Create resource with Bconnection '%f' Bread '%f' Bwrite '%f' and Size '%llu'", bconnection, bread, bwrite, size);
   XBT_DEBUG("Create resource with Bconnection '%f' Bread '%f' Bwrite '%f' and Size '%llu'", bconnection, bread, bwrite, size);
-
-  p_constraint = lmm_constraint_new(maxminSystem, this, bconnection);
   p_constraintRead  = lmm_constraint_new(maxminSystem, this, bread);
   p_constraintWrite = lmm_constraint_new(maxminSystem, this, bwrite);
 }
   p_constraintRead  = lmm_constraint_new(maxminSystem, this, bread);
   p_constraintWrite = lmm_constraint_new(maxminSystem, this, bwrite);
 }
@@ -135,7 +133,7 @@ StorageAction::StorageAction(StoragePtr storage, e_surf_action_storage_type_t ty
 {
 };
 
 {
 };
 
-StorageActionLmm::StorageActionLmm(StorageLmmPtr storage, e_surf_action_storage_type_t type)
-  : StorageAction(storage, type) {
+StorageActionLmm::StorageActionLmm(StorageLmmPtr storage, e_surf_action_storage_type_t type, lmm_variable_t var)
+  : StorageAction(storage, type), ActionLmm(var) {
 }
 
 }
 
index 9319dc5..634bd94 100644 (file)
@@ -104,7 +104,7 @@ class StorageActionLmm : public ActionLmm, public StorageAction {
 public:
   StorageActionLmm() {};//FIXME:REMOVE
 
 public:
   StorageActionLmm() {};//FIXME:REMOVE
 
-  StorageActionLmm(StorageLmmPtr storage, e_surf_action_storage_type_t type);
+  StorageActionLmm(StorageLmmPtr storage, e_surf_action_storage_type_t type, lmm_variable_t var);
 };
 
 typedef struct s_storage_type {
 };
 
 typedef struct s_storage_type {
index 600cca1..b0d0683 100644 (file)
@@ -210,13 +210,12 @@ void surf_storage_model_init_default(void)
 }
 
 StorageN11Model::StorageN11Model() : StorageModel() {
 }
 
 StorageN11Model::StorageN11Model() : StorageModel() {
-  StorageN11ActionLmm action;
+  ActionPtr action = NULL;
 
   XBT_DEBUG("surf_storage_model_init_internal");
 
   storage_running_action_set_that_does_not_need_being_checked =
 
   XBT_DEBUG("surf_storage_model_init_internal");
 
   storage_running_action_set_that_does_not_need_being_checked =
-      xbt_swag_new(xbt_swag_offset(action, p_stateHookup));
-
+      xbt_swag_new(xbt_swag_offset(*action, p_stateHookup));
   if (!p_maxminSystem) {
     p_maxminSystem = lmm_system_new(storage_selective_update);
   }
   if (!p_maxminSystem) {
     p_maxminSystem = lmm_system_new(storage_selective_update);
   }
@@ -268,7 +267,7 @@ double StorageN11Model::shareResources(double now)
   void *_write_action;
   StorageActionLmmPtr write_action;
 
   void *_write_action;
   StorageActionLmmPtr write_action;
 
-  double min_completion = shareResourcesMaxMin(p_runningActionSet,
+  double min_completion = shareResourcesMaxMin(getRunningActionSet(),
       p_maxminSystem, lmm_solve);
 
   double rate;
       p_maxminSystem, lmm_solve);
 
   double rate;
@@ -280,7 +279,7 @@ double StorageN11Model::shareResources(double now)
     xbt_dynar_foreach(storage->p_writeActions, j, _write_action)
     {
       write_action = dynamic_cast<StorageActionLmmPtr>(static_cast<ActionPtr>(_write_action));
     xbt_dynar_foreach(storage->p_writeActions, j, _write_action)
     {
       write_action = dynamic_cast<StorageActionLmmPtr>(static_cast<ActionPtr>(_write_action));
-      rate += lmm_variable_getvalue(write_action->p_variable);
+      rate += lmm_variable_getvalue(write_action->getVariable());
     }
     if(rate > 0)
       min_completion = MIN(min_completion, (storage->m_size-storage->m_usedSize)/rate);
     }
     if(rate > 0)
       min_completion = MIN(min_completion, (storage->m_size-storage->m_usedSize)/rate);
@@ -294,14 +293,15 @@ void StorageN11Model::updateActionsState(double /*now*/, double delta)
   void *_action, *_next_action;
   StorageActionLmmPtr action = NULL;
 
   void *_action, *_next_action;
   StorageActionLmmPtr action = NULL;
 
-  xbt_swag_foreach_safe(_action, _next_action, p_runningActionSet) {
+  xbt_swag_t actionSet = getRunningActionSet();
+  xbt_swag_foreach_safe(_action, _next_action, actionSet) {
        action = dynamic_cast<StorageActionLmmPtr>(static_cast<ActionPtr>(_action));
     if(action->m_type == WRITE)
     {
       // Update the disk usage
      // Update the file size
      // For each action of type write
        action = dynamic_cast<StorageActionLmmPtr>(static_cast<ActionPtr>(_action));
     if(action->m_type == WRITE)
     {
       // Update the disk usage
      // Update the file size
      // For each action of type write
-      double rate = lmm_variable_getvalue(action->p_variable);
+      double rate = lmm_variable_getvalue(action->getVariable());
       /* Hack to avoid rounding differences between x86 and x86_64
        * (note that the next sizes are of type sg_size_t). */
       long incr = delta * rate + MAXMIN_PRECISION;
       /* Hack to avoid rounding differences between x86 and x86_64
        * (note that the next sizes are of type sg_size_t). */
       long incr = delta * rate + MAXMIN_PRECISION;
@@ -315,27 +315,26 @@ void StorageN11Model::updateActionsState(double /*now*/, double delta)
       xbt_dict_set(content_dict, action->p_file->name, psize, NULL);
     }
 
       xbt_dict_set(content_dict, action->p_file->name, psize, NULL);
     }
 
-    double_update(&action->m_remains,
-                  lmm_variable_getvalue(action->p_variable) * delta);
+    action->updateRemains(lmm_variable_getvalue(action->getVariable()) * delta);
 
 
-    if (action->m_maxDuration != NO_MAX_DURATION)
-      double_update(&action->m_maxDuration, delta);
+    if (action->getMaxDuration() != NO_MAX_DURATION)
+      action->updateMaxDuration(delta);
 
 
-    if(action->m_remains > 0 &&
-        lmm_get_variable_weight(action->p_variable) > 0 &&
+    if(action->getRemains() > 0 &&
+        lmm_get_variable_weight(action->getVariable()) > 0 &&
         action->p_storage->m_usedSize == action->p_storage->m_size)
     {
         action->p_storage->m_usedSize == action->p_storage->m_size)
     {
-      action->m_finish = surf_get_clock();
+      action->finish();
       action->setState(SURF_ACTION_FAILED);
       action->setState(SURF_ACTION_FAILED);
-    } else if ((action->m_remains <= 0) &&
-        (lmm_get_variable_weight(action->p_variable) > 0))
+    } else if ((action->getRemains() <= 0) &&
+        (lmm_get_variable_weight(action->getVariable()) > 0))
     {
     {
-      action->m_finish = surf_get_clock();
+      action->finish();
       action->setState(SURF_ACTION_DONE);
       action->setState(SURF_ACTION_DONE);
-    } else if ((action->m_maxDuration != NO_MAX_DURATION) &&
-               (action->m_maxDuration <= 0))
+    } else if ((action->getMaxDuration() != NO_MAX_DURATION) &&
+               (action->getMaxDuration() <= 0))
     {
     {
-      action->m_finish = surf_get_clock();
+      action->finish();
       action->setState(SURF_ACTION_DONE);
     }
   }
       action->setState(SURF_ACTION_DONE);
     }
   }
@@ -353,15 +352,11 @@ StorageN11Lmm::StorageN11Lmm(StorageModelPtr model, const char* name, xbt_dict_t
  :  Resource(model, name, properties),
     StorageLmm(maxminSystem, bread, bwrite, bconnection, type_id, content_name, content_type, size) {
   XBT_DEBUG("Create resource with Bconnection '%f' Bread '%f' Bwrite '%f' and Size '%llu'", bconnection, bread, bwrite, size);
  :  Resource(model, name, properties),
     StorageLmm(maxminSystem, bread, bwrite, bconnection, type_id, content_name, content_type, size) {
   XBT_DEBUG("Create resource with Bconnection '%f' Bread '%f' Bwrite '%f' and Size '%llu'", bconnection, bread, bwrite, size);
-
-  p_constraint = lmm_constraint_new(maxminSystem, this, bconnection);
-  p_constraintRead  = lmm_constraint_new(maxminSystem, this, bread);
-  p_constraintWrite = lmm_constraint_new(maxminSystem, this, bwrite);
 }
 
 StorageActionPtr StorageN11Lmm::ls(const char* path)
 {
 }
 
 StorageActionPtr StorageN11Lmm::ls(const char* path)
 {
-  StorageActionLmmPtr action = new StorageN11ActionLmm(p_model, 0, p_stateCurrent != SURF_RESOURCE_ON, this, LS);
+  StorageActionLmmPtr action = new StorageN11ActionLmm(getModel(), 0, m_stateCurrent != SURF_RESOURCE_ON, this, LS);
 
   action->p_lsDict = NULL;
   xbt_dict_t ls_dict = xbt_dict_new_homogeneous(xbt_free);
 
   action->p_lsDict = NULL;
   xbt_dict_t ls_dict = xbt_dict_new_homogeneous(xbt_free);
@@ -425,7 +420,7 @@ StorageActionPtr StorageN11Lmm::open(const char* mount, const char* path)
   file->mount = xbt_strdup(mount);
   file->current_position = 0;
 
   file->mount = xbt_strdup(mount);
   file->current_position = 0;
 
-  StorageActionLmmPtr action = new StorageN11ActionLmm(p_model, 0, p_stateCurrent != SURF_RESOURCE_ON, this, OPEN);
+  StorageActionLmmPtr action = new StorageN11ActionLmm(getModel(), 0, m_stateCurrent != SURF_RESOURCE_ON, this, OPEN);
   action->p_file = file;
   return action;
 }
   action->p_file = file;
   return action;
 }
@@ -448,7 +443,7 @@ StorageActionPtr StorageN11Lmm::close(surf_file_t fd)
   free(fd->name);
   free(fd->mount);
   xbt_free(fd);
   free(fd->name);
   free(fd->mount);
   xbt_free(fd);
-  StorageActionLmmPtr action = new StorageN11ActionLmm(p_model, 0, p_stateCurrent != SURF_RESOURCE_ON, this, CLOSE);
+  StorageActionLmmPtr action = new StorageN11ActionLmm(getModel(), 0, m_stateCurrent != SURF_RESOURCE_ON, this, CLOSE);
   return action;
 }
 
   return action;
 }
 
@@ -461,7 +456,7 @@ StorageActionPtr StorageN11Lmm::read(surf_file_t fd, sg_size_t size)
   else
        fd->current_position += size;
 
   else
        fd->current_position += size;
 
-  StorageActionLmmPtr action = new StorageN11ActionLmm(p_model, size, p_stateCurrent != SURF_RESOURCE_ON, this, READ);
+  StorageActionLmmPtr action = new StorageN11ActionLmm(getModel(), size, m_stateCurrent != SURF_RESOURCE_ON, this, READ);
   return action;
 }
 
   return action;
 }
 
@@ -470,7 +465,7 @@ StorageActionPtr StorageN11Lmm::write(surf_file_t fd, sg_size_t size)
   char *filename = fd->name;
   XBT_DEBUG("\tWrite file '%s' size '%llu/%llu'",filename,size,fd->size);
 
   char *filename = fd->name;
   XBT_DEBUG("\tWrite file '%s' size '%llu/%llu'",filename,size,fd->size);
 
-  StorageActionLmmPtr action = new StorageN11ActionLmm(p_model, size, p_stateCurrent != SURF_RESOURCE_ON, this, WRITE);
+  StorageActionLmmPtr action = new StorageN11ActionLmm(getModel(), size, m_stateCurrent != SURF_RESOURCE_ON, this, WRITE);
   action->p_file = fd;
   fd->current_position += size;
   // If the storage is full
   action->p_file = fd;
   fd->current_position += size;
   // If the storage is full
@@ -519,14 +514,13 @@ sg_size_t StorageN11Lmm::getSize(){
  * Action *
  **********/
 
  * Action *
  **********/
 
-StorageN11ActionLmm::StorageN11ActionLmm(ModelPtr model, double cost, bool failed, StorageLmmPtr storage, e_surf_action_storage_type_t type)
-  : Action(model, cost, failed),
-    StorageActionLmm(storage, type) {
-  XBT_IN("(%s,%g", storage->m_name, cost);
-  p_variable = lmm_variable_new(p_model->p_maxminSystem, this, 1.0, -1.0 , 3);
+StorageN11ActionLmm::StorageN11ActionLmm(ModelPtr model_, double cost, bool failed, StorageLmmPtr storage, e_surf_action_storage_type_t type)
+  : Action(model_, cost, failed),
+    StorageActionLmm(storage, type, lmm_variable_new(getModel()->getMaxminSystem(), this, 1.0, -1.0 , 3)) {
+  XBT_IN("(%s,%g", storage->getName(), cost);
 
   // Must be less than the max bandwidth for all actions
 
   // Must be less than the max bandwidth for all actions
-  lmm_expand(p_model->p_maxminSystem, storage->p_constraint, p_variable, 1.0);
+  lmm_expand(getModel()->getMaxminSystem(), storage->constraint(), getVariable(), 1.0);
   switch(type) {
   case OPEN:
   case CLOSE:
   switch(type) {
   case OPEN:
   case CLOSE:
@@ -534,12 +528,12 @@ StorageN11ActionLmm::StorageN11ActionLmm(ModelPtr model, double cost, bool faile
   case LS:
     break;
   case READ:
   case LS:
     break;
   case READ:
-    lmm_expand(p_model->p_maxminSystem, storage->p_constraintRead,
-               p_variable, 1.0);
+    lmm_expand(getModel()->getMaxminSystem(), storage->p_constraintRead,
+                  getVariable(), 1.0);
     break;
   case WRITE:
     break;
   case WRITE:
-    lmm_expand(p_model->p_maxminSystem, storage->p_constraintWrite,
-               p_variable, 1.0);
+    lmm_expand(getModel()->getMaxminSystem(), storage->p_constraintWrite,
+                  getVariable(), 1.0);
     ActionPtr action = this;
     xbt_dynar_push(storage->p_writeActions, &action);
     ref();
     ActionPtr action = this;
     xbt_dynar_push(storage->p_writeActions, &action);
     ref();
@@ -553,10 +547,10 @@ int StorageN11ActionLmm::unref()
   m_refcount--;
   if (!m_refcount) {
     xbt_swag_remove(static_cast<ActionPtr>(this), p_stateSet);
   m_refcount--;
   if (!m_refcount) {
     xbt_swag_remove(static_cast<ActionPtr>(this), p_stateSet);
-    if (p_variable)
-      lmm_variable_free(p_model->p_maxminSystem, p_variable);
+    if (getVariable())
+      lmm_variable_free(getModel()->getMaxminSystem(), getVariable());
 #ifdef HAVE_TRACING
 #ifdef HAVE_TRACING
-    xbt_free(p_category);
+    xbt_free(getCategory());
 #endif
     delete this;
     return 1;
 #endif
     delete this;
     return 1;
@@ -574,8 +568,8 @@ void StorageN11ActionLmm::suspend()
 {
   XBT_IN("(%p)", this);
   if (m_suspended != 2) {
 {
   XBT_IN("(%p)", this);
   if (m_suspended != 2) {
-    lmm_update_variable_weight(p_model->p_maxminSystem,
-                               p_variable,
+    lmm_update_variable_weight(getModel()->getMaxminSystem(),
+                               getVariable(),
                                0.0);
     m_suspended = 1;
   }
                                0.0);
     m_suspended = 1;
   }
index bd1e7fa..cff5c44 100644 (file)
@@ -67,11 +67,11 @@ static void surf_share_resources(surf_model_t model)
 {
   double next_action_end = -1.0;
   int i = __sync_fetch_and_add(&surf_min_index, 1);
 {
   double next_action_end = -1.0;
   int i = __sync_fetch_and_add(&surf_min_index, 1);
-  if (strcmp(model->m_name.c_str(), "network NS3")) {
-    XBT_DEBUG("Running for Resource [%s]", model->m_name.c_str());
+  if (strcmp(model->getName(), "network NS3")) {
+    XBT_DEBUG("Running for Resource [%s]", model->getName());
     next_action_end = model->shareResources(NOW);
     XBT_DEBUG("Resource [%s] : next action end = %f",
     next_action_end = model->shareResources(NOW);
     XBT_DEBUG("Resource [%s] : next action end = %f",
-        model->m_name.c_str(), next_action_end);
+        model->getName(), next_action_end);
   }
   surf_mins[i] = next_action_end;
 }
   }
   surf_mins[i] = next_action_end;
 }
@@ -128,7 +128,7 @@ double surf_solve(double max_date)
 
     next_event_date = tmgr_history_next_date(history);
 
 
     next_event_date = tmgr_history_next_date(history);
 
-    if(!strcmp(surf_network_model->m_name.c_str(), "network NS3")){//FIXME: add surf_network_model->m_name &&
+    if(!strcmp(surf_network_model->getName(), "network NS3")){//FIXME: add surf_network_model->m_name &&
       if(next_event_date!=-1.0 && surf_min!=-1.0) {
         surf_min = MIN(next_event_date - NOW, surf_min);
       } else{
       if(next_event_date!=-1.0 && surf_min!=-1.0) {
         surf_min = MIN(next_event_date - NOW, surf_min);
       } else{
@@ -156,7 +156,7 @@ double surf_solve(double max_date)
             tmgr_history_get_next_event_leq(history, next_event_date,
                                             &value,
                                             (void **) &resource))) {
             tmgr_history_get_next_event_leq(history, next_event_date,
                                             &value,
                                             (void **) &resource))) {
-      if (resource->isUsed() || xbt_dict_get_or_null(watched_hosts_lib, resource->m_name)) {
+      if (resource->isUsed() || xbt_dict_get_or_null(watched_hosts_lib, resource->getName())) {
         surf_min = next_event_date - NOW;
         XBT_DEBUG
             ("This event will modify model state. Next event set to %f",
         surf_min = next_event_date - NOW;
         XBT_DEBUG
             ("This event will modify model state. Next event set to %f",
@@ -165,7 +165,7 @@ double surf_solve(double max_date)
       /* update state of model_obj according to new value. Does not touch lmm.
          It will be modified if needed when updating actions */
       XBT_DEBUG("Calling update_resource_state for resource %s with min %lf",
       /* update state of model_obj according to new value. Does not touch lmm.
          It will be modified if needed when updating actions */
       XBT_DEBUG("Calling update_resource_state for resource %s with min %lf",
-             resource->m_name, surf_min);
+             resource->getName(), surf_min);
       resource->updateState(event, value, next_event_date);
     }
   } while (1);
       resource->updateState(event, value, next_event_date);
     }
   } while (1);
@@ -212,7 +212,7 @@ surf_model_t surf_resource_model(const void *host, int level) {
   /* If level is SURF_WKS_LEVEL, ws is a workstation_CLM03 object. It has
    * surf_resource at the generic_resource field. */
   ResourcePtr ws = static_cast<ResourcePtr>(xbt_lib_get_level((xbt_dictelm_t) host, level));
   /* If level is SURF_WKS_LEVEL, ws is a workstation_CLM03 object. It has
    * surf_resource at the generic_resource field. */
   ResourcePtr ws = static_cast<ResourcePtr>(xbt_lib_get_level((xbt_dictelm_t) host, level));
-  return ws->p_model;
+  return ws->getModel();
 }
 
 void *surf_as_cluster_get_backbone(AS_t as){
 }
 
 void *surf_as_cluster_get_backbone(AS_t as){
@@ -224,23 +224,23 @@ void surf_as_cluster_set_backbone(AS_t as, void* backbone){
 }
 
 const char *surf_model_name(surf_model_t model){
 }
 
 const char *surf_model_name(surf_model_t model){
-  return model->m_name.c_str();
+  return model->getName();
 }
 
 xbt_swag_t surf_model_done_action_set(surf_model_t model){
 }
 
 xbt_swag_t surf_model_done_action_set(surf_model_t model){
-  return model->p_doneActionSet;
+  return model->getDoneActionSet();
 }
 
 xbt_swag_t surf_model_failed_action_set(surf_model_t model){
 }
 
 xbt_swag_t surf_model_failed_action_set(surf_model_t model){
-  return model->p_failedActionSet;
+  return model->getFailedActionSet();
 }
 
 xbt_swag_t surf_model_ready_action_set(surf_model_t model){
 }
 
 xbt_swag_t surf_model_ready_action_set(surf_model_t model){
-  return model->p_readyActionSet;
+  return model->getReadyActionSet();
 }
 
 xbt_swag_t surf_model_running_action_set(surf_model_t model){
 }
 
 xbt_swag_t surf_model_running_action_set(surf_model_t model){
-  return model->p_runningActionSet;
+  return model->getRunningActionSet();
 }
 
 surf_action_t surf_workstation_model_execute_parallel_task(surf_workstation_model_t model,
 }
 
 surf_action_t surf_workstation_model_execute_parallel_task(surf_workstation_model_t model,
@@ -270,7 +270,7 @@ surf_action_t surf_network_model_communicate(surf_network_model_t model, sg_rout
 }
 
 const char *surf_resource_name(surf_cpp_resource_t resource){
 }
 
 const char *surf_resource_name(surf_cpp_resource_t resource){
-  return resource->m_name;
+  return resource->getName();
 }
 
 xbt_dict_t surf_resource_get_properties(surf_cpp_resource_t resource){
 }
 
 xbt_dict_t surf_resource_get_properties(surf_cpp_resource_t resource){
@@ -458,11 +458,11 @@ surf_action_t surf_cpu_sleep(surf_resource_t cpu, double duration){
 }
 
 double surf_action_get_start_time(surf_action_t action){
 }
 
 double surf_action_get_start_time(surf_action_t action){
-  return action->m_start;
+  return action->getStartTime();
 }
 
 double surf_action_get_finish_time(surf_action_t action){
 }
 
 double surf_action_get_finish_time(surf_action_t action){
-  return action->m_finish;
+  return action->getFinishTime();
 }
 
 double surf_action_get_remains(surf_action_t action){
 }
 
 double surf_action_get_remains(surf_action_t action){
@@ -494,11 +494,11 @@ void surf_action_set_category(surf_action_t action, const char *category){
 }
 
 void *surf_action_get_data(surf_action_t action){
 }
 
 void *surf_action_get_data(surf_action_t action){
-  return action->p_data;
+  return action->getData();
 }
 
 void surf_action_set_data(surf_action_t action, void *data){
 }
 
 void surf_action_set_data(surf_action_t action, void *data){
-  action->p_data = data;
+  action->setData(data);
 }
 
 e_surf_action_state_t surf_action_get_state(surf_action_t action){
 }
 
 e_surf_action_state_t surf_action_get_state(surf_action_t action){
@@ -506,7 +506,7 @@ e_surf_action_state_t surf_action_get_state(surf_action_t action){
 }
 
 int surf_action_get_cost(surf_action_t action){
 }
 
 int surf_action_get_cost(surf_action_t action){
-  return action->m_cost;
+  return action->getCost();
 }
 
 void surf_cpu_action_set_affinity(surf_action_t action, surf_resource_t cpu, unsigned long mask) {
 }
 
 void surf_cpu_action_set_affinity(surf_action_t action, surf_resource_t cpu, unsigned long mask) {
index a5fd214..3cfb2fc 100644 (file)
@@ -419,8 +419,8 @@ void surf_exit(void)
  * Model *
  *********/
 
  * Model *
  *********/
 
-Model::Model(string name)
-  : p_maxminSystem(0),  m_name(name),
+Model::Model(const char *name)
+  : p_maxminSystem(0),  p_name(name),
     m_resOnCB(0), m_resOffCB(0),
     m_actCancelCB(0), m_actSuspendCB(0), m_actResumeCB(0)
 {
     m_resOnCB(0), m_resOffCB(0),
     m_actCancelCB(0), m_actSuspendCB(0), m_actResumeCB(0)
 {
@@ -473,20 +473,20 @@ double Model::shareResourcesLazy(double now)
   while((action = static_cast<ActionLmmPtr>(xbt_swag_extract(p_modifiedSet)))) {
     int max_dur_flag = 0;
 
   while((action = static_cast<ActionLmmPtr>(xbt_swag_extract(p_modifiedSet)))) {
     int max_dur_flag = 0;
 
-    if (action->p_stateSet != p_runningActionSet)
+    if (action->getStateSet() != p_runningActionSet)
       continue;
 
     /* bogus priority, skip it */
       continue;
 
     /* bogus priority, skip it */
-    if (action->m_priority <= 0)
+    if (action->getPriority() <= 0)
       continue;
 
     action->updateRemainingLazy(now);
 
     min = -1;
       continue;
 
     action->updateRemainingLazy(now);
 
     min = -1;
-    value = lmm_variable_getvalue(action->p_variable);
+    value = lmm_variable_getvalue(action->getVariable());
     if (value > 0) {
     if (value > 0) {
-      if (action->m_remains > 0) {
-        value = action->m_remains / value;
+      if (action->getRemains() > 0) {
+        value = action->getRemains() / value;
         min = now + value;
       } else {
         value = 0.0;
         min = now + value;
       } else {
         value = 0.0;
@@ -494,18 +494,18 @@ double Model::shareResourcesLazy(double now)
       }
     }
 
       }
     }
 
-    if ((action->m_maxDuration != NO_MAX_DURATION)
+    if ((action->getMaxDuration() != NO_MAX_DURATION)
         && (min == -1
         && (min == -1
-            || action->m_start +
-            action->m_maxDuration < min)) {
-      min = action->m_start +
-          action->m_maxDuration;
+            || action->getStartTime() +
+            action->getMaxDuration() < min)) {
+      min = action->getStartTime() +
+          action->getMaxDuration();
       max_dur_flag = 1;
     }
 
     XBT_DEBUG("Action(%p) Start %lf Finish %lf Max_duration %lf", action,
       max_dur_flag = 1;
     }
 
     XBT_DEBUG("Action(%p) Start %lf Finish %lf Max_duration %lf", action,
-        action->m_start, now + value,
-        action->m_maxDuration);
+        action->getStartTime(), now + value,
+        action->getMaxDuration());
 
     if (min != -1) {
       action->heapRemove(p_actionHeap);
 
     if (min != -1) {
       action->heapRemove(p_actionHeap);
@@ -544,8 +544,8 @@ double Model::shareResourcesMaxMin(xbt_swag_t running_actions,
 
   xbt_swag_foreach(_action, running_actions) {
     action = dynamic_cast<ActionLmmPtr>(static_cast<ActionPtr>(_action));
 
   xbt_swag_foreach(_action, running_actions) {
     action = dynamic_cast<ActionLmmPtr>(static_cast<ActionPtr>(_action));
-    value = lmm_variable_getvalue(action->p_variable);
-    if ((value > 0) || (action->m_maxDuration >= 0))
+    value = lmm_variable_getvalue(action->getVariable());
+    if ((value > 0) || (action->getMaxDuration() >= 0))
       break;
   }
 
       break;
   }
 
@@ -553,24 +553,24 @@ double Model::shareResourcesMaxMin(xbt_swag_t running_actions,
     return -1.0;
 
   if (value > 0) {
     return -1.0;
 
   if (value > 0) {
-    if (action->m_remains > 0)
-      min = action->m_remains / value;
+    if (action->getRemains() > 0)
+      min = action->getRemains() / value;
     else
       min = 0.0;
     else
       min = 0.0;
-    if ((action->m_maxDuration >= 0) && (action->m_maxDuration < min))
-      min = action->m_maxDuration;
+    if ((action->getMaxDuration() >= 0) && (action->getMaxDuration() < min))
+      min = action->getMaxDuration();
   } else
   } else
-    min = action->m_maxDuration;
+    min = action->getMaxDuration();
 
 
   for (_action = xbt_swag_getNext(static_cast<ActionPtr>(action), running_actions->offset);
        _action;
        _action = xbt_swag_getNext(static_cast<ActionPtr>(action), running_actions->offset)) {
        action = dynamic_cast<ActionLmmPtr>(static_cast<ActionPtr>(_action));
 
 
   for (_action = xbt_swag_getNext(static_cast<ActionPtr>(action), running_actions->offset);
        _action;
        _action = xbt_swag_getNext(static_cast<ActionPtr>(action), running_actions->offset)) {
        action = dynamic_cast<ActionLmmPtr>(static_cast<ActionPtr>(_action));
-    value = lmm_variable_getvalue(action->p_variable);
+    value = lmm_variable_getvalue(action->getVariable());
     if (value > 0) {
     if (value > 0) {
-      if (action->m_remains > 0)
-        value = action->m_remains / value;
+      if (action->getRemains() > 0)
+        value = action->getRemains() / value;
       else
         value = 0.0;
       if (value < min) {
       else
         value = 0.0;
       if (value < min) {
@@ -578,8 +578,8 @@ double Model::shareResourcesMaxMin(xbt_swag_t running_actions,
         XBT_DEBUG("Updating min (value) with %p: %f", action, min);
       }
     }
         XBT_DEBUG("Updating min (value) with %p: %f", action, min);
       }
     }
-    if ((action->m_maxDuration >= 0) && (action->m_maxDuration < min)) {
-      min = action->m_maxDuration;
+    if ((action->getMaxDuration() >= 0) && (action->getMaxDuration() < min)) {
+      min = action->getMaxDuration();
       XBT_DEBUG("Updating min (duration) with %p: %f", action, min);
     }
   }
       XBT_DEBUG("Updating min (duration) with %p: %f", action, min);
     }
   }
@@ -664,32 +664,28 @@ void Model::notifyActionSuspend(ActionPtr a)
  * Resource *
  ************/
 
  * Resource *
  ************/
 
-Resource::Resource(surf_model_t model, const char *name, xbt_dict_t props)
-  : m_name(xbt_strdup(name)), m_properties(props), p_model(model), m_running(true)
-{}
-
 Resource::Resource()
 Resource::Resource()
-: m_name(NULL), m_properties(NULL), p_model(NULL)
+: p_name(NULL), p_properties(NULL), p_model(NULL)
 {}
 
 {}
 
-const char *Resource::getName()
-{
-  return m_name;
-}
+Resource::Resource(surf_model_t model, const char *name, xbt_dict_t props)
+ : p_name(xbt_strdup(name)), p_properties(props), p_model(model)
+ , m_running(true), m_stateCurrent(SURF_RESOURCE_ON)
+{}
 
 
-xbt_dict_t Resource::getProperties()
-{
-  return m_properties;
-}
+Resource::Resource(surf_model_t model, const char *name, xbt_dict_t props, e_surf_resource_state_t stateInit)
+ : p_name(xbt_strdup(name)), p_properties(props), p_model(model)
+ , m_running(true), m_stateCurrent(stateInit)
+{}
 
 e_surf_resource_state_t Resource::getState()
 {
 
 e_surf_resource_state_t Resource::getState()
 {
-  return p_stateCurrent;
+  return m_stateCurrent;
 }
 
 void Resource::setState(e_surf_resource_state_t state)
 {
 }
 
 void Resource::setState(e_surf_resource_state_t state)
 {
-  p_stateCurrent = state;
+  m_stateCurrent = state;
 }
 
 bool Resource::isOn()
 }
 
 bool Resource::isOn()
@@ -701,7 +697,7 @@ void Resource::turnOn()
 {
   if (!m_running) {
     m_running = true;
 {
   if (!m_running) {
     m_running = true;
-    p_model->notifyResourceTurnedOn(this);
+    getModel()->notifyResourceTurnedOn(this);
   }
 }
 
   }
 }
 
@@ -709,29 +705,17 @@ void Resource::turnOff()
 {
   if (m_running) {
     m_running = false;
 {
   if (m_running) {
     m_running = false;
-    p_model->notifyResourceTurnedOff(this);
+    getModel()->notifyResourceTurnedOff(this);
   }
 }
 
   }
 }
 
-ResourceLmm::ResourceLmm(lmm_system_t system,
-                         double constraint_value,
-                         tmgr_history_t history,
-                         e_surf_resource_state_t state_init,
-                         tmgr_trace_t state_trace,
-                         double metric_peak,
-                         tmgr_trace_t metric_trace)
-{
-  p_constraint = lmm_constraint_new(system, this, constraint_value);
-  p_stateCurrent = state_init;
-  if (state_trace)
-    p_stateEvent = tmgr_history_add_trace(history, state_trace, 0.0, 0, static_cast<ResourcePtr>(this));
-  p_power.scale = 1.0;
-  p_power.peak = metric_peak;
-  if (metric_trace)
-    p_power.event = tmgr_history_add_trace(history, metric_trace, 0.0, 0, static_cast<ResourcePtr>(this));
-  else
-    p_power.event = NULL;
-}
+ResourceLmm::ResourceLmm()
+ : p_constraint(NULL)
+{}
+
+ResourceLmm::ResourceLmm(lmm_constraint_t constraint)
+ : p_constraint(constraint)
+{}
 
 /**********
  * Action *
 
 /**********
  * Action *
@@ -767,14 +751,22 @@ Action::Action(ModelPtr model, double cost, bool failed)
   p_stateHookup.prev = 0;
   p_stateHookup.next = 0;
   if (failed)
   p_stateHookup.prev = 0;
   p_stateHookup.next = 0;
   if (failed)
-    p_stateSet = p_model->p_failedActionSet;
+    p_stateSet = getModel()->getFailedActionSet();
   else
   else
-    p_stateSet = p_model->p_runningActionSet;
+    p_stateSet = getModel()->getRunningActionSet();
 
   xbt_swag_insert(this, p_stateSet);
 }
 
 
   xbt_swag_insert(this, p_stateSet);
 }
 
-Action::~Action() {}
+Action::~Action() {
+#ifdef HAVE_TRACING
+  xbt_free(p_category);
+#endif
+}
+
+void Action::finish() {
+    m_finish = surf_get_clock();
+}
 
 int Action::unref(){
   DIE_IMPOSSIBLE;
 
 int Action::unref(){
   DIE_IMPOSSIBLE;
@@ -790,13 +782,13 @@ void Action::recycle(){
 
 e_surf_action_state_t Action::getState()
 {
 
 e_surf_action_state_t Action::getState()
 {
-  if (p_stateSet ==  p_model->p_readyActionSet)
+  if (p_stateSet ==  getModel()->getReadyActionSet())
     return SURF_ACTION_READY;
     return SURF_ACTION_READY;
-  if (p_stateSet ==  p_model->p_runningActionSet)
+  if (p_stateSet ==  getModel()->getRunningActionSet())
     return SURF_ACTION_RUNNING;
     return SURF_ACTION_RUNNING;
-  if (p_stateSet ==  p_model->p_failedActionSet)
+  if (p_stateSet ==  getModel()->getFailedActionSet())
     return SURF_ACTION_FAILED;
     return SURF_ACTION_FAILED;
-  if (p_stateSet ==  p_model->p_doneActionSet)
+  if (p_stateSet ==  getModel()->getDoneActionSet())
     return SURF_ACTION_DONE;
   return SURF_ACTION_NOT_IN_THE_SYSTEM;
 }
     return SURF_ACTION_DONE;
   return SURF_ACTION_NOT_IN_THE_SYSTEM;
 }
@@ -808,13 +800,13 @@ void Action::setState(e_surf_action_state_t state)
   xbt_swag_remove(this, p_stateSet);
 
   if (state == SURF_ACTION_READY)
   xbt_swag_remove(this, p_stateSet);
 
   if (state == SURF_ACTION_READY)
-    p_stateSet = p_model->p_readyActionSet;
+    p_stateSet = getModel()->getReadyActionSet();
   else if (state == SURF_ACTION_RUNNING)
   else if (state == SURF_ACTION_RUNNING)
-    p_stateSet = p_model->p_runningActionSet;
+    p_stateSet = getModel()->getRunningActionSet();
   else if (state == SURF_ACTION_FAILED)
   else if (state == SURF_ACTION_FAILED)
-    p_stateSet = p_model->p_failedActionSet;
+    p_stateSet = getModel()->getFailedActionSet();
   else if (state == SURF_ACTION_DONE)
   else if (state == SURF_ACTION_DONE)
-    p_stateSet = p_model->p_doneActionSet;
+    p_stateSet = getModel()->getDoneActionSet();
   else
     p_stateSet = NULL;
 
   else
     p_stateSet = NULL;
 
@@ -863,8 +855,8 @@ void ActionLmm::setMaxDuration(double duration)
 {
   XBT_IN("(%p,%g)", this, duration);
   m_maxDuration = duration;
 {
   XBT_IN("(%p,%g)", this, duration);
   m_maxDuration = duration;
-  if (p_model->p_updateMechanism == UM_LAZY)      // remove action from the heap
-    heapRemove(p_model->p_actionHeap);
+  if (getModel()->getUpdateMechanism() == UM_LAZY)      // remove action from the heap
+    heapRemove(getModel()->getActionHeap());
   XBT_OUT();
 }
 
   XBT_OUT();
 }
 
@@ -874,18 +866,18 @@ void ActionLmm::setPriority(double priority)
 {
   XBT_IN("(%p,%g)", this, priority);
   m_priority = priority;
 {
   XBT_IN("(%p,%g)", this, priority);
   m_priority = priority;
-  lmm_update_variable_weight(p_model->p_maxminSystem, p_variable, priority);
+  lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), priority);
 
 
-  if (p_model->p_updateMechanism == UM_LAZY)
-       heapRemove(p_model->p_actionHeap);
+  if (getModel()->getUpdateMechanism() == UM_LAZY)
+       heapRemove(getModel()->getActionHeap());
   XBT_OUT();
 }
 
 void ActionLmm::cancel(){
   setState(SURF_ACTION_FAILED);
   XBT_OUT();
 }
 
 void ActionLmm::cancel(){
   setState(SURF_ACTION_FAILED);
-  if (p_model->p_updateMechanism == UM_LAZY) {
-    xbt_swag_remove(this, p_model->p_modifiedSet);
-    heapRemove(p_model->p_actionHeap);
+  if (getModel()->getUpdateMechanism() == UM_LAZY) {
+    xbt_swag_remove(this, getModel()->getModifiedSet());
+    heapRemove(getModel()->getActionHeap());
   }
 }
 
   }
 }
 
@@ -893,16 +885,13 @@ int ActionLmm::unref(){
   m_refcount--;
   if (!m_refcount) {
        xbt_swag_remove(static_cast<ActionPtr>(this), p_stateSet);
   m_refcount--;
   if (!m_refcount) {
        xbt_swag_remove(static_cast<ActionPtr>(this), p_stateSet);
-       if (p_variable)
-         lmm_variable_free(p_model->p_maxminSystem, p_variable);
-       if (p_model->p_updateMechanism == UM_LAZY) {
+       if (getVariable())
+         lmm_variable_free(getModel()->getMaxminSystem(), getVariable());
+       if (getModel()->getUpdateMechanism() == UM_LAZY) {
          /* remove from heap */
          /* remove from heap */
-         heapRemove(p_model->p_actionHeap);
-         xbt_swag_remove(this, p_model->p_modifiedSet);
+         heapRemove(getModel()->getActionHeap());
+         xbt_swag_remove(this, getModel()->getModifiedSet());
     }
     }
-#ifdef HAVE_TRACING
-    xbt_free(p_category);
-#endif
        delete this;
        return 1;
   }
        delete this;
        return 1;
   }
@@ -913,10 +902,10 @@ void ActionLmm::suspend()
 {
   XBT_IN("(%p)", this);
   if (m_suspended != 2) {
 {
   XBT_IN("(%p)", this);
   if (m_suspended != 2) {
-    lmm_update_variable_weight(p_model->p_maxminSystem, p_variable, 0.0);
+    lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), 0.0);
     m_suspended = 1;
     m_suspended = 1;
-    if (p_model->p_updateMechanism == UM_LAZY)
-      heapRemove(p_model->p_actionHeap);
+    if (getModel()->getUpdateMechanism() == UM_LAZY)
+      heapRemove(getModel()->getActionHeap());
   }
   XBT_OUT();
 }
   }
   XBT_OUT();
 }
@@ -925,10 +914,10 @@ void ActionLmm::resume()
 {
   XBT_IN("(%p)", this);
   if (m_suspended != 2) {
 {
   XBT_IN("(%p)", this);
   if (m_suspended != 2) {
-    lmm_update_variable_weight(p_model->p_maxminSystem, p_variable, m_priority);
+    lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), m_priority);
     m_suspended = 0;
     m_suspended = 0;
-    if (p_model->p_updateMechanism == UM_LAZY)
-      heapRemove(p_model->p_actionHeap);
+    if (getModel()->getUpdateMechanism() == UM_LAZY)
+      heapRemove(getModel()->getActionHeap());
   }
   XBT_OUT();
 }
   }
   XBT_OUT();
 }
@@ -971,7 +960,7 @@ double ActionLmm::getRemains()
 {
   XBT_IN("(%p)", this);
   /* update remains before return it */
 {
   XBT_IN("(%p)", this);
   /* update remains before return it */
-  if (p_model->p_updateMechanism == UM_LAZY)      /* update remains before return it */
+  if (getModel()->getUpdateMechanism() == UM_LAZY)      /* update remains before return it */
     updateRemainingLazy(surf_get_clock());
   XBT_OUT();
   return m_remains;
     updateRemainingLazy(surf_get_clock());
   XBT_OUT();
   return m_remains;
@@ -982,14 +971,14 @@ void ActionLmm::updateRemainingLazy(double now)
 {
   double delta = 0.0;
 
 {
   double delta = 0.0;
 
-  if(p_model == static_cast<ModelPtr>(surf_network_model))
+  if(getModel() == static_cast<ModelPtr>(surf_network_model))
   {
     if (m_suspended != 0)
       return;
   }
   else
   {
   {
     if (m_suspended != 0)
       return;
   }
   else
   {
-    xbt_assert(p_stateSet == p_model->p_runningActionSet,
+    xbt_assert(p_stateSet == getModel()->getRunningActionSet(),
         "You're updating an action that is not running.");
 
       /* bogus priority, skip it */
         "You're updating an action that is not running.");
 
       /* bogus priority, skip it */
@@ -1004,35 +993,35 @@ void ActionLmm::updateRemainingLazy(double now)
     double_update(&m_remains, m_lastValue * delta);
 
 #ifdef HAVE_TRACING
     double_update(&m_remains, m_lastValue * delta);
 
 #ifdef HAVE_TRACING
-    if (p_model == static_cast<ModelPtr>(surf_cpu_model_pm) && TRACE_is_enabled()) {
-      ResourcePtr cpu = static_cast<ResourcePtr>(lmm_constraint_id(lmm_get_cnst_from_var(p_model->p_maxminSystem, p_variable, 0)));
-      TRACE_surf_host_set_utilization(cpu->m_name, p_category, m_lastValue, m_lastUpdate, now - m_lastUpdate);
+    if (getModel() == static_cast<ModelPtr>(surf_cpu_model_pm) && TRACE_is_enabled()) {
+      ResourcePtr cpu = static_cast<ResourcePtr>(lmm_constraint_id(lmm_get_cnst_from_var(getModel()->getMaxminSystem(), getVariable(), 0)));
+      TRACE_surf_host_set_utilization(cpu->getName(), getCategory(), m_lastValue, m_lastUpdate, now - m_lastUpdate);
     }
 #endif
     XBT_DEBUG("Updating action(%p): remains is now %f", this, m_remains);
   }
 
     }
 #endif
     XBT_DEBUG("Updating action(%p): remains is now %f", this, m_remains);
   }
 
-  if(p_model == static_cast<ModelPtr>(surf_network_model))
+  if(getModel() == static_cast<ModelPtr>(surf_network_model))
   {
     if (m_maxDuration != NO_MAX_DURATION)
       double_update(&m_maxDuration, delta);
 
     //FIXME: duplicated code
     if ((m_remains <= 0) &&
   {
     if (m_maxDuration != NO_MAX_DURATION)
       double_update(&m_maxDuration, delta);
 
     //FIXME: duplicated code
     if ((m_remains <= 0) &&
-        (lmm_get_variable_weight(p_variable) > 0)) {
-      m_finish = surf_get_clock();
+        (lmm_get_variable_weight(getVariable()) > 0)) {
+      finish();
       setState(SURF_ACTION_DONE);
       setState(SURF_ACTION_DONE);
-      heapRemove(p_model->p_actionHeap);
+      heapRemove(getModel()->getActionHeap());
     } else if (((m_maxDuration != NO_MAX_DURATION)
         && (m_maxDuration <= 0))) {
     } else if (((m_maxDuration != NO_MAX_DURATION)
         && (m_maxDuration <= 0))) {
-      m_finish = surf_get_clock();
+      finish();
       setState(SURF_ACTION_DONE);
       setState(SURF_ACTION_DONE);
-      heapRemove(p_model->p_actionHeap);
+      heapRemove(getModel()->getActionHeap());
     }
   }
 
   m_lastUpdate = now;
     }
   }
 
   m_lastUpdate = now;
-  m_lastValue = lmm_variable_getvalue(p_variable);
+  m_lastValue = lmm_variable_getvalue(getVariable());
 }
 
 /*void Action::cancel()
 }
 
 /*void Action::cancel()
index b28e1c0..74db479 100644 (file)
@@ -95,11 +95,38 @@ XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_latency;
 XBT_PUBLIC_DATA(xbt_dynar_t) model_list;
 
 class Model {
 XBT_PUBLIC_DATA(xbt_dynar_t) model_list;
 
 class Model {
+  const char *p_name;
+
+  xbt_swag_t p_readyActionSet; /**< Actions in state SURF_ACTION_READY */
+  xbt_swag_t p_runningActionSet; /**< Actions in state SURF_ACTION_RUNNING */
+  xbt_swag_t p_failedActionSet; /**< Actions in state SURF_ACTION_FAILED */
+  xbt_swag_t p_doneActionSet; /**< Actions in state SURF_ACTION_DONE */
+
+  ResourceCallback m_resOnCB, m_resOffCB;
+  ActionCallback m_actCancelCB, m_actSuspendCB, m_actResumeCB;
+
+protected:
+  xbt_swag_t p_modifiedSet;
+
+  lmm_system_t p_maxminSystem;
+  e_UM_t p_updateMechanism;
+  int m_selectiveUpdate;
+  xbt_heap_t p_actionHeap;
+
 public:
 public:
-  Model(string name);
+  Model(const char *name);
   virtual ~Model();
 
   virtual ~Model();
 
-  //ResourcePtr createResource(string name);
+  const char *getName() {return p_name;}
+  xbt_swag_t getReadyActionSet() {return p_readyActionSet;}
+  xbt_swag_t getRunningActionSet() {return p_runningActionSet;}
+  xbt_swag_t getFailedActionSet() {return p_failedActionSet;}
+  xbt_swag_t getDoneActionSet() {return p_doneActionSet;}
+  xbt_swag_t getModifiedSet() {return p_modifiedSet;}
+  lmm_system_t getMaxminSystem() {return p_maxminSystem;}
+  e_UM_t getUpdateMechanism() {return p_updateMechanism;}
+  xbt_heap_t getActionHeap() {return p_actionHeap;}
+
   ActionPtr createAction(double _cost, bool _failed);
   virtual double shareResources(double now);
   virtual double shareResourcesLazy(double now);
   ActionPtr createAction(double _cost, bool _failed);
   virtual double shareResources(double now);
   virtual double shareResourcesLazy(double now);
@@ -111,8 +138,6 @@ public:
   virtual void updateActionsStateLazy(double now, double delta);
   virtual void updateActionsStateFull(double now, double delta);
 
   virtual void updateActionsStateLazy(double now, double delta);
   virtual void updateActionsStateFull(double now, double delta);
 
-  string getName() {return m_name;};
-
   void addTurnedOnCallback(ResourceCallback rc);
   void notifyResourceTurnedOn(ResourcePtr r);
 
   void addTurnedOnCallback(ResourceCallback rc);
   void notifyResourceTurnedOn(ResourcePtr r);
 
@@ -125,25 +150,6 @@ public:
   void notifyActionResume(ActionPtr a);
   void addActionSuspendCallback(ActionCallback ac);  
   void notifyActionSuspend(ActionPtr a);
   void notifyActionResume(ActionPtr a);
   void addActionSuspendCallback(ActionCallback ac);  
   void notifyActionSuspend(ActionPtr a);
-
-  lmm_system_t p_maxminSystem;
-  e_UM_t p_updateMechanism;
-  xbt_swag_t p_modifiedSet;
-  xbt_heap_t p_actionHeap;
-  int m_selectiveUpdate;
-
-  xbt_swag_t p_readyActionSet; /**< Actions in state SURF_ACTION_READY */
-  xbt_swag_t p_runningActionSet; /**< Actions in state SURF_ACTION_RUNNING */
-  xbt_swag_t p_failedActionSet; /**< Actions in state SURF_ACTION_FAILED */
-  xbt_swag_t p_doneActionSet; /**< Actions in state SURF_ACTION_DONE */
-  string m_name;
-
-protected:
-  std::vector<ActionPtr> m_failedActions, m_runningActions;
-
-private:
-  ResourceCallback m_resOnCB, m_resOffCB;
-  ActionCallback m_actCancelCB, m_actSuspendCB, m_actResumeCB;
 };
 
 /************
 };
 
 /************
@@ -160,62 +166,49 @@ typedef struct {
 } s_surf_metric_t;
 
 class Resource {
 } s_surf_metric_t;
 
 class Resource {
+  void *p_resource;
+  const char *p_name;
+  ModelPtr p_model;
+  xbt_dict_t p_properties;
+  bool m_running;
+
+protected:
+  e_surf_resource_state_t m_stateCurrent;
+
 public:
   Resource();
   Resource(ModelPtr model, const char *name, xbt_dict_t properties);
 public:
   Resource();
   Resource(ModelPtr model, const char *name, xbt_dict_t properties);
+  Resource(surf_model_t model, const char *name, xbt_dict_t props, e_surf_resource_state_t stateInit);
   virtual ~Resource() {
   virtual ~Resource() {
-       xbt_free((void*)m_name);
-    xbt_dict_free(&m_properties);
+       xbt_free((void*)p_name);
+    xbt_dict_free(&p_properties);
   };
 
   };
 
-  virtual void updateState(tmgr_trace_event_t event_type, double value, double date)=0;
+  ModelPtr getModel() {return p_model;};
+  const char *getName() {return p_name;};
+  virtual xbt_dict_t getProperties() {return p_properties;};
 
 
-  //private
+  virtual void updateState(tmgr_trace_event_t event_type, double value, double date)=0;
   virtual bool isUsed()=0;
   virtual bool isUsed()=0;
-  //FIXME:updateActionState();
-  //FIXME:updateResourceState();
-  //FIXME:finilize();
-
   bool isOn();
   void turnOn();
   void turnOff();
   void setName(string name);
   bool isOn();
   void turnOn();
   void turnOff();
   void setName(string name);
-  const char *getName();
-  virtual xbt_dict_t getProperties();
 
 
-  ModelPtr getModel() {return p_model;};
   virtual e_surf_resource_state_t getState();
   virtual void setState(e_surf_resource_state_t state);
   virtual e_surf_resource_state_t getState();
   virtual void setState(e_surf_resource_state_t state);
-  void printModel() { std::cout << p_model->getName() << "<<plop"<<std::endl;};
-  void *p_resource;
-  const char *m_name;
-  xbt_dict_t m_properties;
-  ModelPtr p_model;
-  e_surf_resource_state_t p_stateCurrent;
-
-protected:
-
-private:
-  bool m_running;  
 };
 
 class ResourceLmm: virtual public Resource {
 };
 
 class ResourceLmm: virtual public Resource {
+  lmm_constraint_t p_constraint;
+
 public:
 public:
-  ResourceLmm() : p_constraint(NULL) {
-       p_power.event = NULL;
-  };
-  ResourceLmm(lmm_system_t system,
-              double constraint_value,
-              tmgr_history_t history,
-              e_surf_resource_state_t state_init,
-              tmgr_trace_t state_trace,
-              double metric_peak,
-              tmgr_trace_t metric_trace);
+  ResourceLmm();
+  ResourceLmm(lmm_constraint_t constraint);
   ~ResourceLmm() {
   };
   ~ResourceLmm() {
   };
-  lmm_constraint_t p_constraint;
-  tmgr_trace_event_t p_stateEvent;
-  s_surf_metric_t p_power;
+
+  lmm_constraint_t constraint() {return p_constraint;};
 };
 
 /**********
 };
 
 /**********
@@ -223,18 +216,57 @@ public:
  **********/
 
 class Action {
  **********/
 
 class Action {
+  xbt_swag_t p_modifiedSet;
+  xbt_heap_t p_actionHeap;
+  int m_selectiveUpdate;
+  ModelPtr p_model;
+  double m_bound;   /**< the capping of the CPU use  */
+  bool m_failed;
+  double m_start; /**< start time  */
+  char *p_category;               /**< tracing category for categorized resource utilization monitoring */
+
+  #ifdef HAVE_LATENCY_BOUND_TRACKING
+  int m_latencyLimited;               /**< Set to 1 if is limited by latency, 0 otherwise */
+  #endif
+  int    m_cost;
+  void *p_data; /**< for your convenience */
+
+protected:
+  xbt_swag_t p_stateSet;
+  double m_priority; /**< priority (1.0 by default) */
+  int    m_refcount;
+  double m_remains; /**< How much of that cost remains to be done in the currently running task */
+  double m_maxDuration; /*< max_duration (may fluctuate until the task is completed) */
+  double m_finish; /**< finish time : this is modified during the run and fluctuates until the task is completed */
+
+  ModelPtr getModel() {return p_model;}
+  double getBound() {return m_bound;}
+
 public:
 public:
+
   Action();
   Action(ModelPtr model, double cost, bool failed);
   virtual ~Action();
   
   Action();
   Action(ModelPtr model, double cost, bool failed);
   virtual ~Action();
   
+  void finish();
   s_xbt_swag_hookup_t p_stateHookup;
 
   e_surf_action_state_t getState(); /**< get the state*/
   virtual void setState(e_surf_action_state_t state); /**< Change state*/
   double getStartTime(); /**< Return the start time of an action */
   double getFinishTime(); /**< Return the finish time of an action */
   s_xbt_swag_hookup_t p_stateHookup;
 
   e_surf_action_state_t getState(); /**< get the state*/
   virtual void setState(e_surf_action_state_t state); /**< Change state*/
   double getStartTime(); /**< Return the start time of an action */
   double getFinishTime(); /**< Return the finish time of an action */
+  void *getData() {return p_data;}
   void setData(void* data);
   void setData(void* data);
+  double getMaxDuration() {return m_maxDuration;}
+  char *getCategory() {return p_category;}
+  double getCost() {return m_cost;}
+  void setCost(double cost) {m_cost = cost;}
+
+  void updateMaxDuration(double delta) {double_update(&m_maxDuration, delta);}
+  void updateRemains(double delta) {double_update(&m_remains, delta);}
+  void setRemains(double value) {m_remains = value;}
+  void setFinishTime(double value) {m_finish = value;}
+
 
   void ref();
   virtual int unref();     /**< Specify that we don't use that action anymore. Returns true if the action was destroyed and false if someone still has references on it. */
 
   void ref();
   virtual int unref();     /**< Specify that we don't use that action anymore. Returns true if the action was destroyed and false if someone still has references on it. */
@@ -254,26 +286,9 @@ public:
   int getLatencyLimited();     /**< Return 1 if action is limited by latency, 0 otherwise */
 #endif
 
   int getLatencyLimited();     /**< Return 1 if action is limited by latency, 0 otherwise */
 #endif
 
-  xbt_swag_t p_stateSet;
 
 
-  double m_priority; /**< priority (1.0 by default) */
-  double m_bound;              /**< the capping of the CPU use  */
-  bool m_failed;
-  double m_start; /**< start time  */
-  double m_finish; /**< finish time : this is modified during the run and fluctuates until the task is completed */
-  double m_remains; /**< How much of that cost remains to be done in the currently running task */
-  #ifdef HAVE_LATENCY_BOUND_TRACKING
-  int m_latencyLimited;               /**< Set to 1 if is limited by latency, 0 otherwise */
-  #endif
-  double m_maxDuration; /*< max_duration (may fluctuate until the task is completed) */  
-  char *p_category;               /**< tracing category for categorized resource utilization monitoring */  
-  int    m_cost;
-  void *p_data; /**< for your convenience */
-protected:
-  ModelPtr p_model;  
-  int    m_refcount;
-#ifdef HAVE_TRACING
-#endif
+  double getPriority() {return m_priority;};
+  xbt_swag_t getStateSet() {return p_stateSet;};
 
 private:
   int resourceUsed(void *resource_id);
 
 private:
   int resourceUsed(void *resource_id);
@@ -285,27 +300,35 @@ private:
   void updateResourceState(void *id, tmgr_trace_event_t event_type,
                                  double value, double time);
 
   void updateResourceState(void *id, tmgr_trace_event_t event_type,
                                  double value, double time);
 
-  xbt_swag_t p_modifiedSet;
-  xbt_heap_t p_actionHeap;
-  int m_selectiveUpdate;
+
 };
 
 //FIXME:REMOVE
 void surf_action_lmm_update_index_heap(void *action, int i);
 
 class ActionLmm: virtual public Action {
 };
 
 //FIXME:REMOVE
 void surf_action_lmm_update_index_heap(void *action, int i);
 
 class ActionLmm: virtual public Action {
+
+protected:
+  lmm_variable_t p_variable;
+  double m_lastUpdate;
+  double m_lastValue;
+  int m_suspended;
+  int m_indexHeap;
+  enum heap_action_type m_hat;
+
 public:
   ActionLmm() : m_suspended(false) {
        p_actionListHookup.prev = 0;
        p_actionListHookup.next = 0;
 public:
   ActionLmm() : m_suspended(false) {
        p_actionListHookup.prev = 0;
        p_actionListHookup.next = 0;
-        m_lastUpdate = 0;
-        m_lastValue = 0;
+    m_lastUpdate = 0;
+    m_lastValue = 0;
   };
   };
-  ActionLmm(ModelPtr /*model*/, double /*cost*/, bool /*failed*/) : m_suspended(false) {
+  ActionLmm(lmm_variable_t var) : m_suspended(false) {
        p_actionListHookup.prev = 0;
        p_actionListHookup.next = 0;
        p_actionListHookup.prev = 0;
        p_actionListHookup.next = 0;
-        m_lastUpdate = 0;
-        m_lastValue = 0;
+    m_lastUpdate = 0;
+    m_lastValue = 0;
+    p_variable = var;
   };
 
   virtual void updateRemainingLazy(double now);
   };
 
   virtual void updateRemainingLazy(double now);
@@ -313,6 +336,10 @@ public:
   void heapRemove(xbt_heap_t heap);
   double getRemains();     /**< Get the remains of an action */
   void updateIndexHeap(int i);
   void heapRemove(xbt_heap_t heap);
   double getRemains();     /**< Get the remains of an action */
   void updateIndexHeap(int i);
+  lmm_variable_t getVariable() {return p_variable;}
+  double getLastUpdate() {return m_lastUpdate;}
+  void refreshLastUpdate() {m_lastUpdate = surf_get_clock();}
+  enum heap_action_type getHat() {return m_hat;}
 
   virtual int unref();
   void cancel();
 
   virtual int unref();
   void cancel();
@@ -322,14 +349,8 @@ public:
   void setMaxDuration(double duration);
   void setPriority(double priority);
   void gapRemove();
   void setMaxDuration(double duration);
   void setPriority(double priority);
   void gapRemove();
-
-  lmm_variable_t p_variable;
   s_xbt_swag_hookup_t p_actionListHookup;
   s_xbt_swag_hookup_t p_actionListHookup;
-  int m_indexHeap;
-  double m_lastUpdate;
-  double m_lastValue;
-  enum heap_action_type m_hat;
-  int m_suspended;
+
 };
 
 #endif /* SURF_MODEL_H_ */
 };
 
 #endif /* SURF_MODEL_H_ */
index ca6288f..b910808 100644 (file)
@@ -90,7 +90,7 @@ void AsCluster::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)
   routerNode = new_xbt_graph_node(graph, link_name, nodes);
 
   if(p_backbone) {
   routerNode = new_xbt_graph_node(graph, link_name, nodes);
 
   if(p_backbone) {
-    const char *link_nameR = p_backbone->m_name;
+    const char *link_nameR = p_backbone->getName();
     backboneNode = new_xbt_graph_node(graph, link_nameR, nodes);
 
     new_xbt_graph_edge(graph, routerNode, backboneNode, edges);
     backboneNode = new_xbt_graph_node(graph, link_nameR, nodes);
 
     new_xbt_graph_edge(graph, routerNode, backboneNode, edges);
@@ -106,7 +106,7 @@ void AsCluster::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)
 
       if (info.link_up) {     // link up
 
 
       if (info.link_up) {     // link up
 
-        const char *link_name = ((ResourcePtr) info.link_up)->m_name;
+        const char *link_name = static_cast<ResourcePtr>(info.link_up)->getName();
         current = new_xbt_graph_node(graph, link_name, nodes);
         new_xbt_graph_edge(graph, previous, current, edges);
 
         current = new_xbt_graph_node(graph, link_name, nodes);
         new_xbt_graph_edge(graph, previous, current, edges);
 
@@ -119,7 +119,7 @@ void AsCluster::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)
       }
 
       if (info.link_down) {    // link down
       }
 
       if (info.link_down) {    // link down
-        const char *link_name = ((ResourcePtr) info.link_down)->m_name;
+        const char *link_name = static_cast<ResourcePtr>(info.link_down)->getName();
         current = new_xbt_graph_node(graph, link_name, nodes);
         new_xbt_graph_edge(graph, previous, current, edges);
 
         current = new_xbt_graph_node(graph, link_name, nodes);
         new_xbt_graph_edge(graph, previous, current, edges);
 
index 1558ff3..8a0a781 100644 (file)
@@ -179,7 +179,7 @@ void AsGeneric::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)
       }
 
       xbt_dynar_foreach(route->link_list, cpt, link) {
       }
 
       xbt_dynar_foreach(route->link_list, cpt, link) {
-        const char *link_name = ((ResourcePtr) link)->m_name;
+        const char *link_name = ((ResourcePtr) link)->getName();
         current = new_xbt_graph_node(graph, link_name, nodes);
         current_name = link_name;
         new_xbt_graph_edge(graph, previous, current, edges);
         current = new_xbt_graph_node(graph, link_name, nodes);
         current_name = link_name;
         new_xbt_graph_edge(graph, previous, current, edges);
index b8f6ecc..473c66e 100644 (file)
@@ -51,7 +51,7 @@ void WorkstationVMHL13Model::createResource(const char *name, void *ind_phys_wor
 
 static inline double get_solved_value(CpuActionLmmPtr cpu_action)
 {
 
 static inline double get_solved_value(CpuActionLmmPtr cpu_action)
 {
-  return cpu_action->p_variable->value;
+  return cpu_action->getVariable()->value;
 }
 
 /* In the real world, processes on the guest operating system will be somewhat
 }
 
 /* In the real world, processes on the guest operating system will be somewhat
@@ -118,7 +118,7 @@ double WorkstationVMHL13Model::shareResources(double now)
     if (!ws)
       continue;
     /* skip if it is not a virtual machine */
     if (!ws)
       continue;
     /* skip if it is not a virtual machine */
-    if (ws->p_model != static_cast<ModelPtr>(surf_vm_workstation_model))
+    if (ws->getModel() != static_cast<ModelPtr>(surf_vm_workstation_model))
       continue;
     xbt_assert(cpu, "cpu-less workstation");
 
       continue;
     xbt_assert(cpu, "cpu-less workstation");
 
@@ -127,13 +127,13 @@ double WorkstationVMHL13Model::shareResources(double now)
 
     double solved_value = get_solved_value(reinterpret_cast<CpuActionLmmPtr>(ws_vm->p_action));
     XBT_DEBUG("assign %f to vm %s @ pm %s", solved_value,
 
     double solved_value = get_solved_value(reinterpret_cast<CpuActionLmmPtr>(ws_vm->p_action));
     XBT_DEBUG("assign %f to vm %s @ pm %s", solved_value,
-        ws->m_name, ws_vm->p_subWs->m_name);
+        ws->getName(), ws_vm->p_subWs->getName());
 
     // TODO: check lmm_update_constraint_bound() works fine instead of the below manual substitution.
     // cpu_cas01->constraint->bound = solved_value;
 
     // TODO: check lmm_update_constraint_bound() works fine instead of the below manual substitution.
     // cpu_cas01->constraint->bound = solved_value;
-    xbt_assert(cpu->p_model == static_cast<ModelPtr>(surf_cpu_model_vm));
-    lmm_system_t vcpu_system = cpu->p_model->p_maxminSystem;
-    lmm_update_constraint_bound(vcpu_system, cpu->p_constraint, virt_overhead * solved_value);
+    xbt_assert(cpu->getModel() == static_cast<ModelPtr>(surf_cpu_model_vm));
+    lmm_system_t vcpu_system = cpu->getModel()->getMaxminSystem();
+    lmm_update_constraint_bound(vcpu_system, cpu->constraint(), virt_overhead * solved_value);
   }
 
 
   }
 
 
@@ -150,7 +150,7 @@ double WorkstationVMHL13Model::shareResources(double now)
     /* skip if it is not a virtual machine */
     if (!ws_clm03)
       continue;
     /* skip if it is not a virtual machine */
     if (!ws_clm03)
       continue;
-    if (ws_clm03->p_model != surf_vm_workstation_model)
+    if (ws_clm03->getModel() != surf_vm_workstation_model)
       continue;
 
     /* It is a virtual machine, so we can cast it to workstation_VM2013_t */
       continue;
 
     /* It is a virtual machine, so we can cast it to workstation_VM2013_t */
@@ -164,7 +164,7 @@ double WorkstationVMHL13Model::shareResources(double now)
           );
 #endif
 #if 0
           );
 #endif
 #if 0
-      void *ind_sub_host = xbt_lib_get_elm_or_null(host_lib, ws_vm2013->sub_ws->generic_resource.name);
+      void *ind_sub_host = xbt_lib_get_elm_or_null(host_lib, ws_vm2013->sub_ws->generic_resource.getName);
       surf_cpu_model_pm->action_unref(ws_vm2013->cpu_action);
       /* FIXME: this means busy loop? */
       // ws_vm2013->cpu_action = surf_cpu_model_pm->extension.cpu.execute(ind_sub_host, GUESTOS_NOISE);
       surf_cpu_model_pm->action_unref(ws_vm2013->cpu_action);
       /* FIXME: this means busy loop? */
       // ws_vm2013->cpu_action = surf_cpu_model_pm->extension.cpu.execute(ind_sub_host, GUESTOS_NOISE);
@@ -201,7 +201,7 @@ WorkstationVMHL13Lmm::WorkstationVMHL13Lmm(WorkstationVMModelPtr model, const ch
    * from the VM name, we have to make sure that the system does not call the
    * free callback for the network resource object. The network resource object
    * is still used by the physical machine. */
    * from the VM name, we have to make sure that the system does not call the
    * free callback for the network resource object. The network resource object
    * is still used by the physical machine. */
-  p_netElm = static_cast<RoutingEdgePtr>(xbt_lib_get_or_null(host_lib, sub_ws->m_name, ROUTING_HOST_LEVEL));
+  p_netElm = static_cast<RoutingEdgePtr>(xbt_lib_get_or_null(host_lib, sub_ws->getName(), ROUTING_HOST_LEVEL));
   xbt_lib_set(host_lib, name, ROUTING_HOST_LEVEL, p_netElm);
 
   p_subWs = sub_ws;
   xbt_lib_set(host_lib, name, ROUTING_HOST_LEVEL, p_netElm);
 
   p_subWs = sub_ws;
@@ -238,7 +238,7 @@ WorkstationVMHL13Lmm::WorkstationVMHL13Lmm(WorkstationVMModelPtr model, const ch
    * If you want to get a workstation_VM2013 object from host_lib, see
    * ws->generic_resouce.model->type first. If it is
    * SURF_MODEL_TYPE_VM_WORKSTATION, you can cast ws to vm_ws. */
    * If you want to get a workstation_VM2013 object from host_lib, see
    * ws->generic_resouce.model->type first. If it is
    * SURF_MODEL_TYPE_VM_WORKSTATION, you can cast ws to vm_ws. */
-  XBT_INFO("Create VM(%s)@PM(%s) with %ld mounted disks", name, sub_ws->m_name, xbt_dynar_length(p_storage));
+  XBT_INFO("Create VM(%s)@PM(%s) with %ld mounted disks", name, sub_ws->getName(), xbt_dynar_length(p_storage));
 }
 
 /*
 }
 
 /*
@@ -248,7 +248,7 @@ WorkstationVMHL13Lmm::WorkstationVMHL13Lmm(WorkstationVMModelPtr model, const ch
 WorkstationVMHL13Lmm::~WorkstationVMHL13Lmm()
 {
   /* ind_phys_workstation equals to smx_host_t */
 WorkstationVMHL13Lmm::~WorkstationVMHL13Lmm()
 {
   /* ind_phys_workstation equals to smx_host_t */
-  surf_resource_t ind_vm_workstation = xbt_lib_get_elm_or_null(host_lib, m_name);
+  surf_resource_t ind_vm_workstation = xbt_lib_get_elm_or_null(host_lib, getName());
 
   /* Before clearing the entries in host_lib, we have to pick up resources. */
   CpuCas01LmmPtr cpu = dynamic_cast<CpuCas01LmmPtr>(
 
   /* Before clearing the entries in host_lib, we have to pick up resources. */
   CpuCas01LmmPtr cpu = dynamic_cast<CpuCas01LmmPtr>(
@@ -261,9 +261,9 @@ WorkstationVMHL13Lmm::~WorkstationVMHL13Lmm()
    * Do not call xbt_lib_remove() here. It deletes all levels of the key,
    * including MSG_HOST_LEVEL and others. We should unregister only what we know.
    */
    * Do not call xbt_lib_remove() here. It deletes all levels of the key,
    * including MSG_HOST_LEVEL and others. We should unregister only what we know.
    */
-  xbt_lib_unset(host_lib, m_name, SURF_CPU_LEVEL, 0);
-  xbt_lib_unset(host_lib, m_name, ROUTING_HOST_LEVEL, 0);
-  xbt_lib_unset(host_lib, m_name, SURF_WKS_LEVEL, 0);
+  xbt_lib_unset(host_lib, getName(), SURF_CPU_LEVEL, 0);
+  xbt_lib_unset(host_lib, getName(), ROUTING_HOST_LEVEL, 0);
+  xbt_lib_unset(host_lib, getName(), SURF_WKS_LEVEL, 0);
 
   /* TODO: comment out when VM stroage is implemented. */
   // xbt_lib_unset(host_lib, name, SURF_STORAGE_LEVEL, 0);
 
   /* TODO: comment out when VM stroage is implemented. */
   // xbt_lib_unset(host_lib, name, SURF_STORAGE_LEVEL, 0);
@@ -334,9 +334,9 @@ void WorkstationVMHL13Lmm::migrate(surf_resource_t ind_dst_pm)
    WorkstationPtr ws_dst = dynamic_cast<WorkstationPtr>(
                                          static_cast<ResourcePtr>(
                                           surf_workstation_resource_priv(ind_dst_pm)));
    WorkstationPtr ws_dst = dynamic_cast<WorkstationPtr>(
                                          static_cast<ResourcePtr>(
                                           surf_workstation_resource_priv(ind_dst_pm)));
-   const char *vm_name = m_name;
-   const char *pm_name_src = p_subWs->m_name;
-   const char *pm_name_dst = ws_dst->m_name;
+   const char *vm_name = getName();
+   const char *pm_name_src = p_subWs->getName();
+   const char *pm_name_dst = ws_dst->getName();
 
    xbt_assert(ws_dst);
 
 
    xbt_assert(ws_dst);
 
@@ -377,8 +377,8 @@ void WorkstationVMHL13Lmm::migrate(surf_resource_t ind_dst_pm)
      e_surf_action_state_t state = p_action->getState();
      if (state != SURF_ACTION_DONE)
        XBT_CRITICAL("FIXME: may need a proper handling, %d", state);
      e_surf_action_state_t state = p_action->getState();
      if (state != SURF_ACTION_DONE)
        XBT_CRITICAL("FIXME: may need a proper handling, %d", state);
-     if (p_action->m_remains > 0)
-       XBT_CRITICAL("FIXME: need copy the state(?), %f", p_action->m_remains);
+     if (p_action->getRemains() > 0)
+       XBT_CRITICAL("FIXME: need copy the state(?), %f", p_action->getRemains());
 
      int ret = p_action->unref();
      xbt_assert(ret == 1, "Bug: some resource still remains");
 
      int ret = p_action->unref();
      xbt_assert(ret == 1, "Bug: some resource still remains");
@@ -404,20 +404,20 @@ void WorkstationVMHL13Lmm::setAffinity(CpuLmmPtr cpu, unsigned long mask){
  **/
 surf_resource_t WorkstationVMHL13Lmm::getPm()
 {
  **/
 surf_resource_t WorkstationVMHL13Lmm::getPm()
 {
-  return xbt_lib_get_elm_or_null(host_lib, p_subWs->m_name);
+  return xbt_lib_get_elm_or_null(host_lib, p_subWs->getName());
 }
 
 /* Adding a task to a VM updates the VCPU task on its physical machine. */
 ActionPtr WorkstationVMHL13Lmm::execute(double size)
 {
 }
 
 /* Adding a task to a VM updates the VCPU task on its physical machine. */
 ActionPtr WorkstationVMHL13Lmm::execute(double size)
 {
-  double old_cost = p_action->m_cost;
+  double old_cost = p_action->getCost();
   double new_cost = old_cost + size;
 
   XBT_DEBUG("VM(%s)@PM(%s): update dummy action's cost (%f -> %f)",
   double new_cost = old_cost + size;
 
   XBT_DEBUG("VM(%s)@PM(%s): update dummy action's cost (%f -> %f)",
-      m_name, p_subWs->m_name,
+      getName(), p_subWs->getName(),
       old_cost, new_cost);
 
       old_cost, new_cost);
 
-  p_action->m_cost = new_cost;
+  p_action->setCost(new_cost);
 
   return WorkstationCLM03Lmm::execute(size);
 }
 
   return WorkstationCLM03Lmm::execute(size);
 }
index 5b66145..4c49591 100644 (file)
@@ -37,7 +37,7 @@ WorkstationVMLmm::WorkstationVMLmm(RoutingEdgePtr netElm, CpuPtr cpu)
 WorkstationVM::~WorkstationVM()
 {
   /* ind_phys_workstation equals to smx_host_t */
 WorkstationVM::~WorkstationVM()
 {
   /* ind_phys_workstation equals to smx_host_t */
-  surf_resource_t ind_vm_workstation = xbt_lib_get_elm_or_null(host_lib, m_name);
+  surf_resource_t ind_vm_workstation = xbt_lib_get_elm_or_null(host_lib, getName());
 
   /* Before clearing the entries in host_lib, we have to pick up resources. */
   CpuCas01LmmPtr cpu = dynamic_cast<CpuCas01LmmPtr>(
 
   /* Before clearing the entries in host_lib, we have to pick up resources. */
   CpuCas01LmmPtr cpu = dynamic_cast<CpuCas01LmmPtr>(
@@ -50,9 +50,9 @@ WorkstationVM::~WorkstationVM()
    * Do not call xbt_lib_remove() here. It deletes all levels of the key,
    * including MSG_HOST_LEVEL and others. We should unregister only what we know.
    */
    * Do not call xbt_lib_remove() here. It deletes all levels of the key,
    * including MSG_HOST_LEVEL and others. We should unregister only what we know.
    */
-  xbt_lib_unset(host_lib, m_name, SURF_CPU_LEVEL, 0);
-  xbt_lib_unset(host_lib, m_name, ROUTING_HOST_LEVEL, 0);
-  xbt_lib_unset(host_lib, m_name, SURF_WKS_LEVEL, 0);
+  xbt_lib_unset(host_lib, getName(), SURF_CPU_LEVEL, 0);
+  xbt_lib_unset(host_lib, getName(), ROUTING_HOST_LEVEL, 0);
+  xbt_lib_unset(host_lib, getName(), SURF_WKS_LEVEL, 0);
 
   /* TODO: comment out when VM stroage is implemented. */
   // xbt_lib_unset(host_lib, name, SURF_STORAGE_LEVEL, 0);
 
   /* TODO: comment out when VM stroage is implemented. */
   // xbt_lib_unset(host_lib, name, SURF_STORAGE_LEVEL, 0);
@@ -72,7 +72,7 @@ WorkstationVM::~WorkstationVM()
  **/
 surf_resource_t WorkstationVM::getPm()
 {
  **/
 surf_resource_t WorkstationVM::getPm()
 {
-  return xbt_lib_get_elm_or_null(host_lib, p_subWs->m_name);
+  return xbt_lib_get_elm_or_null(host_lib, p_subWs->getName());
 }
 
 /**********
 }
 
 /**********
index dd7a23d..7b45c6a 100644 (file)
@@ -44,7 +44,7 @@ void surf_workstation_model_init_compound()
   sg_platf_host_add_cb(workstation_new);
 }
 
   sg_platf_host_add_cb(workstation_new);
 }
 
-WorkstationCLM03Model::WorkstationCLM03Model(string name)
+WorkstationCLM03Model::WorkstationCLM03Model(const char *name)
  : WorkstationModel(name)
 {}
 
  : WorkstationModel(name)
 {}
 
@@ -61,14 +61,14 @@ void WorkstationCLM03Model::parseInit(sg_platf_host_cbarg_t host){
   createResource(host->id);
 }
 
   createResource(host->id);
 }
 
-WorkstationPtr WorkstationCLM03Model::createResource(string name){
+WorkstationPtr WorkstationCLM03Model::createResource(const char *name){
 
 
-  WorkstationPtr workstation = new WorkstationCLM03Lmm(surf_workstation_model, name.c_str(), NULL,
-                 (xbt_dynar_t)xbt_lib_get_or_null(storage_lib, name.c_str(), ROUTING_STORAGE_HOST_LEVEL),
-                 (RoutingEdgePtr)xbt_lib_get_or_null(host_lib, name.c_str(), ROUTING_HOST_LEVEL),
-                 dynamic_cast<CpuPtr>(static_cast<ResourcePtr>(xbt_lib_get_or_null(host_lib, name.c_str(), SURF_CPU_LEVEL))));
-  XBT_DEBUG("Create workstation %s with %ld mounted disks", name.c_str(), xbt_dynar_length(workstation->p_storage));
-  xbt_lib_set(host_lib, name.c_str(), SURF_WKS_LEVEL, static_cast<ResourcePtr>(workstation));
+  WorkstationPtr workstation = new WorkstationCLM03Lmm(surf_workstation_model, name, NULL,
+                 (xbt_dynar_t)xbt_lib_get_or_null(storage_lib, name, ROUTING_STORAGE_HOST_LEVEL),
+                 (RoutingEdgePtr)xbt_lib_get_or_null(host_lib, name, ROUTING_HOST_LEVEL),
+                 dynamic_cast<CpuPtr>(static_cast<ResourcePtr>(xbt_lib_get_or_null(host_lib, name, SURF_CPU_LEVEL))));
+  XBT_DEBUG("Create workstation %s with %ld mounted disks", name, xbt_dynar_length(workstation->p_storage));
+  xbt_lib_set(host_lib, name, SURF_WKS_LEVEL, static_cast<ResourcePtr>(workstation));
   return workstation;
 }
 
   return workstation;
 }
 
@@ -82,9 +82,9 @@ double WorkstationCLM03Model::shareResources(double now){
        min_by_sto = surf_storage_model->shareResources(now);
 
   XBT_DEBUG("model %p, %s min_by_cpu %f, %s min_by_net %f, %s min_by_sto %f",
        min_by_sto = surf_storage_model->shareResources(now);
 
   XBT_DEBUG("model %p, %s min_by_cpu %f, %s min_by_net %f, %s min_by_sto %f",
-      this, surf_cpu_model_pm->m_name.c_str(), min_by_cpu,
-            surf_network_model->m_name.c_str(), min_by_net,
-            surf_storage_model->m_name.c_str(), min_by_sto);
+      this, surf_cpu_model_pm->getName(), min_by_cpu,
+            surf_network_model->getName(), min_by_net,
+            surf_storage_model->getName(), min_by_sto);
 
   double res = max(max(min_by_cpu, min_by_net), min_by_sto);
   if (min_by_cpu >= 0.0 && min_by_cpu < res)
 
   double res = max(max(min_by_cpu, min_by_net), min_by_sto);
   if (min_by_cpu >= 0.0 && min_by_cpu < res)
index 08eb43e..ccf2480 100644 (file)
@@ -25,11 +25,11 @@ typedef WorkstationCLM03ActionLmm *WorkstationCLM03ActionLmmPtr;
 
 class WorkstationCLM03Model : virtual public WorkstationModel {
 public:
 
 class WorkstationCLM03Model : virtual public WorkstationModel {
 public:
-  WorkstationCLM03Model(string name);
+  WorkstationCLM03Model(const char *name);
   WorkstationCLM03Model();
   ~WorkstationCLM03Model();
   void parseInit(sg_platf_host_cbarg_t host);
   WorkstationCLM03Model();
   ~WorkstationCLM03Model();
   void parseInit(sg_platf_host_cbarg_t host);
-  WorkstationPtr createResource(string name);
+  WorkstationPtr createResource(const char *name);
   double shareResources(double now);
 
   void updateActionsState(double now, double delta);
   double shareResources(double now);
 
   void updateActionsState(double now, double delta);
index 3b4341d..ddcfab7 100644 (file)
@@ -11,7 +11,7 @@ WorkstationModelPtr surf_workstation_model = NULL;
 /*********
  * Model *
  *********/
 /*********
  * Model *
  *********/
-WorkstationModel::WorkstationModel(string name)
+WorkstationModel::WorkstationModel(const char *name)
  : Model(name)
 {
   p_cpuModel = surf_cpu_model_pm;
  : Model(name)
 {
   p_cpuModel = surf_cpu_model_pm;
@@ -47,14 +47,14 @@ void WorkstationModel::adjustWeightOfDummyCpuActions()
     if (!ws)
       continue;
     /* skip if it is not a virtual machine */
     if (!ws)
       continue;
     /* skip if it is not a virtual machine */
-    if (ws->p_model != static_cast<ModelPtr>(surf_vm_workstation_model))
+    if (ws->getModel() != static_cast<ModelPtr>(surf_vm_workstation_model))
       continue;
     xbt_assert(cpu_cas01, "cpu-less workstation");
 
     /* It is a virtual machine, so we can cast it to workstation_VM2013_t */
     WorkstationVMLmmPtr ws_vm = dynamic_cast<WorkstationVMLmmPtr>(ws);
 
       continue;
     xbt_assert(cpu_cas01, "cpu-less workstation");
 
     /* It is a virtual machine, so we can cast it to workstation_VM2013_t */
     WorkstationVMLmmPtr ws_vm = dynamic_cast<WorkstationVMLmmPtr>(ws);
 
-    int is_active = lmm_constraint_used(cpu_cas01->p_model->p_maxminSystem, cpu_cas01->p_constraint);
+    int is_active = lmm_constraint_used(cpu_cas01->getModel()->getMaxminSystem(), cpu_cas01->constraint());
     // int is_active_old = constraint_is_active(cpu_cas01);
 
     // {
     // int is_active_old = constraint_is_active(cpu_cas01);
 
     // {
@@ -124,7 +124,7 @@ double Workstation::getConsumedEnergy()
 
 xbt_dict_t Workstation::getProperties()
 {
 
 xbt_dict_t Workstation::getProperties()
 {
-  return p_cpu->m_properties;
+  return p_cpu->getProperties();
 }
 
 
 }
 
 
@@ -134,7 +134,7 @@ StoragePtr Workstation::findStorageOnMountList(const char* mount)
   s_mount_t mnt;
   unsigned int cursor;
 
   s_mount_t mnt;
   unsigned int cursor;
 
-  XBT_DEBUG("Search for storage name '%s' on '%s'", mount, m_name);
+  XBT_DEBUG("Search for storage name '%s' on '%s'", mount, getName());
   xbt_dynar_foreach(p_storage,cursor,mnt)
   {
     XBT_DEBUG("See '%s'",mnt.name);
   xbt_dynar_foreach(p_storage,cursor,mnt)
   {
     XBT_DEBUG("See '%s'",mnt.name);
@@ -143,7 +143,7 @@ StoragePtr Workstation::findStorageOnMountList(const char* mount)
       break;
     }
   }
       break;
     }
   }
-  if(!st) xbt_die("Can't find mount '%s' for '%s'", mount, m_name);
+  if(!st) xbt_die("Can't find mount '%s' for '%s'", mount, getName());
   return st;
 }
 
   return st;
 }
 
@@ -155,7 +155,7 @@ xbt_dict_t Workstation::getStorageList()
   char *storage_name = NULL;
 
   xbt_dynar_foreach(p_storage,i,mnt){
   char *storage_name = NULL;
 
   xbt_dynar_foreach(p_storage,i,mnt){
-    storage_name = (char *)dynamic_cast<StoragePtr>(static_cast<ResourcePtr>(mnt.storage))->m_name;
+    storage_name = (char *)dynamic_cast<StoragePtr>(static_cast<ResourcePtr>(mnt.storage))->getName();
     xbt_dict_set(storage_list,mnt.name,storage_name,NULL);
   }
   return storage_list;
     xbt_dict_set(storage_list,mnt.name,storage_name,NULL);
   }
   return storage_list;
@@ -163,25 +163,25 @@ xbt_dict_t Workstation::getStorageList()
 
 ActionPtr Workstation::open(const char* mount, const char* path) {
   StoragePtr st = findStorageOnMountList(mount);
 
 ActionPtr Workstation::open(const char* mount, const char* path) {
   StoragePtr st = findStorageOnMountList(mount);
-  XBT_DEBUG("OPEN on disk '%s'", st->m_name);
+  XBT_DEBUG("OPEN on disk '%s'", st->getName());
   return st->open(mount, path);
 }
 
 ActionPtr Workstation::close(surf_file_t fd) {
   StoragePtr st = findStorageOnMountList(fd->mount);
   return st->open(mount, path);
 }
 
 ActionPtr Workstation::close(surf_file_t fd) {
   StoragePtr st = findStorageOnMountList(fd->mount);
-  XBT_DEBUG("CLOSE on disk '%s'",st->m_name);
+  XBT_DEBUG("CLOSE on disk '%s'",st->getName());
   return st->close(fd);
 }
 
 ActionPtr Workstation::read(surf_file_t fd, sg_size_t size) {
   StoragePtr st = findStorageOnMountList(fd->mount);
   return st->close(fd);
 }
 
 ActionPtr Workstation::read(surf_file_t fd, sg_size_t size) {
   StoragePtr st = findStorageOnMountList(fd->mount);
-  XBT_DEBUG("READ on disk '%s'",st->m_name);
+  XBT_DEBUG("READ on disk '%s'",st->getName());
   return st->read(fd, size);
 }
 
 ActionPtr Workstation::write(surf_file_t fd, sg_size_t size) {
   StoragePtr st = findStorageOnMountList(fd->mount);
   return st->read(fd, size);
 }
 
 ActionPtr Workstation::write(surf_file_t fd, sg_size_t size) {
   StoragePtr st = findStorageOnMountList(fd->mount);
-  XBT_DEBUG("WRITE on disk '%s'",st->m_name);
+  XBT_DEBUG("WRITE on disk '%s'",st->getName());
   return st->write(fd, size);
 }
 
   return st->write(fd, size);
 }
 
@@ -195,10 +195,10 @@ int Workstation::unlink(surf_file_t fd) {
     /* Check if the file is on this storage */
     if (!xbt_dict_get_or_null(st->p_content, fd->name)){
       XBT_WARN("File %s is not on disk %s. Impossible to unlink", fd->name,
     /* Check if the file is on this storage */
     if (!xbt_dict_get_or_null(st->p_content, fd->name)){
       XBT_WARN("File %s is not on disk %s. Impossible to unlink", fd->name,
-          st->m_name);
+          st->getName());
       return 0;
     } else {
       return 0;
     } else {
-      XBT_DEBUG("UNLINK on disk '%s'",st->m_name);
+      XBT_DEBUG("UNLINK on disk '%s'",st->getName());
       st->m_usedSize -= fd->size;
 
       // Remove the file from storage
       st->m_usedSize -= fd->size;
 
       // Remove the file from storage
@@ -230,7 +230,7 @@ xbt_dynar_t Workstation::getInfo( surf_file_t fd)
   xbt_dynar_t info = xbt_dynar_new(sizeof(void*), NULL);
   xbt_dynar_push_as(info, sg_size_t *, psize);
   xbt_dynar_push_as(info, void *, fd->mount);
   xbt_dynar_t info = xbt_dynar_new(sizeof(void*), NULL);
   xbt_dynar_push_as(info, sg_size_t *, psize);
   xbt_dynar_push_as(info, void *, fd->mount);
-  xbt_dynar_push_as(info, void *, (void *)st->m_name);
+  xbt_dynar_push_as(info, void *, (void *)st->getName());
   xbt_dynar_push_as(info, void *, st->p_typeId);
   xbt_dynar_push_as(info, void *, st->p_contentType);
 
   xbt_dynar_push_as(info, void *, st->p_typeId);
   xbt_dynar_push_as(info, void *, st->p_contentType);
 
@@ -285,7 +285,7 @@ xbt_dynar_t Workstation::getVms()
     if (!ws)
       continue;
     /* skip if it is not a virtual machine */
     if (!ws)
       continue;
     /* skip if it is not a virtual machine */
-    if (ws->p_model != static_cast<ModelPtr>(surf_vm_workstation_model))
+    if (ws->getModel() != static_cast<ModelPtr>(surf_vm_workstation_model))
       continue;
 
     /* It is a virtual machine, so we can cast it to workstation_VM2013_t */
       continue;
 
     /* It is a virtual machine, so we can cast it to workstation_VM2013_t */
index 307d2d6..a4622e7 100644 (file)
@@ -35,7 +35,7 @@ extern WorkstationModelPtr surf_workstation_model;
  *********/
 class WorkstationModel : public Model {
 public:
  *********/
 class WorkstationModel : public Model {
 public:
-  WorkstationModel(string name);
+  WorkstationModel(const char *name);
   WorkstationModel();
   ~WorkstationModel();
   virtual void adjustWeightOfDummyCpuActions();
   WorkstationModel();
   ~WorkstationModel();
   virtual void adjustWeightOfDummyCpuActions();
index f25aa1f..63e7594 100644 (file)
@@ -46,7 +46,7 @@ double WorkstationL07Model::shareResources(double /*now*/)
   void *_action;
   WorkstationL07ActionLmmPtr action;
 
   void *_action;
   WorkstationL07ActionLmmPtr action;
 
-  xbt_swag_t running_actions = this->p_runningActionSet;
+  xbt_swag_t running_actions = getRunningActionSet();
   double min = this->shareResourcesMaxMin(running_actions,
                                               ptask_maxmin_system,
                                               bottleneck_solve);
   double min = this->shareResourcesMaxMin(running_actions,
                                               ptask_maxmin_system,
                                               bottleneck_solve);
@@ -57,11 +57,11 @@ double WorkstationL07Model::shareResources(double /*now*/)
       if (min < 0) {
         min = action->m_latency;
         XBT_DEBUG("Updating min (value) with %p (start %f): %f", action,
       if (min < 0) {
         min = action->m_latency;
         XBT_DEBUG("Updating min (value) with %p (start %f): %f", action,
-               action->m_start, min);
+               action->getStartTime(), min);
       } else if (action->m_latency < min) {
         min = action->m_latency;
         XBT_DEBUG("Updating min (latency) with %p (start %f): %f", action,
       } else if (action->m_latency < min) {
         min = action->m_latency;
         XBT_DEBUG("Updating min (latency) with %p (start %f): %f", action,
-               action->m_start, min);
+               action->getStartTime(), min);
       }
     }
   }
       }
     }
   }
@@ -77,7 +77,8 @@ void WorkstationL07Model::updateActionsState(double /*now*/, double delta)
   void *_action, *_next_action;
   WorkstationL07ActionLmmPtr action;
 
   void *_action, *_next_action;
   WorkstationL07ActionLmmPtr action;
 
-  xbt_swag_foreach_safe(_action, _next_action, p_runningActionSet) {
+  xbt_swag_t actionSet = getRunningActionSet();
+  xbt_swag_foreach_safe(_action, _next_action, actionSet) {
     action = dynamic_cast<WorkstationL07ActionLmmPtr>(static_cast<ActionPtr>(_action));
 
     deltap = delta;
     action = dynamic_cast<WorkstationL07ActionLmmPtr>(static_cast<ActionPtr>(_action));
 
     deltap = delta;
@@ -89,27 +90,27 @@ void WorkstationL07Model::updateActionsState(double /*now*/, double delta)
         double_update(&(deltap), action->m_latency);
         action->m_latency = 0.0;
       }
         double_update(&(deltap), action->m_latency);
         action->m_latency = 0.0;
       }
-      if ((action->m_latency == 0.0) && (action->m_suspended == 0)) {
+      if ((action->m_latency == 0.0) && (action->isSuspended() == 0)) {
         action->updateBound();
         action->updateBound();
-        lmm_update_variable_weight(ptask_maxmin_system, action->p_variable, 1.0);
+        lmm_update_variable_weight(ptask_maxmin_system, action->getVariable(), 1.0);
       }
     }
     XBT_DEBUG("Action (%p) : remains (%g) updated by %g.",
       }
     }
     XBT_DEBUG("Action (%p) : remains (%g) updated by %g.",
-           action, action->m_remains, lmm_variable_getvalue(action->p_variable) * delta);
-    double_update(&(action->m_remains), lmm_variable_getvalue(action->p_variable) * delta);
+           action, action->getRemains(), lmm_variable_getvalue(action->getVariable()) * delta);
+    action->updateRemains(lmm_variable_getvalue(action->getVariable()) * delta);
 
 
-    if (action->m_maxDuration != NO_MAX_DURATION)
-      double_update(&(action->m_maxDuration), delta);
+    if (action->getMaxDuration() != NO_MAX_DURATION)
+      action->updateMaxDuration(delta);
 
     XBT_DEBUG("Action (%p) : remains (%g).",
 
     XBT_DEBUG("Action (%p) : remains (%g).",
-           action, action->m_remains);
-    if ((action->m_remains <= 0) &&
-        (lmm_get_variable_weight(action->p_variable) > 0)) {
-      action->m_finish = surf_get_clock();
+           action, action->getRemains());
+    if ((action->getRemains() <= 0) &&
+        (lmm_get_variable_weight(action->getVariable()) > 0)) {
+      action->finish();
       action->setState(SURF_ACTION_DONE);
       action->setState(SURF_ACTION_DONE);
-    } else if ((action->m_maxDuration != NO_MAX_DURATION) &&
-               (action->m_maxDuration <= 0)) {
-      action->m_finish = surf_get_clock();
+    } else if ((action->getMaxDuration() != NO_MAX_DURATION) &&
+               (action->getMaxDuration() <= 0)) {
+      action->finish();
      action->setState(SURF_ACTION_DONE);
     } else {
       /* Need to check that none of the model has failed */
      action->setState(SURF_ACTION_DONE);
     } else {
       /* Need to check that none of the model has failed */
@@ -117,13 +118,13 @@ void WorkstationL07Model::updateActionsState(double /*now*/, double delta)
       int i = 0;
       void *constraint_id = NULL;
 
       int i = 0;
       void *constraint_id = NULL;
 
-      while ((cnst = lmm_get_cnst_from_var(ptask_maxmin_system, action->p_variable,
+      while ((cnst = lmm_get_cnst_from_var(ptask_maxmin_system, action->getVariable(),
                                     i++))) {
         constraint_id = lmm_constraint_id(cnst);
 
                                     i++))) {
         constraint_id = lmm_constraint_id(cnst);
 
-        if (static_cast<WorkstationLmmPtr>(constraint_id)->p_stateCurrent == SURF_RESOURCE_OFF) {
+        if (static_cast<WorkstationLmmPtr>(constraint_id)->getState() == SURF_RESOURCE_OFF) {
           XBT_DEBUG("Action (%p) Failed!!", action);
           XBT_DEBUG("Action (%p) Failed!!", action);
-          action->m_finish = surf_get_clock();
+          action->finish();
           action->setState(SURF_ACTION_FAILED);
           break;
         }
           action->setState(SURF_ACTION_FAILED);
           break;
         }
@@ -175,7 +176,7 @@ ActionPtr WorkstationL07Model::executeParallelTask(int workstation_nb,
 
         xbt_dynar_foreach(route, cpt, _link) {
            link = dynamic_cast<LinkL07Ptr>(static_cast<ResourcePtr>(_link));
 
         xbt_dynar_foreach(route, cpt, _link) {
            link = dynamic_cast<LinkL07Ptr>(static_cast<ResourcePtr>(_link));
-           xbt_dict_set(ptask_parallel_task_link_set, link->m_name, link, NULL);
+           xbt_dict_set(ptask_parallel_task_link_set, link->getName(), link, NULL);
         }
       }
     }
         }
       }
     }
@@ -205,13 +206,13 @@ ActionPtr WorkstationL07Model::executeParallelTask(int workstation_nb,
                        workstation_nb + nb_link);
 
   if (action->m_latency > 0)
                        workstation_nb + nb_link);
 
   if (action->m_latency > 0)
-    lmm_update_variable_weight(ptask_maxmin_system, action->p_variable, 0.0);
+    lmm_update_variable_weight(ptask_maxmin_system, action->getVariable(), 0.0);
 
   for (i = 0; i < workstation_nb; i++)
     lmm_expand(ptask_maxmin_system,
               static_cast<CpuLmmPtr>(dynamic_cast<WorkstationL07Ptr>(
 
   for (i = 0; i < workstation_nb; i++)
     lmm_expand(ptask_maxmin_system,
               static_cast<CpuLmmPtr>(dynamic_cast<WorkstationL07Ptr>(
-                                          static_cast<ResourcePtr>(workstation_list[i]))->p_cpu)->p_constraint,
-               action->p_variable, computation_amount[i]);
+                                          static_cast<ResourcePtr>(workstation_list[i]))->p_cpu)->constraint(),
+               action->getVariable(), computation_amount[i]);
 
   for (i = 0; i < workstation_nb; i++) {
     for (j = 0; j < workstation_nb; j++) {
 
   for (i = 0; i < workstation_nb; i++) {
     for (j = 0; j < workstation_nb; j++) {
@@ -230,16 +231,16 @@ ActionPtr WorkstationL07Model::executeParallelTask(int workstation_nb,
 
       xbt_dynar_foreach(route, cpt, _link) {
         link = dynamic_cast<LinkL07Ptr>(static_cast<ResourcePtr>(_link));
 
       xbt_dynar_foreach(route, cpt, _link) {
         link = dynamic_cast<LinkL07Ptr>(static_cast<ResourcePtr>(_link));
-        lmm_expand_add(ptask_maxmin_system, link->p_constraint,
-                       action->p_variable,
+        lmm_expand_add(ptask_maxmin_system, link->constraint(),
+                       action->getVariable(),
                        communication_amount[i * workstation_nb + j]);
       }
     }
   }
 
   if (nb_link + nb_host == 0) {
                        communication_amount[i * workstation_nb + j]);
       }
     }
   }
 
   if (nb_link + nb_host == 0) {
-    action->m_cost = 1.0;
-    action->m_remains = 0.0;
+    action->setCost(1.0);
+    action->setRemains(0.0);
   }
 
   return static_cast<ActionPtr>(action);
   }
 
   return static_cast<ActionPtr>(action);
@@ -299,29 +300,12 @@ ResourcePtr CpuL07Model::createResource(const char *name, double power_scale,
                                tmgr_trace_t state_trace,
                                xbt_dict_t cpu_properties)
 {
                                tmgr_trace_t state_trace,
                                xbt_dict_t cpu_properties)
 {
-  CpuL07Ptr cpu = NULL;
   xbt_assert(!surf_workstation_resource_priv(surf_workstation_resource_by_name(name)),
               "Host '%s' declared several times in the platform file.",
               name);
 
   xbt_assert(!surf_workstation_resource_priv(surf_workstation_resource_by_name(name)),
               "Host '%s' declared several times in the platform file.",
               name);
 
-  cpu = new CpuL07(this, name, cpu_properties);
-
-  cpu->p_power.scale = power_scale;
-  xbt_assert(cpu->p_power.scale > 0, "Power has to be >0");
-
-  cpu->m_powerCurrent = power_initial;
-  if (power_trace)
-    cpu->p_power.event =
-        tmgr_history_add_trace(history, power_trace, 0.0, 0, static_cast<ResourcePtr>(cpu));
-
-  cpu->p_stateCurrent = state_initial;
-  if (state_trace)
-    cpu->p_stateEvent =
-        tmgr_history_add_trace(history, state_trace, 0.0, 0, static_cast<ResourcePtr>(cpu));
-
-  cpu->p_constraint =
-      lmm_constraint_new(ptask_maxmin_system, cpu,
-                         cpu->m_powerCurrent * cpu->p_power.scale);
+  CpuL07Ptr cpu = new CpuL07(this, name, cpu_properties,
+                                    power_scale, power_initial, power_trace,state_initial, state_trace);
 
   xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, static_cast<ResourcePtr>(cpu));
 
 
   xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, static_cast<ResourcePtr>(cpu));
 
@@ -336,33 +320,18 @@ NetworkLinkPtr NetworkL07Model::createResource(const char *name,
                                  e_surf_resource_state_t
                                  state_initial,
                                  tmgr_trace_t state_trace,
                                  e_surf_resource_state_t
                                  state_initial,
                                  tmgr_trace_t state_trace,
-                                 e_surf_link_sharing_policy_t
-                                 policy, xbt_dict_t properties)
+                                 e_surf_link_sharing_policy_t policy,
+                                 xbt_dict_t properties)
 {
 {
-  LinkL07Ptr nw_link = new LinkL07(this, name, properties);
   xbt_assert(!xbt_lib_get_or_null(link_lib, name, SURF_LINK_LEVEL),
   xbt_assert(!xbt_lib_get_or_null(link_lib, name, SURF_LINK_LEVEL),
-              "Link '%s' declared several times in the platform file.",
-              name);
+                     "Link '%s' declared several times in the platform file.",
+                     name);
 
 
-  nw_link->m_bwCurrent = bw_initial;
-  if (bw_trace)
-    nw_link->p_bwEvent =
-        tmgr_history_add_trace(history, bw_trace, 0.0, 0, static_cast<ResourcePtr>(nw_link));
-  nw_link->p_stateCurrent = state_initial;
-  nw_link->m_latCurrent = lat_initial;
-  if (lat_trace)
-    nw_link->p_latEvent =
-        tmgr_history_add_trace(history, lat_trace, 0.0, 0, static_cast<ResourcePtr>(nw_link));
-  if (state_trace)
-    nw_link->p_stateEvent =
-        tmgr_history_add_trace(history, state_trace, 0.0, 0, static_cast<ResourcePtr>(nw_link));
-
-  nw_link->p_constraint =
-      lmm_constraint_new(ptask_maxmin_system, nw_link,
-                         nw_link->m_bwCurrent);
-
-  if (policy == SURF_LINK_FATPIPE)
-    lmm_constraint_shared(nw_link->p_constraint);
+  LinkL07Ptr nw_link = new LinkL07(this, name, properties,
+                                      bw_initial, bw_trace,
+                                      lat_initial, lat_trace,
+                                      state_initial, state_trace,
+                                      policy);
 
   xbt_lib_set(link_lib, name, SURF_LINK_LEVEL, static_cast<ResourcePtr>(nw_link));
   return nw_link;
 
   xbt_lib_set(link_lib, name, SURF_LINK_LEVEL, static_cast<ResourcePtr>(nw_link));
   return nw_link;
@@ -469,36 +438,70 @@ double WorkstationL07::getConsumedEnergy()
        return 0.0;
 }
 
        return 0.0;
 }
 
-CpuL07::CpuL07(CpuL07ModelPtr model, const char* name, xbt_dict_t props)
- : Resource(model, name, props), CpuLmm() {
+CpuL07::CpuL07(CpuL07ModelPtr model, const char* name, xbt_dict_t props,
+                  double power_scale,
+                      double power_initial, tmgr_trace_t power_trace,
+                      e_surf_resource_state_t state_initial, tmgr_trace_t state_trace)
+ : Resource(model, name, props)
+ , CpuLmm(lmm_constraint_new(ptask_maxmin_system, this, power_initial * power_scale))
+{
+  p_power.scale = power_scale;
+  xbt_assert(p_power.scale > 0, "Power has to be >0");
 
 
+  m_powerCurrent = power_initial;
+  if (power_trace)
+       p_power.event = tmgr_history_add_trace(history, power_trace, 0.0, 0, static_cast<ResourcePtr>(this));
+
+  m_stateCurrent = state_initial;
+  if (state_trace)
+       p_stateEvent = tmgr_history_add_trace(history, state_trace, 0.0, 0, static_cast<ResourcePtr>(this));
 }
 
 }
 
-LinkL07::LinkL07(NetworkL07ModelPtr model, const char* name, xbt_dict_t props)
- : Resource(model, name, props), NetworkLinkLmm() {
+LinkL07::LinkL07(NetworkL07ModelPtr model, const char* name, xbt_dict_t props,
+                        double bw_initial,
+                        tmgr_trace_t bw_trace,
+                        double lat_initial,
+                        tmgr_trace_t lat_trace,
+                        e_surf_resource_state_t state_initial,
+                        tmgr_trace_t state_trace,
+                        e_surf_link_sharing_policy_t policy)
+ : Resource(model, name, props)
+ , NetworkLinkLmm(lmm_constraint_new(ptask_maxmin_system, this, bw_initial), history, state_trace)
+{
+  m_bwCurrent = bw_initial;
+  if (bw_trace)
+    p_bwEvent = tmgr_history_add_trace(history, bw_trace, 0.0, 0, static_cast<ResourcePtr>(this));
+
+  m_stateCurrent = state_initial;
+  m_latCurrent = lat_initial;
+
+  if (lat_trace)
+       p_latEvent = tmgr_history_add_trace(history, lat_trace, 0.0, 0, static_cast<ResourcePtr>(this));
 
 
+  if (policy == SURF_LINK_FATPIPE)
+       lmm_constraint_shared(constraint());
 }
 
 bool CpuL07::isUsed(){
 }
 
 bool CpuL07::isUsed(){
-  return lmm_constraint_used(ptask_maxmin_system, p_constraint);
+  return lmm_constraint_used(ptask_maxmin_system, constraint());
 }
 
 bool LinkL07::isUsed(){
 }
 
 bool LinkL07::isUsed(){
-  return lmm_constraint_used(ptask_maxmin_system, p_constraint);
+  return lmm_constraint_used(ptask_maxmin_system, constraint());
 }
 
 void CpuL07::updateState(tmgr_trace_event_t event_type, double value, double /*date*/){
 }
 
 void CpuL07::updateState(tmgr_trace_event_t event_type, double value, double /*date*/){
-  XBT_DEBUG("Updating cpu %s (%p) with value %g", m_name, this, value);
+  XBT_DEBUG("Updating cpu %s (%p) with value %g", getName(), this, value);
   if (event_type == p_power.event) {
        m_powerCurrent = value;
   if (event_type == p_power.event) {
        m_powerCurrent = value;
-    lmm_update_constraint_bound(ptask_maxmin_system, p_constraint, m_powerCurrent * p_power.scale);
+    lmm_update_constraint_bound(ptask_maxmin_system, constraint(), m_powerCurrent * p_power.scale);
     if (tmgr_trace_event_free(event_type))
       p_power.event = NULL;
   } else if (event_type == p_stateEvent) {
     if (value > 0)
     if (tmgr_trace_event_free(event_type))
       p_power.event = NULL;
   } else if (event_type == p_stateEvent) {
     if (value > 0)
-      p_stateCurrent = SURF_RESOURCE_ON;
+      m_stateCurrent = SURF_RESOURCE_ON;
     else
     else
-      p_stateCurrent = SURF_RESOURCE_OFF;
+      m_stateCurrent = SURF_RESOURCE_OFF;
     if (tmgr_trace_event_free(event_type))
       p_stateEvent = NULL;
   } else {
     if (tmgr_trace_event_free(event_type))
       p_stateEvent = NULL;
   } else {
@@ -509,10 +512,10 @@ void CpuL07::updateState(tmgr_trace_event_t event_type, double value, double /*d
 }
 
 void LinkL07::updateState(tmgr_trace_event_t event_type, double value, double date){
 }
 
 void LinkL07::updateState(tmgr_trace_event_t event_type, double value, double date){
-  XBT_DEBUG("Updating link %s (%p) with value=%f for date=%g", m_name, this, value, date);
+  XBT_DEBUG("Updating link %s (%p) with value=%f for date=%g", getName(), this, value, date);
   if (event_type == p_bwEvent) {
     m_bwCurrent = value;
   if (event_type == p_bwEvent) {
     m_bwCurrent = value;
-    lmm_update_constraint_bound(ptask_maxmin_system, p_constraint, m_bwCurrent);
+    lmm_update_constraint_bound(ptask_maxmin_system, constraint(), m_bwCurrent);
     if (tmgr_trace_event_free(event_type))
       p_bwEvent = NULL;
   } else if (event_type == p_latEvent) {
     if (tmgr_trace_event_free(event_type))
       p_bwEvent = NULL;
   } else if (event_type == p_latEvent) {
@@ -521,7 +524,7 @@ void LinkL07::updateState(tmgr_trace_event_t event_type, double value, double da
     lmm_element_t elem = NULL;
 
     m_latCurrent = value;
     lmm_element_t elem = NULL;
 
     m_latCurrent = value;
-    while ((var = lmm_get_var_from_cnst(ptask_maxmin_system, p_constraint, &elem))) {
+    while ((var = lmm_get_var_from_cnst(ptask_maxmin_system, constraint(), &elem))) {
       action = (WorkstationL07ActionLmmPtr) lmm_variable_id(var);
       action->updateBound();
     }
       action = (WorkstationL07ActionLmmPtr) lmm_variable_id(var);
       action->updateBound();
     }
@@ -529,9 +532,9 @@ void LinkL07::updateState(tmgr_trace_event_t event_type, double value, double da
       p_latEvent = NULL;
   } else if (event_type == p_stateEvent) {
     if (value > 0)
       p_latEvent = NULL;
   } else if (event_type == p_stateEvent) {
     if (value > 0)
-      p_stateCurrent = SURF_RESOURCE_ON;
+      m_stateCurrent = SURF_RESOURCE_ON;
     else
     else
-      p_stateCurrent = SURF_RESOURCE_OFF;
+      m_stateCurrent = SURF_RESOURCE_OFF;
     if (tmgr_trace_event_free(event_type))
       p_stateEvent = NULL;
   } else {
     if (tmgr_trace_event_free(event_type))
       p_stateEvent = NULL;
   } else {
@@ -543,12 +546,12 @@ void LinkL07::updateState(tmgr_trace_event_t event_type, double value, double da
 
 e_surf_resource_state_t WorkstationL07::getState()
 {
 
 e_surf_resource_state_t WorkstationL07::getState()
 {
-  return p_cpu->p_stateCurrent;
+  return p_cpu->getState();
 }
 
 e_surf_resource_state_t CpuL07::getState()
 {
 }
 
 e_surf_resource_state_t CpuL07::getState()
 {
-  return p_stateCurrent;
+  return m_stateCurrent;
 }
 
 double CpuL07::getSpeed(double load)
 }
 
 double CpuL07::getSpeed(double load)
@@ -571,7 +574,7 @@ ActionPtr WorkstationL07::execute(double size)
   communication_amount[0] = 0.0;
   computation_amount[0] = size;
 
   communication_amount[0] = 0.0;
   computation_amount[0] = size;
 
-  return static_cast<WorkstationL07ModelPtr>(p_model)->executeParallelTask(1, workstation_list,
+  return static_cast<WorkstationL07ModelPtr>(getModel())->executeParallelTask(1, workstation_list,
                                              computation_amount,
                                      communication_amount, -1);
 }
                                              computation_amount,
                                      communication_amount, -1);
 }
@@ -580,12 +583,12 @@ ActionPtr WorkstationL07::sleep(double duration)
 {
   WorkstationL07ActionLmmPtr action = NULL;
 
 {
   WorkstationL07ActionLmmPtr action = NULL;
 
-  XBT_IN("(%s,%g)", m_name, duration);
+  XBT_IN("(%s,%g)", getName(), duration);
 
   action = dynamic_cast<WorkstationL07ActionLmmPtr>(execute(1.0));
   action->m_maxDuration = duration;
   action->m_suspended = 2;
 
   action = dynamic_cast<WorkstationL07ActionLmmPtr>(execute(1.0));
   action->m_maxDuration = duration;
   action->m_suspended = 2;
-  lmm_update_variable_weight(ptask_maxmin_system, action->p_variable, 0.0);
+  lmm_update_variable_weight(ptask_maxmin_system, action->getVariable(), 0.0);
 
   XBT_OUT();
   return action;
 
   XBT_OUT();
   return action;
@@ -603,7 +606,7 @@ double LinkL07::getLatency()
 
 bool LinkL07::isShared()
 {
 
 bool LinkL07::isShared()
 {
-  return lmm_constraint_is_shared(p_constraint);
+  return lmm_constraint_is_shared(constraint());
 }
 
 /**********
 }
 
 /**********
@@ -614,9 +617,6 @@ WorkstationL07ActionLmm::~WorkstationL07ActionLmm(){
   free(p_workstationList);
   free(p_communicationAmount);
   free(p_computationAmount);
   free(p_workstationList);
   free(p_communicationAmount);
   free(p_computationAmount);
-#ifdef HAVE_TRACING
-  xbt_free(p_category);
-#endif
 }
 
 void WorkstationL07ActionLmm::updateBound()
 }
 
 void WorkstationL07ActionLmm::updateBound()
@@ -645,9 +645,9 @@ void WorkstationL07ActionLmm::updateBound()
   XBT_DEBUG("action (%p) : lat_bound = %g", this, lat_bound);
   if ((m_latency == 0.0) && (m_suspended == 0)) {
     if (m_rate < 0)
   XBT_DEBUG("action (%p) : lat_bound = %g", this, lat_bound);
   if ((m_latency == 0.0) && (m_suspended == 0)) {
     if (m_rate < 0)
-      lmm_update_variable_bound(ptask_maxmin_system, p_variable, lat_bound);
+      lmm_update_variable_bound(ptask_maxmin_system, getVariable(), lat_bound);
     else
     else
-      lmm_update_variable_bound(ptask_maxmin_system, p_variable, min(m_rate, lat_bound));
+      lmm_update_variable_bound(ptask_maxmin_system, getVariable(), min(m_rate, lat_bound));
   }
 }
 
   }
 }
 
@@ -656,8 +656,8 @@ int WorkstationL07ActionLmm::unref()
   m_refcount--;
   if (!m_refcount) {
     xbt_swag_remove(static_cast<ActionPtr>(this), p_stateSet);
   m_refcount--;
   if (!m_refcount) {
     xbt_swag_remove(static_cast<ActionPtr>(this), p_stateSet);
-    if (p_variable)
-      lmm_variable_free(ptask_maxmin_system, p_variable);
+    if (getVariable())
+      lmm_variable_free(ptask_maxmin_system, getVariable());
     delete this;
     return 1;
   }
     delete this;
     return 1;
   }
@@ -675,7 +675,7 @@ void WorkstationL07ActionLmm::suspend()
   XBT_IN("(%p))", this);
   if (m_suspended != 2) {
     m_suspended = 1;
   XBT_IN("(%p))", this);
   if (m_suspended != 2) {
     m_suspended = 1;
-    lmm_update_variable_weight(ptask_maxmin_system, p_variable, 0.0);
+    lmm_update_variable_weight(ptask_maxmin_system, getVariable(), 0.0);
   }
   XBT_OUT();
 }
   }
   XBT_OUT();
 }
@@ -684,7 +684,7 @@ void WorkstationL07ActionLmm::resume()
 {
   XBT_IN("(%p)", this);
   if (m_suspended != 2) {
 {
   XBT_IN("(%p)", this);
   if (m_suspended != 2) {
-    lmm_update_variable_weight(ptask_maxmin_system, p_variable, 1.0);
+    lmm_update_variable_weight(ptask_maxmin_system, getVariable(), 1.0);
     m_suspended = 0;
   }
   XBT_OUT();
     m_suspended = 0;
   }
   XBT_OUT();
@@ -716,7 +716,7 @@ double WorkstationL07ActionLmm::getRemains()
   return m_remains;
 }
 
   return m_remains;
 }
 
-/*static void ptask_finalize(void)
+/*FIXME:remove static void ptask_finalize(void)
 {
   xbt_dict_free(&ptask_parallel_task_link_set);
 
 {
   xbt_dict_free(&ptask_parallel_task_link_set);
 
@@ -737,21 +737,6 @@ double WorkstationL07ActionLmm::getRemains()
 /******* Resource Private    **********/
 /**************************************/
 
 /******* Resource Private    **********/
 /**************************************/
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 /**************************************/
 /*** Resource Creation & Destruction **/
 /**************************************/
 /**************************************/
 /*** Resource Creation & Destruction **/
 /**************************************/
index 35283a5..1c7cf50 100644 (file)
@@ -115,15 +115,22 @@ public:
 
 class CpuL07 : public CpuLmm {
 public:
 
 class CpuL07 : public CpuLmm {
 public:
-  CpuL07(CpuL07ModelPtr model, const char* name, xbt_dict_t properties);
+  s_surf_metric_t p_power;
+  tmgr_trace_event_t p_stateEvent;
+
+public:
+  CpuL07(CpuL07ModelPtr model, const char* name, xbt_dict_t properties,
+                double power_scale,
+                double power_initial, tmgr_trace_t power_trace,
+                e_surf_resource_state_t state_initial, tmgr_trace_t state_trace);
   bool isUsed();
   //bool isUsed() {DIE_IMPOSSIBLE;};
   void updateState(tmgr_trace_event_t event_type, double value, double date);
   e_surf_resource_state_t getState();
   double getSpeed(double load);
   double getAvailableSpeed();
   bool isUsed();
   //bool isUsed() {DIE_IMPOSSIBLE;};
   void updateState(tmgr_trace_event_t event_type, double value, double date);
   e_surf_resource_state_t getState();
   double getSpeed(double load);
   double getAvailableSpeed();
-  ActionPtr execute(double /*size*/) {DIE_IMPOSSIBLE;};
-  ActionPtr sleep(double /*duration*/) {DIE_IMPOSSIBLE;};
+  CpuActionPtr execute(double /*size*/) {DIE_IMPOSSIBLE;};
+  CpuActionPtr sleep(double /*duration*/) {DIE_IMPOSSIBLE;};
 
   double getCurrentPowerPeak() {THROW_UNIMPLEMENTED;};
   double getPowerPeakAt(int /*pstate_index*/) {THROW_UNIMPLEMENTED;};
 
   double getCurrentPowerPeak() {THROW_UNIMPLEMENTED;};
   double getPowerPeakAt(int /*pstate_index*/) {THROW_UNIMPLEMENTED;};
@@ -136,7 +143,15 @@ public:
 
 class LinkL07 : public NetworkLinkLmm {
 public:
 
 class LinkL07 : public NetworkLinkLmm {
 public:
-  LinkL07(NetworkL07ModelPtr model, const char* name, xbt_dict_t props);
+  LinkL07(NetworkL07ModelPtr model, const char* name, xbt_dict_t props,
+                 double bw_initial,
+          tmgr_trace_t bw_trace,
+          double lat_initial,
+          tmgr_trace_t lat_trace,
+          e_surf_resource_state_t
+          state_initial,
+          tmgr_trace_t state_trace,
+          e_surf_link_sharing_policy_t policy);
   ~LinkL07(){
   };
   bool isUsed();
   ~LinkL07(){
   };
   bool isUsed();
@@ -155,6 +170,14 @@ public:
  * Action *
  **********/
 class WorkstationL07ActionLmm : public WorkstationActionLmm {
  * Action *
  **********/
 class WorkstationL07ActionLmm : public WorkstationActionLmm {
+  friend ActionPtr WorkstationL07::execute(double size);
+  friend ActionPtr WorkstationL07::sleep(double duration);
+  friend ActionPtr WorkstationL07Model::executeParallelTask(int workstation_nb,
+                                                     void **workstation_list,
+                                                   double
+                                                   *computation_amount, double
+                                                   *communication_amount,
+                                                   double rate);
 public:
   WorkstationL07ActionLmm(ModelPtr model, double cost, bool failed)
   : Action(model, cost, failed), WorkstationActionLmm() {};
 public:
   WorkstationL07ActionLmm(ModelPtr model, double cost, bool failed)
   : Action(model, cost, failed), WorkstationActionLmm() {};