Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
mess up with parsing and exceptions
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 24 Jul 2017 13:24:06 +0000 (15:24 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 24 Jul 2017 13:24:06 +0000 (15:24 +0200)
src/kernel/routing/VivaldiZone.cpp
src/kernel/routing/VivaldiZone.hpp
src/surf/StorageImpl.cpp
src/surf/StorageImpl.hpp
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

index c2f242a..97849e0 100644 (file)
@@ -20,7 +20,7 @@ namespace routing {
 namespace vivaldi {
 simgrid::xbt::Extension<NetPoint, Coords> Coords::EXTENSION_ID;
 
 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>();
 {
   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)
   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);
   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)
 }; // 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");
 
 {
   xbt_assert(netpoint->netzone() == this, "Cannot add a peer link to a netpoint that is not in this netzone");
 
index 9b7c9ff..83fc6b2 100644 (file)
@@ -47,7 +47,7 @@ class XBT_PRIVATE VivaldiZone : public ClusterZone {
 public:
   explicit VivaldiZone(NetZone* father, const char* name);
 
 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;
 };
 
   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;
 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;
 };
 
   std::vector<double> coords;
 };
index 03e1f87..b162a6e 100644 (file)
@@ -58,9 +58,9 @@ StorageModel::~StorageModel()
  * Resource *
  ************/
 
  * 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)
     , piface_(this)
     , typeId_(type_id)
     , size_(size)
@@ -81,15 +81,15 @@ StorageImpl::~StorageImpl()
     delete content_;
 }
 
     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;
 {
   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>();
 
     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;
 
   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);
     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;
       sg_size_t size = std::stoull(tokens.at(1));
 
       usedSize_ += size;
index 186fd7c..9f410d3 100644 (file)
@@ -68,8 +68,8 @@ public:
   StorageModel();
   ~StorageModel();
 
   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;
 };
 
   std::vector<StorageImpl*> p_storageList;
 };
@@ -84,8 +84,8 @@ public:
 class StorageImpl : public simgrid::surf::Resource, public simgrid::surf::PropertyHolder {
 public:
   /** @brief Storage constructor */
 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;
 
 
   ~StorageImpl() override;
 
@@ -140,7 +140,7 @@ public:
   virtual sg_size_t getSize() { return size_; }
   virtual std::string getHost() { return attach_; }
 
   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*/
   static std::unordered_map<std::string, StorageImpl*>* storagesMap() { return StorageImpl::storages; }
 
   lmm_constraint_t constraintWrite_; /* Constraint for maximum write bandwidth*/
index e376085..236c577 100644 (file)
@@ -359,29 +359,33 @@ void sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet)
   delete cabinet->radicals;
 }
 
   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(),
 {
   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
 
   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",
   }
 
   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);
 
 
   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;
 
   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});
 }
 
             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(),
   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);
 
   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)
 }
 
 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;
 }
 
   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::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);
 
 
   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 {
 
 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);
 
 {
   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(),
   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);
 
   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);
 
 
   p_storageList.push_back(storage);
 
@@ -111,8 +112,8 @@ void StorageN11Model::updateActionsState(double /*now*/, double delta)
  * Resource *
  ************/
 
  * 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);
     : 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:
 
 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;
 };
   double nextOccuringEvent(double now) override;
   void updateActionsState(double now, double delta) override;
 };
@@ -41,8 +41,8 @@ public:
 
 class StorageN11 : public StorageImpl {
 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);
   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;
 };
 
   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;
   double speed;
   double bw_in;
   double bw_out;
-  const char* coord;
+  std::string coord;
   tmgr_trace_t speed_trace;
   tmgr_trace_t state_trace;
   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 {
 
 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;
 
   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;
   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 {
 
 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;
 
   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 {
 
 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(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
 
 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_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_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);
 
 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;
 
 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 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()
 {
 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;
 
   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.id           = A_surfxml_storage_id;
   storage.type_id      = A_surfxml_storage_typeId;
   storage.content      = A_surfxml_storage_content;
-
   storage.attach       = A_surfxml_storage_attach;
   storage.attach       = A_surfxml_storage_attach;
+
   sg_platf_new_storage(&storage);
 }
 void STag_surfxml_storage___type()
   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);
 }
         "size of storage type", storage_type.id);
   sg_platf_new_storage_type(&storage_type);
 }
+
 void STag_surfxml_mount()
 {
   XBT_DEBUG("STag_surfxml_mount");
 }
 void STag_surfxml_mount()
 {
   XBT_DEBUG("STag_surfxml_mount");
 }
+
 void ETag_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;
 
   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();
 
 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;
   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;