Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of github.com:simgrid/simgrid
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 24 Jul 2017 20:10:40 +0000 (22:10 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 24 Jul 2017 20:10:40 +0000 (22:10 +0200)
21 files changed:
include/simgrid/plugins/energy.h
include/xbt/functional.hpp
src/kernel/routing/NetZoneImpl.cpp
src/kernel/routing/TorusZone.cpp
src/kernel/routing/VivaldiZone.cpp
src/kernel/routing/VivaldiZone.hpp
src/mc/ChunkedData.hpp
src/s4u/s4u_engine.cpp
src/s4u/s4u_host.cpp
src/simix/ActorImpl.cpp
src/smpi/mpi/smpi_group.cpp
src/surf/FileImpl.cpp
src/surf/StorageImpl.cpp
src/surf/StorageImpl.hpp
src/surf/network_interface.cpp
src/surf/sg_platf.cpp
src/surf/storage_n11.cpp
src/surf/storage_n11.hpp
src/surf/xml/platf_private.hpp
src/surf/xml/surfxml_sax_cb.cpp
src/xbt/xbt_replay.cpp

index a4d9be7..2a697ab 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2016. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2016-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. */
@@ -19,7 +18,7 @@ XBT_PUBLIC(double) sg_host_get_wattmin_at(sg_host_t host, int pstate);
 XBT_PUBLIC(double) sg_host_get_wattmax_at(sg_host_t host, int pstate);
 XBT_PUBLIC(double) sg_host_get_current_consumption(sg_host_t host);
 
-#define MSG_host_energy_plugin_init() sg_energy_plugin_init()
+#define MSG_host_energy_plugin_init() sg_host_energy_plugin_init()
 #define MSG_host_get_consumed_energy(host) sg_host_get_consumed_energy(host)
 #define MSG_host_get_wattmin_at(host,pstate) sg_host_get_wattmin_at(host,pstate)
 #define MSG_host_get_wattmax_at(host,pstate) sg_host_get_wattmax_at(host,pstate)
index 4f475b8..a05a254 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2015-2016. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2015-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. */
@@ -39,10 +38,10 @@ public:
   {}
   void operator()() const
   {
-    char noarg[] = {'\0'};
     const int argc = args_->size();
     std::vector<std::string> args = *args_;
     if (not args.empty()) {
+      char noarg[] = {'\0'};
       std::unique_ptr<char* []> argv(new char*[argc + 1]);
       for (int i = 0; i != argc; ++i)
         argv[i]  = args[i].empty() ? noarg : &args[i].front();
index 2b4a84d..1486801 100644 (file)
@@ -260,16 +260,20 @@ bool NetZoneImpl::getBypassRoute(routing::NetPoint* src, routing::NetPoint* dst,
     for (int i = 0; i < max; i++) {
       if (i <= max_index_src && max <= max_index_dst) {
         key = {path_src.at(i)->netpoint_, path_dst.at(max)->netpoint_};
-        if (bypassRoutes_.find(key) != bypassRoutes_.end()) {
+        try {
           bypassedRoute = bypassRoutes_.at(key);
           break;
+        } catch (std::out_of_range& unfound) {
+          // Do nothing
         }
       }
       if (max <= max_index_src && i <= max_index_dst) {
         key = {path_src.at(max)->netpoint_, path_dst.at(i)->netpoint_};
-        if (bypassRoutes_.find(key) != bypassRoutes_.end()) {
+        try {
           bypassedRoute = bypassRoutes_.at(key);
           break;
+        } catch (std::out_of_range& unfound) {
+          // Do nothing
         }
       }
     }
@@ -279,9 +283,11 @@ bool NetZoneImpl::getBypassRoute(routing::NetPoint* src, routing::NetPoint* dst,
 
     if (max <= max_index_src && max <= max_index_dst) {
       key = {path_src.at(max)->netpoint_, path_dst.at(max)->netpoint_};
-      if (bypassRoutes_.find(key) != bypassRoutes_.end()) {
+      try {
         bypassedRoute = bypassRoutes_.at(key);
         break;
+      } catch (std::out_of_range& unfound) {
+        // Do nothing
       }
     }
   }
index dca285d..7f6b210 100644 (file)
@@ -116,7 +116,6 @@ void TorusZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg
    * Dimension based routing routes through each dimension consecutively
    * TODO Change to dynamic assignment
    */
-  unsigned int dim_product = 1;
   unsigned int current_node = src->id();
   unsigned int next_node    = 0;
   /*
@@ -142,7 +141,7 @@ void TorusZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg
   bool use_lnk_up = false; // Is this link of the form "cur -> next" or "next -> cur"?
   // false means: next -> cur
   while (current_node != dst->id()) {
-    dim_product = 1; // First, we will route in x-dimension
+    unsigned int dim_product = 1; // First, we will route in x-dimension
     int j=0;
     for (auto cur_dim : dimensions_){
       // current_node/dim_product = position in current dimension
index ddc4b6d..97849e0 100644 (file)
@@ -20,7 +20,7 @@ namespace routing {
 namespace vivaldi {
 simgrid::xbt::Extension<NetPoint, Coords> Coords::EXTENSION_ID;
 
-Coords::Coords(NetPoint* netpoint, const char* coordStr)
+Coords::Coords(NetPoint* netpoint, std::string coordStr)
 {
   if (not Coords::EXTENSION_ID.valid())
     Coords::EXTENSION_ID = NetPoint::extension_create<Coords>();
@@ -30,13 +30,16 @@ Coords::Coords(NetPoint* netpoint, const char* coordStr)
   xbt_assert(string_values.size() == 3, "Coordinates of %s must have 3 dimensions", netpoint->cname());
 
   for (auto str : string_values)
-    coords.push_back(xbt_str_parse_double(str.c_str(), "Invalid coordinate: %s"));
+    try {
+      coords.push_back(std::stod(str));
+    } catch (std::invalid_argument const& ia) {
+      throw std::invalid_argument(std::string("Invalid coordinate: ") + ia.what());
+    }
   coords.shrink_to_fit();
 
   netpoint->extension_set<Coords>(this);
-  XBT_DEBUG("Coords of %s %p: %s", netpoint->cname(), netpoint, coordStr);
+  XBT_DEBUG("Coords of %s %p: %s", netpoint->cname(), netpoint, coordStr.c_str());
 }
-Coords::~Coords() = default;
 }; // namespace vivaldi
 
 static inline double euclidean_dist_comp(int index, std::vector<double>* src, std::vector<double>* dst)
@@ -58,7 +61,7 @@ VivaldiZone::VivaldiZone(NetZone* father, const char* name) : ClusterZone(father
 {
 }
 
-void VivaldiZone::setPeerLink(NetPoint* netpoint, double bw_in, double bw_out, const char* coord)
+void VivaldiZone::setPeerLink(NetPoint* netpoint, double bw_in, double bw_out, std::string coord)
 {
   xbt_assert(netpoint->netzone() == this, "Cannot add a peer link to a netpoint that is not in this netzone");
 
@@ -83,21 +86,26 @@ void VivaldiZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cba
   }
 
   /* Retrieve the private links */
-  if (privateLinks_.find(src->id()) != privateLinks_.end()) {
+  try {
     std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(src->id());
     if (info.first) {
       route->link_list->push_back(info.first);
       if (lat)
         *lat += info.first->latency();
     }
+  } catch (std::out_of_range& unfound) {
+    XBT_DEBUG("Source of private link (%u) doesn't exist", src->id());
   }
-  if (privateLinks_.find(dst->id()) != privateLinks_.end()) {
+
+  try {
     std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(dst->id());
     if (info.second) {
       route->link_list->push_back(info.second);
       if (lat)
         *lat += info.second->latency();
     }
+  } catch (std::out_of_range& unfound) {
+    XBT_DEBUG("Destination of private link (%u) doesn't exist", dst->id());
   }
 
   /* Compute the extra latency due to the euclidean distance if needed */
index 9b7c9ff..83fc6b2 100644 (file)
@@ -47,7 +47,7 @@ class XBT_PRIVATE VivaldiZone : public ClusterZone {
 public:
   explicit VivaldiZone(NetZone* father, const char* name);
 
-  void setPeerLink(NetPoint* netpoint, double bw_in, double bw_out, const char* coord);
+  void setPeerLink(NetPoint* netpoint, double bw_in, double bw_out, std::string coord);
   void getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg_t into, double* latency) override;
 };
 
@@ -55,8 +55,8 @@ namespace vivaldi {
 class XBT_PRIVATE Coords {
 public:
   static simgrid::xbt::Extension<NetPoint, Coords> EXTENSION_ID;
-  explicit Coords(NetPoint* host, const char* str);
-  virtual ~Coords();
+  explicit Coords(NetPoint* host, std::string str);
+  virtual ~Coords() = default;
 
   std::vector<double> coords;
 };
index 9652ea1..93c362f 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2014-2015. 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. */
@@ -51,16 +50,15 @@ public:
   ChunkedData(ChunkedData const& that)
      : store_ (that.store_)
      , pagenos_(that.pagenos_)
-
   {
     for (std::size_t pageno : pagenos_)
       store_->ref_page(pageno);
   }
   ChunkedData(ChunkedData&& that)
+     : store(that.store_)
+     , pagenos_(std::move(that.pagenos_))
   {
-    store_ = that.store_;
     that.store_ = nullptr;
-    pagenos_ = std::move(that.pagenos_);
     that.pagenos_.clear();
   }
   ChunkedData& operator=(ChunkedData const& that)
index 71a2345..e061713 100644 (file)
@@ -128,9 +128,11 @@ NetZone* Engine::getNetzoneByNameOrNull(const char* name)
 /** @brief Retrieve the netpoint of the given name (or nullptr if not found) */
 simgrid::kernel::routing::NetPoint* Engine::getNetpointByNameOrNull(const char* name)
 {
-  if (pimpl->netpoints_.find(name) == pimpl->netpoints_.end())
+  try {
+    return pimpl->netpoints_.at(name);
+  } catch (std::out_of_range& unfound) {
     return nullptr;
-  return pimpl->netpoints_.at(name);
+  }
 }
 /** @brief Fill the provided vector with all existing netpoints */
 void Engine::getNetpointList(std::vector<simgrid::kernel::routing::NetPoint*>* list)
index a1520f9..f39b2a2 100644 (file)
@@ -87,9 +87,11 @@ Host* Host::by_name_or_null(const char* name)
 }
 Host* Host::by_name_or_null(std::string name)
 {
-  if (host_list.find(name) == host_list.end())
+  try {
+    return host_list.at(name);
+  } catch (std::out_of_range& unfound) {
     return nullptr;
-  return host_list.at(name);
+  }
 }
 
 Host *Host::current(){
index 25902ce..d9b877d 100644 (file)
@@ -823,9 +823,11 @@ xbt_dynar_t SIMIX_process_get_runnable()
 /** @brief Returns the process from PID. */
 smx_actor_t SIMIX_process_from_PID(aid_t PID)
 {
-  if (simix_global->process_list.find(PID) == simix_global->process_list.end())
+  try {
+    return simix_global->process_list.at(PID);
+  } catch (std::out_of_range& unfound) {
     return nullptr;
-  return simix_global->process_list.at(PID);
+  }
 }
 
 /** @brief returns a dynar containing all currently existing processes */
index 89abd06..bce418b 100644 (file)
@@ -73,10 +73,11 @@ int Group::rank(int index)
 {
   if (this == MPI_GROUP_EMPTY)
     return MPI_UNDEFINED;
-  if (index_to_rank_map_.find(index) == index_to_rank_map_.end())
-    return MPI_UNDEFINED;
-  else
+  try {
     return index_to_rank_map_.at(index);
+  } catch (std::out_of_range& unfound) {
+    return MPI_UNDEFINED;
+  }
 }
 
 void Group::ref()
index 5354850..e454c3a 100644 (file)
@@ -17,9 +17,9 @@ FileImpl::FileImpl(sg_storage_t st, std::string path, std::string mount) : path_
   location_ = st->getImpl();
   std::map<std::string, sg_size_t>* content = location_->getContent();
   // if file does not exist create an empty file
-  if (content->find(path) != content->end())
+  try {
     size_ = content->at(path);
-  else {
+  } catch (std::out_of_range& unfound) {
     size_ = 0;
     content->insert({path, size_});
     XBT_DEBUG("File '%s' was not found, file created.", path.c_str());
@@ -96,13 +96,13 @@ void FileImpl::move(const char* fullpath)
   /* Check if the new full path is on the same mount point */
   if (not strncmp(mount_point_.c_str(), fullpath, mount_point_.size())) {
     std::map<std::string, sg_size_t>* content = location_->getContent();
-    if (content->find(path_) != content->end()) { // src file exists
+    try { // src file exists
       sg_size_t new_size = content->at(path_);
       content->erase(path_);
       std::string path = std::string(fullpath).substr(mount_point_.size(), strlen(fullpath));
       content->insert({path.c_str(), new_size});
       XBT_DEBUG("Move file from %s to %s, size '%llu'", path_.c_str(), fullpath, new_size);
-    } else {
+    } catch (std::out_of_range& unfound) {
       XBT_WARN("File %s doesn't exist", path_.c_str());
     }
   } else {
index 03e1f87..b162a6e 100644 (file)
@@ -58,9 +58,9 @@ StorageModel::~StorageModel()
  * Resource *
  ************/
 
-StorageImpl::StorageImpl(Model* model, const char* name, lmm_system_t maxminSystem, double bread, double bwrite,
-                         const char* type_id, const char* content_name, sg_size_t size, const char* attach)
-    : Resource(model, name, lmm_constraint_new(maxminSystem, this, MAX(bread, bwrite)))
+StorageImpl::StorageImpl(Model* model, std::string name, lmm_system_t maxminSystem, double bread, double bwrite,
+                         std::string type_id, std::string content_name, sg_size_t size, std::string attach)
+    : Resource(model, name.c_str(), lmm_constraint_new(maxminSystem, this, MAX(bread, bwrite)))
     , piface_(this)
     , typeId_(type_id)
     , size_(size)
@@ -81,15 +81,15 @@ StorageImpl::~StorageImpl()
     delete content_;
 }
 
-std::map<std::string, sg_size_t>* StorageImpl::parseContent(const char* filename)
+std::map<std::string, sg_size_t>* StorageImpl::parseContent(std::string filename)
 {
   usedSize_ = 0;
-  if ((not filename) || (strcmp(filename, "") == 0))
+  if (filename.empty())
     return nullptr;
 
   std::map<std::string, sg_size_t>* parse_content = new std::map<std::string, sg_size_t>();
 
-  std::ifstream* fs = surf_ifsopen(filename);
+  std::ifstream* fs = surf_ifsopen(filename.c_str());
 
   std::string line;
   std::vector<std::string> tokens;
@@ -98,7 +98,7 @@ std::map<std::string, sg_size_t>* StorageImpl::parseContent(const char* filename
     boost::trim(line);
     if (line.length() > 0) {
       boost::split(tokens, line, boost::is_any_of(" \t"), boost::token_compress_on);
-      xbt_assert(tokens.size() == 2, "Parse error in %s: %s", filename, line.c_str());
+      xbt_assert(tokens.size() == 2, "Parse error in %s: %s", filename.c_str(), line.c_str());
       sg_size_t size = std::stoull(tokens.at(1));
 
       usedSize_ += size;
index 186fd7c..9f410d3 100644 (file)
@@ -68,8 +68,8 @@ public:
   StorageModel();
   ~StorageModel();
 
-  virtual StorageImpl* createStorage(const char* id, const char* type_id, const char* content_name,
-                                     const char* attach) = 0;
+  virtual StorageImpl* createStorage(std::string id, std::string type_id, std::string content_name,
+                                     std::string attach) = 0;
 
   std::vector<StorageImpl*> p_storageList;
 };
@@ -84,8 +84,8 @@ public:
 class StorageImpl : public simgrid::surf::Resource, public simgrid::surf::PropertyHolder {
 public:
   /** @brief Storage constructor */
-  StorageImpl(Model* model, const char* name, lmm_system_t maxminSystem, double bread, double bwrite,
-              const char* type_id, const char* content_name, sg_size_t size, const char* attach);
+  StorageImpl(Model* model, std::string name, lmm_system_t maxminSystem, double bread, double bwrite,
+              std::string type_id, std::string content_name, sg_size_t size, std::string attach);
 
   ~StorageImpl() override;
 
@@ -140,7 +140,7 @@ public:
   virtual sg_size_t getSize() { return size_; }
   virtual std::string getHost() { return attach_; }
 
-  std::map<std::string, sg_size_t>* parseContent(const char* filename);
+  std::map<std::string, sg_size_t>* parseContent(std::string filename);
   static std::unordered_map<std::string, StorageImpl*>* storagesMap() { return StorageImpl::storages; }
 
   lmm_constraint_t constraintWrite_; /* Constraint for maximum write bandwidth*/
index 81c55be..fdb99fc 100644 (file)
@@ -22,9 +22,11 @@ namespace simgrid {
 
   LinkImpl* LinkImpl::byName(const char* name)
   {
-    if (links->find(name) == links->end())
+    try {
+      return links->at(name);
+    } catch (std::out_of_range& unfound) {
       return nullptr;
-    return links->at(name);
+    }
   }
   /** @brief Returns the amount of links in the platform */
   int LinkImpl::linksCount()
index e376085..236c577 100644 (file)
@@ -359,29 +359,33 @@ void sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet)
   delete cabinet->radicals;
 }
 
-void sg_platf_new_storage(sg_platf_storage_cbarg_t storage)
+void sg_platf_new_storage(StorageCreationArgs* storage)
 {
   xbt_assert(std::find(known_storages.begin(), known_storages.end(), storage->id) == known_storages.end(),
-             "Refusing to add a second storage named \"%s\"", storage->id);
+             "Refusing to add a second storage named \"%s\"", storage->id.c_str());
 
-  xbt_assert(storage_types.find(storage->type_id) != storage_types.end(), "No storage type '%s'", storage->type_id);
-  storage_type_t stype = storage_types.at(storage->type_id);
+  storage_type_t stype;
+  try {
+    stype = storage_types.at(storage->type_id);
+  } catch (std::out_of_range& unfound) {
+    xbt_die("No storage type '%s'", storage->type_id.c_str());
+  }
 
-  XBT_DEBUG("ROUTING Create a storage name '%s' with type_id '%s' and content '%s'", storage->id, storage->type_id,
-            storage->content);
+  XBT_DEBUG("ROUTING Create a storage name '%s' with type_id '%s' and content '%s'", storage->id.c_str(),
+            storage->type_id.c_str(), storage->content.c_str());
 
   known_storages.push_back(storage->id);
 
   // if storage content is not specified use the content of storage_type if any
-  if (not strcmp(storage->content, "") && strcmp(stype->content, "")) {
-    storage->content      = stype->content;
-    XBT_DEBUG("For disk '%s' content is empty, inherit the content (of type %s)", storage->id, stype->type_id);
+  if (storage->content.empty() && strcmp(stype->content, "")) {
+    storage->content = std::string(stype->content);
+    XBT_DEBUG("For disk '%s' content is empty, inherit the content (of type %s)", storage->id.c_str(), stype->type_id);
   }
 
   XBT_DEBUG("SURF storage create resource\n\t\tid '%s'\n\t\ttype '%s' "
             "\n\t\tmodel '%s' \n\t\tcontent '%s' "
             "\n\t\tproperties '%p''\n",
-            storage->id, stype->model, stype->type_id, storage->content, storage->properties);
+            storage->id.c_str(), stype->model, stype->type_id, storage->content.c_str(), storage->properties);
 
   auto s = surf_storage_model->createStorage(storage->id, stype->type_id, storage->content, storage->attach);
 
@@ -408,21 +412,22 @@ void sg_platf_new_storage_type(sg_platf_storage_type_cbarg_t storage_type)
   stype->size = storage_type->size;
   stype->model_properties = storage_type->model_properties;
 
-  XBT_DEBUG("ROUTING Create a storage type id '%s' with model '%s', content '%s'", stype->type_id, stype->model,
+  XBT_DEBUG("Create a storage type id '%s' with model '%s', content '%s'", stype->type_id, stype->model,
             storage_type->content);
 
   storage_types.insert({std::string(stype->type_id), stype});
 }
 
-void sg_platf_new_mount(sg_platf_mount_cbarg_t mount){
+void sg_platf_new_mount(MountCreationArgs* mount)
+{
   xbt_assert(std::find(known_storages.begin(), known_storages.end(), mount->storageId) != known_storages.end(),
-             "Cannot mount non-existent disk \"%s\"", mount->storageId);
+             "Cannot mount non-existent disk \"%s\"", mount->storageId.c_str());
 
-  XBT_DEBUG("ROUTING Mount '%s' on '%s'",mount->storageId, mount->name);
+  XBT_DEBUG("Mount '%s' on '%s'", mount->storageId.c_str(), mount->name.c_str());
 
   if (mount_list.empty())
     XBT_DEBUG("Create a Mount list for %s", A_surfxml_host_id);
-  mount_list.insert({std::string(mount->name), simgrid::surf::StorageImpl::byName(mount->storageId)});
+  mount_list.insert({mount->name, simgrid::surf::StorageImpl::byName(mount->storageId.c_str())});
 }
 
 void sg_platf_new_route(sg_platf_route_cbarg_t route)
@@ -513,14 +518,14 @@ void sg_platf_new_process(sg_platf_process_cbarg_t process)
   current_property_set = nullptr;
 }
 
-void sg_platf_new_peer(sg_platf_peer_cbarg_t peer)
+void sg_platf_new_peer(PeerCreationArgs* peer)
 {
   simgrid::kernel::routing::VivaldiZone* as = dynamic_cast<simgrid::kernel::routing::VivaldiZone*>(current_routing);
   xbt_assert(as, "<peer> tag can only be used in Vivaldi netzones.");
 
   std::vector<double> speedPerPstate;
   speedPerPstate.push_back(peer->speed);
-  simgrid::s4u::Host* host = as->createHost(peer->id, &speedPerPstate, 1, nullptr);
+  simgrid::s4u::Host* host = as->createHost(peer->id.c_str(), &speedPerPstate, 1, nullptr);
 
   as->setPeerLink(host->pimpl_netpoint, peer->bw_in, peer->bw_out, peer->coord);
 
index dd44583..5131db9 100644 (file)
@@ -46,21 +46,22 @@ void surf_storage_model_init_default()
 namespace simgrid {
 namespace surf {
 
-StorageImpl* StorageN11Model::createStorage(const char* id, const char* type_id, const char* content_name,
-                                            const char* attach)
+StorageImpl* StorageN11Model::createStorage(std::string id, std::string type_id, std::string content_name,
+                                            std::string attach)
 {
   storage_type_t storage_type = storage_types.at(type_id);
 
-  double Bread =
-      surf_parse_get_bandwidth(storage_type->model_properties->at("Bread").c_str(), "property Bread, storage", type_id);
+  double Bread = surf_parse_get_bandwidth(storage_type->model_properties->at("Bread").c_str(),
+                                          "property Bread, storage", type_id.c_str());
   double Bwrite = surf_parse_get_bandwidth(storage_type->model_properties->at("Bwrite").c_str(),
-                                           "property Bwrite, storage", type_id);
+                                           "property Bwrite, storage", type_id.c_str());
 
-  StorageImpl* storage = new StorageN11(this, id, maxminSystem_, Bread, Bwrite, type_id, (char*)content_name,
-                                        storage_type->size, (char*)attach);
+  StorageImpl* storage =
+      new StorageN11(this, id, maxminSystem_, Bread, Bwrite, type_id, content_name, storage_type->size, attach);
   storageCreatedCallbacks(storage);
 
-  XBT_DEBUG("SURF storage create resource\n\t\tid '%s'\n\t\ttype '%s'\n\t\tBread '%f'\n", id, type_id, Bread);
+  XBT_DEBUG("SURF storage create resource\n\t\tid '%s'\n\t\ttype '%s'\n\t\tBread '%f'\n", id.c_str(), type_id.c_str(),
+            Bread);
 
   p_storageList.push_back(storage);
 
@@ -111,8 +112,8 @@ void StorageN11Model::updateActionsState(double /*now*/, double delta)
  * Resource *
  ************/
 
-StorageN11::StorageN11(StorageModel* model, const char* name, lmm_system_t maxminSystem, double bread, double bwrite,
-                       const char* type_id, char* content_name, sg_size_t size, char* attach)
+StorageN11::StorageN11(StorageModel* model, std::string name, lmm_system_t maxminSystem, double bread, double bwrite,
+                       std::string type_id, std::string content_name, sg_size_t size, std::string attach)
     : StorageImpl(model, name, maxminSystem, bread, bwrite, type_id, content_name, size, attach)
 {
   XBT_DEBUG("Create resource with Bread '%f' Bwrite '%f' and Size '%llu'", bread, bwrite, size);
index 42793eb..5e3ff38 100644 (file)
@@ -29,8 +29,8 @@ class XBT_PRIVATE StorageN11Action;
 
 class StorageN11Model : public StorageModel {
 public:
-  StorageImpl* createStorage(const char* id, const char* type_id, const char* content_name,
-                             const char* attach) override;
+  StorageImpl* createStorage(std::string id, std::string type_id, std::string content_name,
+                             std::string attach) override;
   double nextOccuringEvent(double now) override;
   void updateActionsState(double now, double delta) override;
 };
@@ -41,8 +41,8 @@ public:
 
 class StorageN11 : public StorageImpl {
 public:
-  StorageN11(StorageModel* model, const char* name, lmm_system_t maxminSystem, double bread, double bwrite,
-             const char* type_id, char* content_name, sg_size_t size, char* attach);
+  StorageN11(StorageModel* model, std::string name, lmm_system_t maxminSystem, double bread, double bwrite,
+             std::string type_id, std::string content_name, sg_size_t size, std::string attach);
   virtual ~StorageN11() = default;
   StorageAction* read(sg_size_t size);
   StorageAction* write(sg_size_t size);
index d6b4dd8..1989a47 100644 (file)
@@ -72,16 +72,16 @@ public:
   xbt_dict_t properties               = nullptr;
 };
 
-typedef struct s_sg_platf_peer_cbarg *sg_platf_peer_cbarg_t;
-typedef struct s_sg_platf_peer_cbarg {
-  const char* id;
+class PeerCreationArgs {
+public:
+  std::string id;
   double speed;
   double bw_in;
   double bw_out;
-  const char* coord;
+  std::string coord;
   tmgr_trace_t speed_trace;
   tmgr_trace_t state_trace;
-} s_sg_platf_peer_cbarg_t;
+};
 
 typedef struct s_sg_platf_route_cbarg *sg_platf_route_cbarg_t;
 typedef struct s_sg_platf_route_cbarg {
@@ -127,14 +127,14 @@ typedef struct s_sg_platf_cabinet_cbarg {
   double lat;
 } s_sg_platf_cabinet_cbarg_t;
 
-typedef struct s_sg_platf_storage_cbarg* sg_platf_storage_cbarg_t;
-typedef struct s_sg_platf_storage_cbarg {
-  const char* id;
-  const char* type_id;
-  const char* content;
+class StorageCreationArgs {
+public:
+  std::string id;
+  std::string type_id;
+  std::string content;
   xbt_dict_t properties;
-  const char* attach;
-} s_sg_platf_storage_cbarg_t;
+  std::string attach;
+};
 
 typedef struct s_sg_platf_storage_type_cbarg* sg_platf_storage_type_cbarg_t;
 typedef struct s_sg_platf_storage_type_cbarg {
@@ -146,11 +146,11 @@ typedef struct s_sg_platf_storage_type_cbarg {
   sg_size_t size;
 } s_sg_platf_storage_type_cbarg_t;
 
-typedef struct s_sg_platf_mount_cbarg* sg_platf_mount_cbarg_t;
-typedef struct s_sg_platf_mount_cbarg {
-  const char* storageId;
-  const char* name;
-} s_sg_platf_mount_cbarg_t;
+class MountCreationArgs {
+public:
+  std::string storageId;
+  std::string name;
+};
 
 typedef struct s_sg_platf_prop_cbarg *sg_platf_prop_cbarg_t;
 typedef struct s_sg_platf_prop_cbarg {
@@ -208,7 +208,7 @@ XBT_PUBLIC(void) sg_platf_new_hostlink(sg_platf_host_link_cbarg_t h); // Add an
 XBT_PUBLIC(simgrid::kernel::routing::NetPoint*)
 sg_platf_new_router(const char* name, const char* coords);             // Add a router  to the currently described AS
 XBT_PUBLIC(void) sg_platf_new_link(LinkCreationArgs* link);            // Add a link    to the currently described AS
-XBT_PUBLIC(void) sg_platf_new_peer   (sg_platf_peer_cbarg_t peer);     // Add a peer    to the currently described AS
+XBT_PUBLIC(void) sg_platf_new_peer(PeerCreationArgs* peer);            // Add a peer    to the currently described AS
 XBT_PUBLIC(void) sg_platf_new_cluster(sg_platf_cluster_cbarg_t clust); // Add a cluster to the currently described AS
 XBT_PUBLIC(void) sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet); // Add a cabinet to the currently described AS
 
@@ -217,9 +217,9 @@ XBT_PUBLIC(void) sg_platf_new_bypassRoute (sg_platf_route_cbarg_t bypassroute);
 
 XBT_PUBLIC(void) sg_platf_new_trace(sg_platf_trace_cbarg_t trace);
 
-XBT_PUBLIC(void) sg_platf_new_storage(sg_platf_storage_cbarg_t storage); // Add a storage to the currently described AS
+XBT_PUBLIC(void) sg_platf_new_storage(StorageCreationArgs* storage); // Add a storage to the currently described AS
 XBT_PUBLIC(void) sg_platf_new_storage_type(sg_platf_storage_type_cbarg_t storage_type);
-XBT_PUBLIC(void) sg_platf_new_mount(sg_platf_mount_cbarg_t mount);
+XBT_PUBLIC(void) sg_platf_new_mount(MountCreationArgs* mount);
 
 XBT_PUBLIC(void) sg_platf_new_process(sg_platf_process_cbarg_t process);
 XBT_PRIVATE void sg_platf_trace_connect(sg_platf_trace_connect_cbarg_t trace_connect);
index b82863a..c348cd5 100644 (file)
@@ -329,19 +329,17 @@ xbt_dict_t random_data_list = nullptr;
 YY_BUFFER_STATE surf_input_buffer;
 FILE *surf_file_to_parse = nullptr;
 
-/*
- * Stuff relative to storage
- */
+/* Stuff relative to storage */
 void STag_surfxml_storage()
 {
   ZONE_TAG = 0;
   XBT_DEBUG("STag_surfxml_storage");
   xbt_assert(current_property_set == nullptr, "Someone forgot to reset the property set to nullptr in its closing tag (or XML malformed)");
 }
+
 void ETag_surfxml_storage()
 {
-  s_sg_platf_storage_cbarg_t storage;
-  memset(&storage,0,sizeof(storage));
+  StorageCreationArgs storage;
 
   storage.properties   = current_property_set;
   current_property_set = nullptr;
@@ -349,8 +347,8 @@ void ETag_surfxml_storage()
   storage.id           = A_surfxml_storage_id;
   storage.type_id      = A_surfxml_storage_typeId;
   storage.content      = A_surfxml_storage_content;
-
   storage.attach       = A_surfxml_storage_attach;
+
   sg_platf_new_storage(&storage);
 }
 void STag_surfxml_storage___type()
@@ -378,14 +376,15 @@ void ETag_surfxml_storage___type()
         "size of storage type", storage_type.id);
   sg_platf_new_storage_type(&storage_type);
 }
+
 void STag_surfxml_mount()
 {
   XBT_DEBUG("STag_surfxml_mount");
 }
+
 void ETag_surfxml_mount()
 {
-  s_sg_platf_mount_cbarg_t mount;
-  memset(&mount,0,sizeof(mount));
+  MountCreationArgs mount;
 
   mount.name      = A_surfxml_mount_name;
   mount.storageId = A_surfxml_mount_storageId;
@@ -666,12 +665,12 @@ void STag_surfxml_cabinet(){
 
 void STag_surfxml_peer(){
   parse_after_config();
-  s_sg_platf_peer_cbarg_t peer;
-  memset(&peer,0,sizeof(peer));
-  peer.id          = A_surfxml_peer_id;
-  peer.speed       = surf_parse_get_speed(A_surfxml_peer_speed, "speed of peer", peer.id);
-  peer.bw_in       = surf_parse_get_bandwidth(A_surfxml_peer_bw___in, "bw_in of peer", peer.id);
-  peer.bw_out      = surf_parse_get_bandwidth(A_surfxml_peer_bw___out, "bw_out of peer", peer.id);
+  PeerCreationArgs peer;
+
+  peer.id          = std::string(A_surfxml_peer_id);
+  peer.speed       = surf_parse_get_speed(A_surfxml_peer_speed, "speed of peer", peer.id.c_str());
+  peer.bw_in       = surf_parse_get_bandwidth(A_surfxml_peer_bw___in, "bw_in of peer", peer.id.c_str());
+  peer.bw_out      = surf_parse_get_bandwidth(A_surfxml_peer_bw___out, "bw_out of peer", peer.id.c_str());
   peer.coord       = A_surfxml_peer_coordinates;
   peer.speed_trace = A_surfxml_peer_availability___file[0] ? tmgr_trace_new_from_file(A_surfxml_peer_availability___file) : nullptr;
   peer.state_trace = A_surfxml_peer_state___file[0] ? tmgr_trace_new_from_file(A_surfxml_peer_state___file) : nullptr;
index b9b6612..74bc5a3 100644 (file)
@@ -78,9 +78,9 @@ static ReplayAction* get_action(char* name)
       } else {
         // Else, I have to store it for the relevant colleague
         std::queue<ReplayAction*>* otherqueue = nullptr;
-        if (action_queues.find(evtname) != action_queues.end())
+        try {
           otherqueue = action_queues.at(evtname);
-        else { // Damn. Create the queue of that guy
+        } catch (std::out_of_range& unfound) { // Damn. Create the queue of that guy
           otherqueue = new std::queue<ReplayAction*>();
           action_queues.insert({evtname, otherqueue});
         }