Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add some 'const' qualifiers.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 31 May 2021 08:22:02 +0000 (10:22 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 31 May 2021 09:20:01 +0000 (11:20 +0200)
This started with NetPoint::get_englobing_zone() and propagated quickly...

29 files changed:
examples/cpp/platform-properties/s4u-platform-properties.cpp
include/simgrid/kernel/routing/DijkstraZone.hpp
include/simgrid/kernel/routing/DragonflyZone.hpp
include/simgrid/kernel/routing/EmptyZone.hpp
include/simgrid/kernel/routing/FatTreeZone.hpp
include/simgrid/kernel/routing/FloydZone.hpp
include/simgrid/kernel/routing/FullZone.hpp
include/simgrid/kernel/routing/NetPoint.hpp
include/simgrid/kernel/routing/NetZoneImpl.hpp
include/simgrid/kernel/routing/RoutedZone.hpp
include/simgrid/kernel/routing/StarZone.hpp
include/simgrid/kernel/routing/TorusZone.hpp
include/simgrid/kernel/routing/VivaldiZone.hpp
include/simgrid/kernel/routing/WifiZone.hpp
include/simgrid/s4u/Host.hpp
src/instr/instr_interface.cpp
src/kernel/routing/DijkstraZone.cpp
src/kernel/routing/DragonflyZone.cpp
src/kernel/routing/FatTreeZone.cpp
src/kernel/routing/FloydZone.cpp
src/kernel/routing/FullZone.cpp
src/kernel/routing/NetZoneImpl.cpp
src/kernel/routing/RoutedZone.cpp
src/kernel/routing/StarZone.cpp
src/kernel/routing/TorusZone.cpp
src/kernel/routing/VivaldiZone.cpp
src/kernel/routing/WifiZone.cpp
src/s4u/s4u_Host.cpp
teshsuite/simdag/flatifier/flatifier.cpp

index 6f3f8e3..63c655e 100644 (file)
@@ -51,7 +51,7 @@ static void test_host(const std::string& hostname)
   /* Restore the value for the next test */
   thehost->set_property(exist, "180");
 
-  auto thezone = thehost->get_englobing_zone();
+  const auto* thezone = thehost->get_englobing_zone();
   XBT_INFO("== Print the properties of the zone '%s' that contains '%s'", thezone->get_cname(), hostname.c_str());
   const std::unordered_map<std::string, std::string>* zoneprops = thezone->get_properties();
   keys.clear();
index ec3992f..6799e29 100644 (file)
@@ -49,7 +49,7 @@ public:
    * After this function returns, any node in the graph
    * will have a loopback attached to it.
    */
-  void get_local_route(NetPoint* src, NetPoint* dst, Route* route, double* lat) override;
+  void get_local_route(const NetPoint* src, const NetPoint* dst, Route* route, double* lat) override;
   void add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
                  const std::vector<resource::LinkImpl*>& link_list, bool symmetrical) override;
 };
index 5e3b0a1..e543435 100644 (file)
@@ -72,7 +72,7 @@ public:
   };
 
   explicit DragonflyZone(const std::string& name);
-  void get_local_route(NetPoint* src, NetPoint* dst, Route* into, double* latency) override;
+  void get_local_route(const NetPoint* src, const NetPoint* dst, Route* into, double* latency) override;
   /**
    * @brief Parse topology parameters from string format
    *
index 4b9114c..c1eb7f7 100644 (file)
@@ -23,7 +23,7 @@ class XBT_PRIVATE EmptyZone : public NetZoneImpl {
 public:
   explicit EmptyZone(const std::string& name) : NetZoneImpl(name) {}
 
-  void get_local_route(NetPoint* src, NetPoint* dst, Route* into, double* latency) override
+  void get_local_route(const NetPoint* src, const NetPoint* dst, Route* into, double* latency) override
   {
     /* There can't be route in an Empty zone */
   }
index 75f8373..33cb078 100644 (file)
@@ -134,7 +134,7 @@ public:
   explicit FatTreeZone(const std::string& name) : ClusterBase(name){};
   FatTreeZone(const FatTreeZone&) = delete;
   FatTreeZone& operator=(const FatTreeZone&) = delete;
