Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use C++ strings instead of char*.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sat, 9 Sep 2017 16:23:12 +0000 (18:23 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sat, 9 Sep 2017 19:55:26 +0000 (21:55 +0200)
16 files changed:
src/kernel/routing/DragonflyZone.cpp
src/kernel/routing/DragonflyZone.hpp
src/kernel/routing/VivaldiZone.cpp
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_ns3.cpp
src/surf/network_ns3.hpp
src/surf/ptask_L07.cpp
src/surf/ptask_L07.hpp
src/surf/sg_platf.cpp
src/surf/surf_interface.cpp
src/surf/surf_interface.hpp

index 1ea236f..e5f0846 100644 (file)
@@ -161,7 +161,7 @@ void DragonflyZone::generateRouters()
   }
 }
 
-void DragonflyZone::createLink(std::string id, int numlinks, surf::LinkImpl** linkup, surf::LinkImpl** linkdown)
+void DragonflyZone::createLink(const std::string& id, int numlinks, surf::LinkImpl** linkup, surf::LinkImpl** linkdown)
 {
   *linkup   = nullptr;
   *linkdown = nullptr;
index ceeeda3..6feea64 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2016. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2017. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -68,7 +68,7 @@ public:
   void seal() override;
   void generateRouters();
   void generateLinks();
-  void createLink(std::string id, int numlinks, surf::LinkImpl** linkup, surf::LinkImpl** linkdown);
+  void createLink(const std::string& id, int numlinks, surf::LinkImpl** linkup, surf::LinkImpl** linkdown);
 
 private:
   void rankId_to_coords(int rankId, unsigned int (*coords)[4]);
index 77ff837..d1ea847 100644 (file)
@@ -70,8 +70,8 @@ void VivaldiZone::setPeerLink(NetPoint* netpoint, double bw_in, double bw_out, s
 
   std::string link_up   = "link_" + netpoint->name() + "_UP";
   std::string link_down = "link_" + netpoint->name() + "_DOWN";
-  surf::LinkImpl* linkUp   = surf_network_model->createLink(link_up.c_str(), bw_out, 0, SURF_LINK_SHARED);
-  surf::LinkImpl* linkDown = surf_network_model->createLink(link_down.c_str(), bw_in, 0, SURF_LINK_SHARED);
+  surf::LinkImpl* linkUp   = surf_network_model->createLink(link_up, bw_out, 0, SURF_LINK_SHARED);
+  surf::LinkImpl* linkDown = surf_network_model->createLink(link_down, bw_in, 0, SURF_LINK_SHARED);
   privateLinks_.insert({netpoint->id(), {linkUp, linkDown}});
 }
 
index 30e3b08..e0ae4e4 100644 (file)
@@ -165,7 +165,7 @@ NetworkCm02Model::NetworkCm02Model(void (*specificSolveFun)(lmm_system_t self))
   maxminSystem_->solve_fun = specificSolveFun;
 }
 
