Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
finish snake_case s4u::Engine
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 9 May 2018 21:58:08 +0000 (23:58 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 9 May 2018 22:50:58 +0000 (00:50 +0200)
12 files changed:
examples/s4u/platform-properties/s4u-platform-properties.cpp
examples/s4u/routing-get-clusters/s4u-routing-get-clusters.cpp
include/simgrid/s4u/Engine.hpp
src/instr/instr_paje_containers.cpp
src/instr/instr_platform.cpp
src/kernel/routing/NetPoint.cpp
src/kernel/routing/NetZoneImpl.cpp
src/kernel/routing/VivaldiZone.cpp
src/s4u/s4u_Engine.cpp
src/s4u/s4u_Netzone.cpp
src/surf/sg_platf.cpp
src/surf/xml/surfxml_sax_cb.cpp

index c4d57e0..fafbfa7 100644 (file)
@@ -71,7 +71,7 @@ static int david(int argc, char* argv[])
 static int bob(int argc, char* argv[])
 {
   /* this host also tests the properties of the AS*/
 static int bob(int argc, char* argv[])
 {
   /* this host also tests the properties of the AS*/
-  simgrid::s4u::NetZone* root = simgrid::s4u::Engine::get_instance()->getNetRoot();
+  simgrid::s4u::NetZone* root = simgrid::s4u::Engine::get_instance()->get_netzone_root();
   XBT_INFO("== Print the properties of the zone");
   XBT_INFO("   Zone property: filename -> %s", root->getProperty("filename"));
   XBT_INFO("   Zone property: date -> %s", root->getProperty("date"));
   XBT_INFO("== Print the properties of the zone");
   XBT_INFO("   Zone property: filename -> %s", root->getProperty("filename"));
   XBT_INFO("   Zone property: date -> %s", root->getProperty("date"));
index d10b415..8f7f622 100644 (file)
@@ -14,12 +14,10 @@ int main(int argc, char* argv[])
   simgrid::s4u::Engine e(&argc, argv);
   e.load_platform(argv[1]);
 
   simgrid::s4u::Engine e(&argc, argv);
   e.load_platform(argv[1]);
 
-  std::vector<simgrid::kernel::routing::ClusterZone*>* clusters =
-      new std::vector<simgrid::kernel::routing::ClusterZone*>;
+  std::vector<simgrid::kernel::routing::ClusterZone*> clusters =
+      e.filter_netzones_by_type<simgrid::kernel::routing::ClusterZone>();
 
 
-  e.getNetzoneByType<simgrid::kernel::routing::ClusterZone>(clusters);
-
-  for (auto c : *clusters) {
+  for (auto c : clusters) {
     XBT_INFO("%s", c->get_cname());
     std::vector<simgrid::s4u::Host*>* hosts = new std::vector<simgrid::s4u::Host*>;
     c->getHosts(hosts);
     XBT_INFO("%s", c->get_cname());
     std::vector<simgrid::s4u::Host*>* hosts = new std::vector<simgrid::s4u::Host*>;
     c->getHosts(hosts);
@@ -28,15 +26,11 @@ int main(int argc, char* argv[])
     delete hosts;
   }
 
     delete hosts;
   }
 
-  delete clusters;
-
-  std::vector<simgrid::kernel::routing::DragonflyZone*>* dragonfly_clusters =
-      new std::vector<simgrid::kernel::routing::DragonflyZone*>;
-
-  e.getNetzoneByType<simgrid::kernel::routing::DragonflyZone>(dragonfly_clusters);
+  std::vector<simgrid::kernel::routing::DragonflyZone*> dragonfly_clusters =
+      e.filter_netzones_by_type<simgrid::kernel::routing::DragonflyZone>();
 
 
-  if (not dragonfly_clusters->empty()) {
-    for (auto d : *dragonfly_clusters) {
+  if (not dragonfly_clusters.empty()) {
+    for (auto d : dragonfly_clusters) {
       XBT_INFO("%s' dragonfly topology:", d->get_cname());
       for (int i = 0; i < d->getHostCount(); i++) {
         unsigned int coords[4];
       XBT_INFO("%s' dragonfly topology:", d->get_cname());
       for (int i = 0; i < d->getHostCount(); i++) {
         unsigned int coords[4];
@@ -45,7 +39,6 @@ int main(int argc, char* argv[])
       }
     }
   }
       }
     }
   }
-  delete dragonfly_clusters;
 
   return 0;
 }
 
   return 0;
 }
index ead005c..43c4920 100644 (file)
@@ -107,17 +107,19 @@ public:
   simgrid::s4u::Storage* storage_by_name_or_null(std::string name);
 
   std::vector<simgrid::kernel::routing::NetPoint*> get_all_netpoints();
   simgrid::s4u::Storage* storage_by_name_or_null(std::string name);
 
   std::vector<simgrid::kernel::routing::NetPoint*> get_all_netpoints();
+  simgrid::kernel::routing::NetPoint* netpoint_by_name_or_null(std::string name);
 
 
-  /** @brief Retrieve the root netzone, containing all others */
-  simgrid::s4u::NetZone* getNetRoot();
+  simgrid::s4u::NetZone* get_netzone_root();
 
 
-  simgrid::s4u::NetZone* getNetzoneByNameOrNull(const char* name);
+  simgrid::s4u::NetZone* netzone_by_name_or_null(const char* name);
 
 
-  /** @brief Retrieves all netzones of the same type than the subtype of the whereto vector */
-  template <class T> void getNetzoneByType(std::vector<T*> * whereto) { netzoneByTypeRecursive(getNetRoot(), whereto); }
-
-  /** @brief Retrieve the netcard of the given name (or nullptr if not found) */
-  simgrid::kernel::routing::NetPoint* getNetpointByNameOrNull(std::string name);
+  /** @brief Retrieves all netzones of the type indicated by the template argument */
+  template <class T> std::vector<T*> filter_netzones_by_type()
+  {
+    std::vector<T*> res;
+    filter_netzones_by_type_recursive(get_netzone_root(), &res);
+    return res;
+  }
 
   /** Returns whether SimGrid was initialized yet -- mostly for internal use */
   static bool is_initialized();
 
   /** Returns whether SimGrid was initialized yet -- mostly for internal use */
   static bool is_initialized();
@@ -194,9 +196,8 @@ public:
     return get_all_hosts();
   }
   XBT_ATTRIB_DEPRECATED_v323("Please use Engine::get_link_count()") size_t getLinkCount() { return get_link_count(); }
     return get_all_hosts();
   }
   XBT_ATTRIB_DEPRECATED_v323("Please use Engine::get_link_count()") size_t getLinkCount() { return get_link_count(); }