-  void get_local_route(NetPoint* src, NetPoint* dst, Route* into, double* latency) override;
+  void get_local_route(const NetPoint* src, const NetPoint* dst, Route* into, double* latency) override;
 
   /**
    * @brief Parse the topology parameters from string format
index 1afe574..0277648 100644 (file)
@@ -35,7 +35,7 @@ public:
   FloydZone(const FloydZone&) = delete;
   FloydZone& operator=(const FloydZone&) = delete;
 
-  void get_local_route(NetPoint* src, NetPoint* dst, Route* into, double* latency) override;
+  void get_local_route(const NetPoint* src, const NetPoint* dst, Route* into, double* latency) override;
   void add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
                  const std::vector<resource::LinkImpl*>& link_list, bool symmetrical) override;
 };
index f602e81..df8a189 100644 (file)
@@ -29,7 +29,7 @@ public:
   FullZone(const FullZone&) = delete;
   FullZone& operator=(const FullZone) = delete;
 
-  void get_local_route(NetPoint* src, NetPoint* dst, Route* into, double* latency) override;
+  void get_local_route(const NetPoint* src, const NetPoint* dst, Route* into, double* latency) override;
   void add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
                  const std::vector<resource::LinkImpl*>& link_list, bool symmetrical) override;
 };
index 7b4126c..5afa2eb 100644 (file)
@@ -35,7 +35,7 @@ public:
   const std::string& get_name() const { return name_; }
   const char* get_cname() const { return name_.c_str(); }
   /** @brief the NetZone in which this NetPoint is included */
-  NetZoneImpl* get_englobing_zone() { return englobing_zone_; }
+  NetZoneImpl* get_englobing_zone() const { return englobing_zone_; }
   /** @brief Set the NetZone in which this NetPoint is included */
   NetPoint* set_englobing_zone(NetZoneImpl* netzone_p);
   NetPoint* set_coordinates(const std::string& coords);