-LinkImpl* NetworkCm02Model::createLink(const char* name, double bandwidth, double latency,
+LinkImpl* NetworkCm02Model::createLink(const std::string& name, double bandwidth, double latency,
                                        e_surf_link_sharing_policy_t policy)
 {
   return new NetworkCm02Link(this, name, bandwidth, latency, policy, maxminSystem_);
@@ -358,7 +358,7 @@ Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double siz
 /************
  * Resource *
  ************/
-NetworkCm02Link::NetworkCm02Link(NetworkCm02Model* model, const char* name, double bandwidth, double latency,
+NetworkCm02Link::NetworkCm02Link(NetworkCm02Model* model, const std::string& name, double bandwidth, double latency,
                                  e_surf_link_sharing_policy_t policy, lmm_system_t system)
     : LinkImpl(model, name, lmm_constraint_new(system, this, sg_bandwidth_factor * bandwidth))
 {
index 8ffa8ef..7fd4187 100644 (file)
@@ -38,7 +38,7 @@ public:
   NetworkCm02Model();
   explicit NetworkCm02Model(void (*solve_fun)(lmm_system_t self));
   virtual ~NetworkCm02Model() = default;
-  LinkImpl* createLink(const char* name, double bandwidth, double latency,
+  LinkImpl* createLink(const std::string& name, double bandwidth, double latency,
                        e_surf_link_sharing_policy_t policy) override;
   void updateActionsStateLazy(double now, double delta) override;
   void updateActionsStateFull(double now, double delta) override;
@@ -51,7 +51,7 @@ public:
 
 class NetworkCm02Link : public LinkImpl {
 public:
-  NetworkCm02Link(NetworkCm02Model* model, const char* name, double bandwidth, double latency,
+  NetworkCm02Link(NetworkCm02Model* model, const std::string& name, double bandwidth, double latency,
                   e_surf_link_sharing_policy_t policy, lmm_system_t system);
   virtual ~NetworkCm02Link() = default;
   void apply_event(tmgr_trace_event_t event, double value) override;
index 68a291a..35a66b6 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2013-2015. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2013-2017. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -20,12 +19,13 @@ void surf_network_model_init_Constant()
 
 namespace simgrid {
 namespace surf {
-LinkImpl* NetworkConstantModel::createLink(const char* name, double bw, double lat, e_surf_link_sharing_policy_t policy)
+LinkImpl* NetworkConstantModel::createLink(const std::string& name, double bw, double lat,
+                                           e_surf_link_sharing_policy_t policy)
 {
 
   xbt_die("Refusing to create the link %s: there is no link in the Constant network model. "
           "Please remove any link from your platform (and switch to routing='None')",
-          name);
+          name.c_str());
   return nullptr;
 }
 
index 61e36a5..108941c 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2013-2015. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2013-2017. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -30,7 +29,8 @@ namespace simgrid {
       double nextOccuringEvent(double now) override;
       void updateActionsState(double now, double delta) override;
 
-      LinkImpl* createLink(const char* name, double bw, double lat, e_surf_link_sharing_policy_t policy) override;
+      LinkImpl* createLink(const std::string& name, double bw, double lat,
+                           e_surf_link_sharing_policy_t policy) override;
     };
 
     /**********
index d6f78f7..6e2569a 100644 (file)
@@ -98,19 +98,18 @@ namespace simgrid {
      * Resource *
      ************/
 
-    LinkImpl::LinkImpl(simgrid::surf::NetworkModel* model, const char* name, lmm_constraint_t constraint)
+    LinkImpl::LinkImpl(simgrid::surf::NetworkModel* model, const std::string& name, lmm_constraint_t constraint)
         : Resource(model, name, constraint), piface_(this)
     {
 
-      if (strcmp(name,"__loopback__"))
-        xbt_assert(not LinkImpl::byName(name), "Link '%s' declared several times in the platform.", name);
+      if (name != "__loopback__")
+        xbt_assert(not LinkImpl::byName(name), "Link '%s' declared several times in the platform.", name.c_str());
 
       latency_.scale   = 1;
       bandwidth_.scale = 1;
 
       links->insert({name, this});
-      XBT_DEBUG("Create link '%s'",name);
-
+      XBT_DEBUG("Create link '%s'", name.c_str());
     }
 
     /** @brief use destroy() instead of this destructor */
index be48491..d8a3b0d 100644 (file)
@@ -43,7 +43,7 @@ public:
    * @param latency The initial latency of the Link in seconds
    * @param policy The sharing policy of the Link
    */
-  virtual LinkImpl* createLink(const char* name, double bandwidth, double latency,
+  virtual LinkImpl* createLink(const std::string& name, double bandwidth, double latency,
                                e_surf_link_sharing_policy_t policy) = 0;
 
   /**
@@ -114,7 +114,7 @@ public:
  */
 class LinkImpl : public simgrid::surf::Resource, public simgrid::surf::PropertyHolder {
 protected:
-  LinkImpl(simgrid::surf::NetworkModel* model, const char* name, lmm_constraint_t constraint);
+  LinkImpl(simgrid::surf::NetworkModel* model, const std::string& name, lmm_constraint_t constraint);
   ~LinkImpl() override;
 
 public:
index dd0e1c9..fe0fdee 100644 (file)
@@ -166,7 +166,7 @@ NetworkNS3Model::~NetworkNS3Model() {
   xbt_dict_free(&flowFromSock);
 }
 
-LinkImpl* NetworkNS3Model::createLink(const char* name, double bandwidth, double latency,
+LinkImpl* NetworkNS3Model::createLink(const std::string& name, double bandwidth, double latency,
                                       e_surf_link_sharing_policy_t policy)
 {
   return new LinkNS3(this, name, bandwidth, latency);
@@ -257,7 +257,7 @@ void NetworkNS3Model::updateActionsState(double now, double delta)
  * Resource *
  ************/
 
-LinkNS3::LinkNS3(NetworkNS3Model* model, const char* name, double bandwidth, double latency)
+LinkNS3::LinkNS3(NetworkNS3Model* model, const std::string& name, double bandwidth, double latency)
     : LinkImpl(model, name, nullptr)
 {
   bandwidth_.peak = bandwidth;
index 196d193..b30a7eb 100644 (file)
@@ -18,7 +18,7 @@ class NetworkNS3Model : public NetworkModel {
 public:
   NetworkNS3Model();
   ~NetworkNS3Model();
-  LinkImpl* createLink(const char* name, double bandwidth, double latency,
+  LinkImpl* createLink(const std::string& name, double bandwidth, double latency,
                        e_surf_link_sharing_policy_t policy) override;
   Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override;
   double nextOccuringEvent(double now) override;
@@ -31,7 +31,7 @@ public:
  ************/
 class LinkNS3 : public LinkImpl {
 public:
-  explicit LinkNS3(NetworkNS3Model* model, const char* name, double bandwidth, double latency);
+  explicit LinkNS3(NetworkNS3Model* model, const std::string& name, double bandwidth, double latency);
   ~LinkNS3();
 
   void apply_event(tmgr_trace_event_t event, double value) override;
index 0ee2f30..c1750d7 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2010, 2013-2015. The SimGrid Team.
+/* Copyright (c) 2007-2010, 2013-2017. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -249,7 +249,7 @@ Cpu *CpuL07Model::createCpu(simgrid::s4u::Host *host,  std::vector<double> *spee
   return new CpuL07(this, host, speedPerPstate, core);
 }
 
-LinkImpl* NetworkL07Model::createLink(const char* name, double bandwidth, double latency,
+LinkImpl* NetworkL07Model::createLink(const std::string& name, double bandwidth, double latency,
                                       e_surf_link_sharing_policy_t policy)
 {
   return new LinkL07(this, name, bandwidth, latency, policy);
@@ -267,7 +267,7 @@ CpuL07::CpuL07(CpuL07Model* model, simgrid::s4u::Host* host, std::vector<double>
 
 CpuL07::~CpuL07()=default;
 
-LinkL07::LinkL07(NetworkL07Model* model, const char* name, double bandwidth, double latency,
+LinkL07::LinkL07(NetworkL07Model* model, const std::string& name, double bandwidth, double latency,
                  e_surf_link_sharing_policy_t policy)
     : LinkImpl(model, name, lmm_constraint_new(model->getMaxminSystem(), this, bandwidth))
 {
index 5d25d4e..3b944a3 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2015. The SimGrid Team.
+/* Copyright (c) 2013-2017. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -58,7 +58,7 @@ class NetworkL07Model : public NetworkModel {
 public:
   NetworkL07Model(HostL07Model *hmodel, lmm_system_t sys);
   ~NetworkL07Model();
-  LinkImpl* createLink(const char* name, double bandwidth, double latency,
+  LinkImpl* createLink(const std::string& name, double bandwidth, double latency,
                        e_surf_link_sharing_policy_t policy) override;
 
   Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override;
@@ -84,7 +84,7 @@ protected:
 
 class LinkL07 : public LinkImpl {
 public:
-  LinkL07(NetworkL07Model* model, const char* name, double bandwidth, double latency,
+  LinkL07(NetworkL07Model* model, const std::string& name, double bandwidth, double latency,
           e_surf_link_sharing_policy_t policy);
   ~LinkL07() override;
   bool isUsed() override;
index 97ce0b1..6966739 100644 (file)
@@ -131,7 +131,7 @@ void sg_platf_new_link(LinkCreationArgs* link)
   }
   for (auto const& link_name : names) {
     simgrid::surf::LinkImpl* l =
-        surf_network_model->createLink(link_name.c_str(), link->bandwidth, link->latency, link->policy);
+        surf_network_model->createLink(link_name, link->bandwidth, link->latency, link->policy);
 
     if (link->properties) {
       for (auto const& elm : *link->properties)
index 9275ffe..a8a7239 100644 (file)
@@ -549,7 +549,7 @@ void Model::updateActionsStateFull(double /*now*/, double /*delta*/)
 namespace simgrid {
 namespace surf {
 
-Resource::Resource(Model* model, const char* name, lmm_constraint_t constraint)
+Resource::Resource(Model* model, const std::string& name, lmm_constraint_t constraint)
     : name_(name), model_(model), constraint_(constraint)
 {}
 
index 0c39619..65eea27 100644 (file)
@@ -363,7 +363,7 @@ public:
    * @param name The name of the Resource
    * @param constraint The lmm constraint associated to this Resource if it is part of a LMM component
    */
-  Resource(Model *model, const char *name, lmm_constraint_t constraint);
+  Resource(Model * model, const std::string& name, lmm_constraint_t constraint);
 
   virtual ~Resource();