-  XBT_ATTRIB_DEPRECATED_v323("Please use Engine::get_link_list()")
-      XBT_ATTRIB_DEPRECATED_v322("Engine::getLinkList() is deprecated in favor of Engine::get_all_links(). Please "
-                                 "switch before v3.22") void getLinkList(std::vector<Link*>* list);
+  XBT_ATTRIB_DEPRECATED_v322("Engine::getLinkList() is deprecated in favor of Engine::get_all_links(). Please "
+                             "switch before v3.22") void getLinkList(std::vector<Link*>* list);
   XBT_ATTRIB_DEPRECATED_v323("Please use Engine::get_link_list()") std::vector<Link*> getAllLinks()
   {
     return get_all_links();
   XBT_ATTRIB_DEPRECATED_v323("Please use Engine::get_link_list()") std::vector<Link*> getAllLinks()
   {
     return get_all_links();
@@ -208,6 +209,27 @@ public:
   XBT_ATTRIB_DEPRECATED_v323("Please use Engine::get_clock()") static double getClock() { return get_clock(); }
   XBT_ATTRIB_DEPRECATED_v323("Please use Engine::get_all_netpoints()") void getNetpointList(
       std::vector<simgrid::kernel::routing::NetPoint*>* list);
   XBT_ATTRIB_DEPRECATED_v323("Please use Engine::get_clock()") static double getClock() { return get_clock(); }
   XBT_ATTRIB_DEPRECATED_v323("Please use Engine::get_all_netpoints()") void getNetpointList(
       std::vector<simgrid::kernel::routing::NetPoint*>* list);
+  XBT_ATTRIB_DEPRECATED_v323("Please use Engine::netpoint_by_name_or_null()")
+      simgrid::kernel::routing::NetPoint* getNetpointByNameOrNull(std::string name)
+  {
+    return netpoint_by_name_or_null(name);
+  }
+  XBT_ATTRIB_DEPRECATED_v323("Please use Engine::get_netzone_root()") simgrid::s4u::NetZone* getNetRoot()
+  {
+    return get_netzone_root();
+  }
+  XBT_ATTRIB_DEPRECATED_v323(
+      "Please use Engine::netzone_by_name_or_null()") simgrid::s4u::NetZone* getNetzoneByNameOrNull(const char* name)
+  {
+    return netzone_by_name_or_null(name);
+  }
+  template <class T>
+  XBT_ATTRIB_DEPRECATED_v323("Please use Engine::filter_netzones_by_type()") void getNetzoneByType(
+      std::vector<T*>* whereto)
+  {
+    filter_netzones_by_type_recursive(get_netzone_root(), whereto);
+  }
+
   XBT_ATTRIB_DEPRECATED_v323("Please use Engine::get_instance()") static s4u::Engine* getInstance()
   {
     return get_instance();
   XBT_ATTRIB_DEPRECATED_v323("Please use Engine::get_instance()") static s4u::Engine* getInstance()
   {
     return get_instance();
@@ -236,10 +258,10 @@ extern XBT_PUBLIC xbt::signal<void(double)> on_time_advance;
 /** Callback fired when the time cannot jump because of inter-actors deadlock */
 extern XBT_PUBLIC xbt::signal<void(void)> on_deadlock;
 
 /** Callback fired when the time cannot jump because of inter-actors deadlock */
 extern XBT_PUBLIC xbt::signal<void(void)> on_deadlock;
 
-template <class T> XBT_PRIVATE void netzoneByTypeRecursive(s4u::NetZone* current, std::vector<T*>* whereto)
+template <class T> XBT_PRIVATE void filter_netzones_by_type_recursive(s4u::NetZone* current, std::vector<T*>* whereto)
 {
   for (auto const& elem : *(current->getChildren())) {
 {
   for (auto const& elem : *(current->getChildren())) {
-    netzoneByTypeRecursive(elem, whereto);
+    filter_netzones_by_type_recursive(elem, whereto);
     if (elem == dynamic_cast<T*>(elem))
       whereto->push_back(dynamic_cast<T*>(elem));
   }
     if (elem == dynamic_cast<T*>(elem))
       whereto->push_back(dynamic_cast<T*>(elem));
   }
index 2cea47f..fa9527e 100644 (file)
@@ -35,7 +35,7 @@ container_t Container::getRoot()
 NetZoneContainer::NetZoneContainer(std::string name, unsigned int level, NetZoneContainer* father)
     : Container::Container(name, "", father)
 {
 NetZoneContainer::NetZoneContainer(std::string name, unsigned int level, NetZoneContainer* father)
     : Container::Container(name, "", father)
 {
-  netpoint_ = simgrid::s4u::Engine::get_instance()->getNetpointByNameOrNull(name);
+  netpoint_ = simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(name);
   xbt_assert(netpoint_, "Element '%s' not found", name.c_str());
   if (father_) {
     type_ = father_->type_->getOrCreateContainerType(std::string("L") + std::to_string(level));
   xbt_assert(netpoint_, "Element '%s' not found", name.c_str());
   if (father_) {
     type_ = father_->type_->getOrCreateContainerType(std::string("L") + std::to_string(level));
@@ -51,7 +51,7 @@ RouterContainer::RouterContainer(std::string name, Container* father) : Containe
 {
   xbt_assert(father, "Only the Root container has no father");
 
 {
   xbt_assert(father, "Only the Root container has no father");
 
-  netpoint_ = simgrid::s4u::Engine::get_instance()->getNetpointByNameOrNull(name);
+  netpoint_ = simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(name);
   xbt_assert(netpoint_, "Element '%s' not found", name.c_str());
 
   trivaNodeTypes.insert(type_->get_name());
   xbt_assert(netpoint_, "Element '%s' not found", name.c_str());
 
   trivaNodeTypes.insert(type_->get_name());
index 26aed0e..2e13b1a 100644 (file)
@@ -241,8 +241,8 @@ static void instr_on_platform_created()
   currentContainer.clear();
   std::set<std::string>* filter = new std::set<std::string>;
   XBT_DEBUG("Starting graph extraction.");
   currentContainer.clear();
   std::set<std::string>* filter = new std::set<std::string>;
   XBT_DEBUG("Starting graph extraction.");
-  recursiveGraphExtraction(simgrid::s4u::Engine::get_instance()->getNetRoot(), simgrid::instr::Container::getRoot(),
-                           filter);
+  recursiveGraphExtraction(simgrid::s4u::Engine::get_instance()->get_netzone_root(),
+                           simgrid::instr::Container::getRoot(), filter);
   XBT_DEBUG("Graph extraction finished.");
   delete filter;
   TRACE_paje_dump_buffer(true);
   XBT_DEBUG("Graph extraction finished.");
   delete filter;
   TRACE_paje_dump_buffer(true);
@@ -455,7 +455,7 @@ xbt_graph_t instr_routing_platform_graph()
   xbt_graph_t ret                          = xbt_graph_new_graph(0, nullptr);
   std::map<std::string, xbt_node_t>* nodes = new std::map<std::string, xbt_node_t>;
   std::map<std::string, xbt_edge_t>* edges = new std::map<std::string, xbt_edge_t>;
   xbt_graph_t ret                          = xbt_graph_new_graph(0, nullptr);
   std::map<std::string, xbt_node_t>* nodes = new std::map<std::string, xbt_node_t>;
   std::map<std::string, xbt_edge_t>* edges = new std::map<std::string, xbt_edge_t>;
-  recursiveXBTGraphExtraction(ret, nodes, edges, simgrid::s4u::Engine::get_instance()->getNetRoot(),
+  recursiveXBTGraphExtraction(ret, nodes, edges, simgrid::s4u::Engine::get_instance()->get_netzone_root(),
                               simgrid::instr::Container::getRoot());
   delete nodes;
   delete edges;
                               simgrid::instr::Container::getRoot());
   delete nodes;
   delete edges;
index 9246108..04f9a23 100644 (file)
@@ -35,5 +35,5 @@ NetPoint::NetPoint(std::string name, NetPoint::Type componentType, NetZoneImpl*
  */
 simgrid::kernel::routing::NetPoint* sg_netpoint_by_name_or_null(const char* name)
 {
  */
 simgrid::kernel::routing::NetPoint* sg_netpoint_by_name_or_null(const char* name)
 {
-  return simgrid::s4u::Engine::get_instance()->getNetpointByNameOrNull(name);
+  return simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(name);
 }
 }
index 8c4f453..0c3a7dc 100644 (file)
@@ -28,7 +28,7 @@ public:
 
 NetZoneImpl::NetZoneImpl(NetZone* father, std::string name) : NetZone(father, name)
 {
 
 NetZoneImpl::NetZoneImpl(NetZone* father, std::string name) : NetZone(father, name)
 {
-  xbt_assert(nullptr == simgrid::s4u::Engine::get_instance()->getNetpointByNameOrNull(name.c_str()),
+  xbt_assert(nullptr == simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(name.c_str()),
              "Refusing to create a second NetZone called '%s'.", name.c_str());
 
   netpoint_ = new NetPoint(name, NetPoint::Type::NetZone, static_cast<NetZoneImpl*>(father));
              "Refusing to create a second NetZone called '%s'.", name.c_str());
 
   netpoint_ = new NetPoint(name, NetPoint::Type::NetZone, static_cast<NetZoneImpl*>(father));
index 3364f03..8b32044 100644 (file)
@@ -84,8 +84,8 @@ void VivaldiZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArg
   if (src->is_netzone()) {
     std::string srcName = "router_" + src->get_name();
     std::string dstName = "router_" + dst->get_name();
   if (src->is_netzone()) {
     std::string srcName = "router_" + src->get_name();
     std::string dstName = "router_" + dst->get_name();
-    route->gw_src       = simgrid::s4u::Engine::get_instance()->getNetpointByNameOrNull(srcName.c_str());
-    route->gw_dst       = simgrid::s4u::Engine::get_instance()->getNetpointByNameOrNull(dstName.c_str());
+    route->gw_src       = simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(srcName.c_str());
+    route->gw_dst       = simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(dstName.c_str());
   }
 
   /* Retrieve the private links */
   }
 
   /* Retrieve the private links */
index 9bcbae9..352e4eb 100644 (file)
@@ -188,7 +188,8 @@ void Engine::run()
   }
 }
 
   }
 }
 
-s4u::NetZone* Engine::getNetRoot()
+/** @brief Retrieve the root netzone, containing all others */
+s4u::NetZone* Engine::get_netzone_root()
 {
   return pimpl->netzone_root_;
 }
 {
   return pimpl->netzone_root_;
 }
@@ -208,13 +209,13 @@ static s4u::NetZone* netzone_by_name_recursive(s4u::NetZone* current, const char
 }
 
 /** @brief Retrieve the NetZone of the given name (or nullptr if not found) */
 }
 
 /** @brief Retrieve the NetZone of the given name (or nullptr if not found) */
-NetZone* Engine::getNetzoneByNameOrNull(const char* name)
+NetZone* Engine::netzone_by_name_or_null(const char* name)
 {
 {
-  return netzone_by_name_recursive(getNetRoot(), name);
+  return netzone_by_name_recursive(get_netzone_root(), name);
 }
 
 /** @brief Retrieve the netpoint of the given name (or nullptr if not found) */
 }
 
 /** @brief Retrieve the netpoint of the given name (or nullptr if not found) */
-simgrid::kernel::routing::NetPoint* Engine::getNetpointByNameOrNull(std::string name)
+simgrid::kernel::routing::NetPoint* Engine::netpoint_by_name_or_null(std::string name)
 {
   auto netp = pimpl->netpoints_.find(name);
   return netp == pimpl->netpoints_.end() ? nullptr : netp->second;
 {
   auto netp = pimpl->netpoints_.find(name);
   return netp == pimpl->netpoints_.end() ? nullptr : netp->second;
index d805c8c..5a60eeb 100644 (file)
@@ -111,7 +111,7 @@ void NetZone::add_route(kernel::routing::NetPoint* /*src*/, kernel::routing::Net
 
 sg_netzone_t sg_zone_get_root()
 {
 
 sg_netzone_t sg_zone_get_root()
 {
-  return simgrid::s4u::Engine::get_instance()->getNetRoot();
+  return simgrid::s4u::Engine::get_instance()->get_netzone_root();
 }
 
 const char* sg_zone_get_name(sg_netzone_t netzone)
 }
 
 const char* sg_zone_get_name(sg_netzone_t netzone)
@@ -121,7 +121,7 @@ const char* sg_zone_get_name(sg_netzone_t netzone)
 
 sg_netzone_t sg_zone_get_by_name(const char* name)
 {
 
 sg_netzone_t sg_zone_get_by_name(const char* name)
 {
-  return simgrid::s4u::Engine::get_instance()->getNetzoneByNameOrNull(name);
+  return simgrid::s4u::Engine::get_instance()->netzone_by_name_or_null(name);
 }
 
 void sg_zone_get_sons(sg_netzone_t netzone, xbt_dict_t whereto)
 }
 
 void sg_zone_get_sons(sg_netzone_t netzone, xbt_dict_t whereto)
index 86cd770..c3c3562 100644 (file)
@@ -96,7 +96,7 @@ simgrid::kernel::routing::NetPoint* sg_platf_new_router(std::string name, const
 
   if (current_routing->hierarchy_ == simgrid::kernel::routing::NetZoneImpl::RoutingMode::unset)
     current_routing->hierarchy_ = simgrid::kernel::routing::NetZoneImpl::RoutingMode::base;
 
   if (current_routing->hierarchy_ == simgrid::kernel::routing::NetZoneImpl::RoutingMode::unset)
     current_routing->hierarchy_ = simgrid::kernel::routing::NetZoneImpl::RoutingMode::base;
-  xbt_assert(nullptr == simgrid::s4u::Engine::get_instance()->getNetpointByNameOrNull(name),
+  xbt_assert(nullptr == simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(name),
              "Refusing to create a router named '%s': this name already describes a node.", name.c_str());
 
   simgrid::kernel::routing::NetPoint* netpoint =
              "Refusing to create a router named '%s': this name already describes a node.", name.c_str());
 
   simgrid::kernel::routing::NetPoint* netpoint =
index be0c93d..9e8f534 100644 (file)
@@ -404,7 +404,7 @@ void STag_surfxml_prop()
 {
   if (ZONE_TAG) { // We need to retrieve the most recently opened zone
     XBT_DEBUG("Set zone property %s -> %s", A_surfxml_prop_id, A_surfxml_prop_value);
 {
   if (ZONE_TAG) { // We need to retrieve the most recently opened zone
     XBT_DEBUG("Set zone property %s -> %s", A_surfxml_prop_id, A_surfxml_prop_value);
-    simgrid::s4u::NetZone* netzone = simgrid::s4u::Engine::get_instance()->getNetzoneByNameOrNull(A_surfxml_zone_id);
+    simgrid::s4u::NetZone* netzone = simgrid::s4u::Engine::get_instance()->netzone_by_name_or_null(A_surfxml_zone_id);
 
     netzone->setProperty(A_surfxml_prop_id, A_surfxml_prop_value);
   } else {
 
     netzone->setProperty(A_surfxml_prop_id, A_surfxml_prop_value);
   } else {