Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
objectifies surf::Action::State
[simgrid.git] / src / surf / network_ns3.cpp
index 3064e7d..d3f0405 100644 (file)
@@ -260,13 +260,10 @@ NetworkNS3Model::~NetworkNS3Model() {
 Link* NetworkNS3Model::createLink(const char *name, double bandwidth, double latency, e_surf_link_sharing_policy_t policy,
     xbt_dict_t properties){
 
-  Link* link = new LinkNS3(this, name, properties, bandwidth, latency);
-  Link::onCreation(link);
-  return link;
+  return new LinkNS3(this, name, properties, bandwidth, latency);
 }
 
-Action *NetworkNS3Model::communicate(NetCard *src, NetCard *dst,
-                                   double size, double rate)
+Action *NetworkNS3Model::communicate(NetCard *src, NetCard *dst, double size, double rate)
 {
   XBT_DEBUG("Communicate from %s to %s", src->name(), dst->name());
   NetworkNS3Action *action = new NetworkNS3Action(this, size, 0);
@@ -326,7 +323,7 @@ void NetworkNS3Model::updateActionsState(double now, double delta)
     action->setRemains(action->getCost() - ns3_get_socket_sent(data));
 
     if (TRACE_is_enabled() &&
-        action->getState() == SURF_ACTION_RUNNING){
+        action->getState() == Action::State::running){
       double data_sent = ns3_get_socket_sent(data);
       double data_delta_sent = data_sent - action->m_lastSent;
 
@@ -344,7 +341,7 @@ void NetworkNS3Model::updateActionsState(double now, double delta)
       xbt_dynar_push(socket_to_destroy,&key);
       XBT_DEBUG("Destroy socket %p of action %p", key, action);
       action->finish();
-      action->setState(SURF_ACTION_DONE);
+      action->setState(Action::State::done);
     }
   }
 
@@ -369,6 +366,8 @@ LinkNS3::LinkNS3(NetworkNS3Model *model, const char *name, xbt_dict_t props, dou
 {
   m_bandwidth.peak = bandwidth;
   m_latency.peak = latency;
+
+  Link::onCreation(this);
 }
 
 LinkNS3::~LinkNS3()