index 257c8e7..430a167 100644 (file)
@@ -83,7 +83,7 @@ class XBT_PUBLIC NetZoneImpl : public xbt::PropertyHolder {
   std::string name_;
   bool sealed_ = false; // We cannot add more content when sealed
 
-  std::map<std::pair<NetPoint*, NetPoint*>, BypassRoute*> bypass_routes_; // src x dst -> route
+  std::map<std::pair<const NetPoint*, const NetPoint*>, BypassRoute*> bypass_routes_; // src x dst -> route
   routing::NetPoint* netpoint_ = nullptr;                                 // Our representative in the father NetZone
 
 protected:
@@ -100,10 +100,10 @@ protected:
    * @param into Container into which the traversed links and gateway information should be pushed
    * @param latency Accumulator in which the latencies should be added (caller must set it to 0)
    */
-  virtual void get_local_route(NetPoint* src, NetPoint* dst, Route* into, double* latency) = 0;
+  virtual void get_local_route(const NetPoint* src, const NetPoint* dst, Route* into, double* latency) = 0;
   /** @brief retrieves the list of all routes of size 1 (of type src x dst x Link) */
   /* returns whether we found a bypass path */
-  bool get_bypass_route(routing::NetPoint* src, routing::NetPoint* dst,
+  bool get_bypass_route(const routing::NetPoint* src, const routing::NetPoint* dst,
                         /* OUT */ std::vector<resource::LinkImpl*>& links, double* latency,
                         std::unordered_set<NetZoneImpl*>& netzones);
 
@@ -186,11 +186,11 @@ public:
    * @param links Accumulator in which all traversed links should be pushed (caller must empty it)
    * @param latency Accumulator in which the latencies should be added (caller must set it to 0)
    */
-  static void get_global_route(routing::NetPoint* src, routing::NetPoint* dst,
+  static void get_global_route(const routing::NetPoint* src, const routing::NetPoint* dst,
                                /* OUT */ std::vector<resource::LinkImpl*>& links, double* latency);
 
   /** @brief Similar to get_global_route but get the NetZones traversed by route */
-  static void get_global_route_with_netzones(routing::NetPoint* src, routing::NetPoint* dst,
+  static void get_global_route_with_netzones(const routing::NetPoint* src, const routing::NetPoint* dst,
                                              /* OUT */ std::vector<resource::LinkImpl*>& links, double* latency,
                                              std::unordered_set<NetZoneImpl*>& netzones);
 
index 3fcbd94..7fcd038 100644 (file)
@@ -64,7 +64,7 @@ protected:
   {
     return new_extended_route(hierarchy, gw_src, gw_dst, link_list, preserve_order);
   }
-  void get_route_check_params(NetPoint* src, NetPoint* dst) const;
+  void get_route_check_params(const NetPoint* src, const NetPoint* dst) const;
   void add_route_check_params(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
                               const std::vector<resource::LinkImpl*>& link_list, bool symmetrical) const;
 };
index c8ad0be..575b60f 100644 (file)
@@ -64,7 +64,7 @@ class StarZone : public ClusterZone { // implements the old ClusterZone
 public:
   explicit StarZone(const std::string& name);
 
-  void get_local_route(NetPoint* src, NetPoint* dst, Route* route, double* latency) override;
+  void get_local_route(const NetPoint* src, const NetPoint* dst, Route* route, double* latency) override;
   void get_graph(const s_xbt_graph_t* graph, std::map<std::string, xbt_node_t, std::less<>>* nodes,
                  std::map<std::string, xbt_edge_t, std::less<>>* edges) override;
 
index 329a031..25b4290 100644 (file)
@@ -25,7 +25,7 @@ class XBT_PRIVATE TorusZone : public ClusterBase {
 public:
   explicit TorusZone(const std::string& name) : ClusterBase(name){};
   void create_torus_links(int id, int rank, unsigned int position);
-  void get_local_route(NetPoint* src, NetPoint* dst, Route* into, double* latency) override;
+  void get_local_route(const NetPoint* src, const NetPoint* dst, Route* into, double* latency) override;
   void set_topology(const std::vector<unsigned int>& dimensions);
 
   /** @brief Convert topology parameters from string to vector of uint */
index ffc6f2e..c8ec4cb 100644 (file)
@@ -48,7 +48,7 @@ class XBT_PRIVATE VivaldiZone : public StarZone {
 public:
   using StarZone::StarZone;
   void set_peer_link(NetPoint* netpoint, double bw_in, double bw_out);
-  void get_local_route(NetPoint* src, NetPoint* dst, Route* into, double* latency) override;
+  void get_local_route(const NetPoint* src, const NetPoint* dst, Route* into, double* latency) override;
 };
 
 namespace vivaldi {
index 2eb9f76..830779a 100644 (file)
@@ -29,7 +29,7 @@ public:
   WifiZone(const WifiZone&) = delete;
   WifiZone& operator=(const WifiZone) = delete;
 
-  void get_local_route(NetPoint* src, NetPoint* dst, Route* into, double* latency) override;
+  void get_local_route(const NetPoint* src, const NetPoint* dst, Route* into, double* latency) override;
   s4u::Link* create_link(const std::string& name, const std::vector<double>& bandwidths) override;
   NetPoint* get_access_point() const { return access_point_; }
 };
index c6f580c..2f6502c 100644 (file)
@@ -200,7 +200,7 @@ public:
   XBT_ATTRIB_DEPRECATED_v330("Please use Host::sendto()") void send_to(Host* dest, double byte_amount);
 #endif
 
-  NetZone* get_englobing_zone();
+  NetZone* get_englobing_zone() const;
   /** Block the calling actor on an execution located on the called host
    *
    * It is not a problem if the actor is not located on the called host.
index 245e609..bb63291 100644 (file)
@@ -296,10 +296,10 @@ static void instr_user_variable(double time, const char* resource, const char* v
 static void instr_user_srcdst_variable(double time, const char *src, const char *dst, const char *variable,
                               const char *father_type, double value, InstrUserVariable what)
 {
-  simgrid::kernel::routing::NetPoint* src_elm = sg_netpoint_by_name_or_null(src);
+  const simgrid::kernel::routing::NetPoint* src_elm = sg_netpoint_by_name_or_null(src);
   xbt_assert(src_elm, "Element '%s' not found!", src);
 
-  simgrid::kernel::routing::NetPoint* dst_elm = sg_netpoint_by_name_or_null(dst);
+  const simgrid::kernel::routing::NetPoint* dst_elm = sg_netpoint_by_name_or_null(dst);
   xbt_assert(dst_elm, "Element '%s' not found!", dst);
 
   std::vector<simgrid::kernel::resource::LinkImpl*> route;
index 374536c..1859eaf 100644 (file)
@@ -84,7 +84,7 @@ xbt_node_t DijkstraZone::node_map_search(int id)
 
 /* Parsing */
 
-void DijkstraZone::get_local_route(NetPoint* src, NetPoint* dst, Route* route, double* lat)
+void DijkstraZone::get_local_route(const NetPoint* src, const NetPoint* dst, Route* route, double* lat)
 {
   get_route_check_params(src, dst);
   int src_id = src->id();
index f9781e4..9248f79 100644 (file)
@@ -281,7 +281,7 @@ void DragonflyZone::generate_links()
   }
 }
 
-void DragonflyZone::get_local_route(NetPoint* src, NetPoint* dst, Route* route, double* latency)
+void DragonflyZone::get_local_route(const NetPoint* src, const NetPoint* dst, Route* route, double* latency)
 {
   // Minimal routing version.
   // TODO : non-minimal random one, and adaptive ?
index 046349e..774696c 100644 (file)
@@ -43,7 +43,7 @@ bool FatTreeZone::is_in_sub_tree(const FatTreeNode* root, const FatTreeNode* nod
   return true;
 }
 
-void FatTreeZone::get_local_route(NetPoint* src, NetPoint* dst, Route* into, double* latency)
+void FatTreeZone::get_local_route(const NetPoint* src, const NetPoint* dst, Route* into, double* latency)
 {
   if (dst->is_router() || src->is_router())
     return;
index 5cc4e80..76411b2 100644 (file)
@@ -33,7 +33,7 @@ void FloydZone::init_tables(unsigned int table_size)
   }
 }
 
-void FloydZone::get_local_route(NetPoint* src, NetPoint* dst, Route* route, double* lat)
+void FloydZone::get_local_route(const NetPoint* src, const NetPoint* dst, Route* route, double* lat)
 {
   get_route_check_params(src, dst);
 
index 4c47c46..da6841f 100644 (file)
@@ -41,7 +41,7 @@ void FullZone::do_seal()
   }
 }
 
-void FullZone::get_local_route(NetPoint* src, NetPoint* dst, Route* res, double* lat)
+void FullZone::get_local_route(const NetPoint* src, const NetPoint* dst, Route* res, double* lat)
 {
   XBT_DEBUG("full getLocalRoute from %s[%u] to %s[%u]", src->get_cname(), src->id(), dst->get_cname(), dst->id());
 
index 5706ce1..20ada8a 100644 (file)
@@ -269,7 +269,7 @@ void NetZoneImpl::add_bypass_route(NetPoint* src, NetPoint* dst, NetPoint* gw_sr
  *                 dst
  *  @endverbatim
  */
-static void find_common_ancestors(NetPoint* src, NetPoint* dst,
+static void find_common_ancestors(const NetPoint* src, const NetPoint* dst,
                                   /* OUT */ NetZoneImpl** common_ancestor, NetZoneImpl** src_ancestor,
                                   NetZoneImpl** dst_ancestor)
 {
@@ -329,7 +329,7 @@ static void find_common_ancestors(NetPoint* src, NetPoint* dst,
 }
 
 /* PRECONDITION: this is the common ancestor of src and dst */
-bool NetZoneImpl::get_bypass_route(NetPoint* src, NetPoint* dst,
+bool NetZoneImpl::get_bypass_route(const NetPoint* src, const NetPoint* dst,
                                    /* OUT */ std::vector<resource::LinkImpl*>& links, double* latency,
                                    std::unordered_set<NetZoneImpl*>& netzones)
 {
@@ -421,14 +421,14 @@ bool NetZoneImpl::get_bypass_route(NetPoint* src, NetPoint* dst,
   return false;
 }
 
-void NetZoneImpl::get_global_route(NetPoint* src, NetPoint* dst,
+void NetZoneImpl::get_global_route(const NetPoint* src, const NetPoint* dst,
                                    /* OUT */ std::vector<resource::LinkImpl*>& links, double* latency)
 {
   std::unordered_set<NetZoneImpl*> netzones;
   get_global_route_with_netzones(src, dst, links, latency, netzones);
 }
 
-void NetZoneImpl::get_global_route_with_netzones(NetPoint* src, NetPoint* dst,
+void NetZoneImpl::get_global_route_with_netzones(const NetPoint* src, const NetPoint* dst,
                                                  /* OUT */ std::vector<resource::LinkImpl*>& links, double* latency,
                                                  std::unordered_set<NetZoneImpl*>& netzones)
 {
index cc10d43..3c28dce 100644 (file)
@@ -131,7 +131,7 @@ Route* RoutedZone::new_extended_route(RoutingMode hierarchy, NetPoint* gw_src, N
   return result;
 }
 
-void RoutedZone::get_route_check_params(NetPoint* src, NetPoint* dst) const
+void RoutedZone::get_route_check_params(const NetPoint* src, const NetPoint* dst) const
 {
   xbt_assert(src, "Cannot find a route from nullptr to %s", dst->get_cname());
   xbt_assert(dst, "Cannot find a route from %s to nullptr", src->get_cname());
index 3afd979..7072a01 100644 (file)
@@ -29,7 +29,7 @@ void StarZone::add_links_to_route(const std::vector<resource::LinkImpl*>& links,
   }
 }
 
-void StarZone::get_local_route(NetPoint* src, NetPoint* dst, Route* route, double* latency)
+void StarZone::get_local_route(const NetPoint* src, const NetPoint* dst, Route* route, double* latency)
 {
   XBT_VERB("StarZone getLocalRoute from '%s'[%u] to '%s'[%u]", src->get_cname(), src->id(), dst->get_cname(),
            dst->id());
index b7c7001..21b83cf 100644 (file)
@@ -82,7 +82,7 @@ void TorusZone::set_topology(const std::vector<unsigned int>& dimensions)
   set_num_links_per_node(dimensions_.size());
 }
 
-void TorusZone::get_local_route(NetPoint* src, NetPoint* dst, Route* route, double* lat)
+void TorusZone::get_local_route(const NetPoint* src, const NetPoint* dst, Route* route, double* lat)
 {
   XBT_VERB("torus getLocalRoute from '%s'[%u] to '%s'[%u]", src->get_cname(), src->id(), dst->get_cname(), dst->id());
 
index eceb3f7..aa2a15d 100644 (file)
@@ -49,7 +49,7 @@ static inline double euclidean_dist_comp(double src_coord, double dst_coord)
   return (src_coord - dst_coord) * (src_coord - dst_coord);
 }
 
-static const std::vector<double>& netpoint_get_coords(NetPoint* np)
+static const std::vector<double>& netpoint_get_coords(const NetPoint* np)
 {
   const auto* coords = np->extension<vivaldi::Coords>();
   xbt_assert(coords, "Please specify the Vivaldi coordinates of %s %s (%p)",
@@ -70,7 +70,7 @@ void VivaldiZone::set_peer_link(NetPoint* netpoint, double bw_in, double bw_out)
   add_route(nullptr, netpoint, nullptr, nullptr, {linkDown->get_impl()}, false);
 }
 
-void VivaldiZone::get_local_route(NetPoint* src, NetPoint* dst, Route* route, double* lat)
+void VivaldiZone::get_local_route(const NetPoint* src, const NetPoint* dst, Route* route, double* lat)
 {
   XBT_DEBUG("vivaldi getLocalRoute from '%s'[%u] '%s'[%u]", src->get_cname(), src->id(), dst->get_cname(), dst->id());
 
index 95f3c16..df2b0c1 100644 (file)
@@ -28,7 +28,7 @@ void WifiZone::do_seal()
   }
 }
 
-void WifiZone::get_local_route(NetPoint* src, NetPoint* dst, Route* res, double* lat)
+void WifiZone::get_local_route(const NetPoint* src, const NetPoint* dst, Route* res, double* lat)
 {
   XBT_DEBUG("full getLocalRoute from %s[%u] to %s[%u]", src->get_cname(), src->id(), dst->get_cname(), dst->id());
 
index b56ad8f..02684f9 100644 (file)
@@ -172,7 +172,7 @@ void Host::route_to(const Host* dest, std::vector<kernel::resource::LinkImpl*>&
 }
 
 /** @brief Returns the networking zone englobing that host */
-NetZone* Host::get_englobing_zone()
+NetZone* Host::get_englobing_zone() const
 {
   return pimpl_netpoint_->get_englobing_zone()->get_iface();
 }
index 44583a1..b604699 100644 (file)
@@ -118,10 +118,10 @@ static void dump_routes()
             });
 
   for (auto src_host : hosts) { // Routes from host
-    simgrid::kernel::routing::NetPoint* src = src_host->get_netpoint();
+    const simgrid::kernel::routing::NetPoint* src = src_host->get_netpoint();
     for (auto dst_host : hosts) { // Routes to host
       std::vector<simgrid::kernel::resource::LinkImpl*> route;
-      simgrid::kernel::routing::NetPoint* dst = dst_host->get_netpoint();
+      const simgrid::kernel::routing::NetPoint* dst = dst_host->get_netpoint();
       simgrid::kernel::routing::NetZoneImpl::get_global_route(src, dst, route, nullptr);
       if (route.empty())
         continue;