Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
start snake_casing NetZone. Many cleanups to come
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 9 Jun 2018 20:16:38 +0000 (22:16 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 9 Jun 2018 20:16:38 +0000 (22:16 +0200)
examples/s4u/platform-properties/s4u-platform-properties.cpp
include/simgrid/s4u/NetZone.hpp
src/kernel/routing/FloydZone.cpp
src/kernel/routing/FullZone.cpp
src/s4u/s4u_Netzone.cpp
src/surf/xml/surfxml_sax_cb.cpp

index e616163..62e2b84 100644 (file)
@@ -73,9 +73,9 @@ 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()->get_netzone_root();
   XBT_INFO("== Print the properties of the zone");
   /* this host also tests the properties of the AS*/
   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("   Zone property: author -> %s", root->getProperty("author"));
+  XBT_INFO("   Zone property: filename -> %s", root->get_property("filename"));
+  XBT_INFO("   Zone property: date -> %s", root->get_property("date"));
+  XBT_INFO("   Zone property: author -> %s", root->get_property("author"));
 
   /* Get the property list of current bob process */
   std::map<std::string, std::string>* props = simgrid::s4u::Actor::self()->get_properties();
 
   /* Get the property list of current bob process */
   std::map<std::string, std::string>* props = simgrid::s4u::Actor::self()->get_properties();
index e8ecc4f..d8e242b 100644 (file)
@@ -43,12 +43,16 @@ public:
   void getHosts(std::vector<s4u::Host*> * whereto); // retrieve my content as a vector of hosts
   int getHostCount();
 
   void getHosts(std::vector<s4u::Host*> * whereto); // retrieve my content as a vector of hosts
   int getHostCount();
 
+private:
+  std::unordered_map<std::string, std::string> properties_;
+
+public:
   /** Get the properties assigned to a host */
   std::unordered_map<std::string, std::string>* getProperties();
 
   /** Retrieve the property value (or nullptr if not set) */
   /** Get the properties assigned to a host */
   std::unordered_map<std::string, std::string>* getProperties();
 
   /** Retrieve the property value (or nullptr if not set) */
-  const char* getProperty(const char* key);
-  void setProperty(const char* key, const char* value);
+  const char* get_property(const char* key);
+  void set_property(const char* key, const char* value);
 
   /* Add content to the netzone, at parsing time. It should be sealed afterward. */
   virtual int addComponent(kernel::routing::NetPoint * elm); /* A host, a router or a netzone, whatever */
 
   /* Add content to the netzone, at parsing time. It should be sealed afterward. */
   virtual int addComponent(kernel::routing::NetPoint * elm); /* A host, a router or a netzone, whatever */
@@ -83,16 +87,24 @@ public:
   {
     add_bypass_route(src, dst, gw_src, gw_dst, link_list, symmetrical);
   }
   {
     add_bypass_route(src, dst, gw_src, gw_dst, link_list, symmetrical);
   }
-
-protected:
-  unsigned int getTableSize() { return vertices_.size(); }
-  std::vector<kernel::routing::NetPoint*> getVertices() { return vertices_; }
+  XBT_ATTRIB_DEPRECATED_v323("Please use NetZone::get_property()") const char* getProperty(const char* key)
+  {
+    return get_property(key);
+  }
+  XBT_ATTRIB_DEPRECATED_v323("Please use NetZone::set_property()") void setProperty(const char* key, const char* value)
+  {
+    set_property(key, value);
+  }
 
 private:
   // our content, as known to our graph routing algorithm (maps vertexId -> vertex)
   std::vector<kernel::routing::NetPoint*> vertices_;
 
 
 private:
   // our content, as known to our graph routing algorithm (maps vertexId -> vertex)
   std::vector<kernel::routing::NetPoint*> vertices_;
 
-  std::unordered_map<std::string, std::string> properties_;
+protected:
+  unsigned int get_table_size() { return vertices_.size(); }
+  std::vector<kernel::routing::NetPoint*> getVertices() { return vertices_; }
+
+private:
   NetZone* father_ = nullptr;
   std::string name_;
 
   NetZone* father_ = nullptr;
   std::string name_;
 
index 8b4b9b5..dd92bc8 100644 (file)
@@ -33,7 +33,7 @@ FloydZone::~FloydZone()
 {
   if (link_table_ == nullptr) // Dealing with a parse error in the file?
     return;
 {
   if (link_table_ == nullptr) // Dealing with a parse error in the file?
     return;
-  unsigned int table_size = getTableSize();
+  unsigned int table_size = get_table_size();
   /* Delete link_table */
   for (unsigned int i = 0; i < table_size; i++)
     for (unsigned int j = 0; j < table_size; j++)
   /* Delete link_table */
   for (unsigned int i = 0; i < table_size; i++)
     for (unsigned int j = 0; j < table_size; j++)
@@ -46,7 +46,7 @@ FloydZone::~FloydZone()
 
 void FloydZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* route, double* lat)
 {
 
 void FloydZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* route, double* lat)
 {
-  unsigned int table_size = getTableSize();
+  unsigned int table_size = get_table_size();
 
   getRouteCheckParams(src, dst);
 
 
   getRouteCheckParams(src, dst);
 
@@ -89,7 +89,7 @@ void FloydZone::add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoi
                           std::vector<resource::LinkImpl*>& link_list, bool symmetrical)
 {
   /* set the size of table routing */
                           std::vector<resource::LinkImpl*>& link_list, bool symmetrical)
 {
   /* set the size of table routing */
-  unsigned int table_size = getTableSize();
+  unsigned int table_size = get_table_size();
 
   addRouteCheckParams(src, dst, gw_src, gw_dst, link_list, symmetrical);
 
 
   addRouteCheckParams(src, dst, gw_src, gw_dst, link_list, symmetrical);
 
@@ -157,7 +157,7 @@ void FloydZone::add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoi
 void FloydZone::seal()
 {
   /* set the size of table routing */
 void FloydZone::seal()
 {
   /* set the size of table routing */
-  unsigned int table_size = getTableSize();
+  unsigned int table_size = get_table_size();
 
   if (not link_table_) {
     /* Create Cost, Predecessor and Link tables */
 
   if (not link_table_) {
     /* Create Cost, Predecessor and Link tables */
index 4549c63..16d3969 100644 (file)
@@ -22,7 +22,7 @@ FullZone::FullZone(NetZone* father, std::string name) : RoutedZone(father, name)
 
 void FullZone::seal()
 {
 
 void FullZone::seal()
 {
-  unsigned int table_size = getTableSize();
+  unsigned int table_size = get_table_size();
 
   /* Create table if needed */
   if (not routing_table_)
 
   /* Create table if needed */
   if (not routing_table_)
@@ -44,7 +44,7 @@ void FullZone::seal()
 FullZone::~FullZone()
 {
   if (routing_table_) {
 FullZone::~FullZone()
 {
   if (routing_table_) {
-    unsigned int table_size = getTableSize();
+    unsigned int table_size = get_table_size();
     /* Delete routing table */
     for (unsigned int i = 0; i < table_size; i++)
       for (unsigned int j = 0; j < table_size; j++)
     /* Delete routing table */
     for (unsigned int i = 0; i < table_size; i++)
       for (unsigned int j = 0; j < table_size; j++)
@@ -57,7 +57,7 @@ void FullZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs*
 {
   XBT_DEBUG("full getLocalRoute from %s[%u] to %s[%u]", src->get_cname(), src->id(), dst->get_cname(), dst->id());
 
 {
   XBT_DEBUG("full getLocalRoute from %s[%u] to %s[%u]", src->get_cname(), src->id(), dst->get_cname(), dst->id());
 
-  unsigned int table_size        = getTableSize();
+  unsigned int table_size        = get_table_size();
   RouteCreationArgs* e_route     = TO_ROUTE_FULL(src->id(), dst->id());
 
   if (e_route != nullptr) {
   RouteCreationArgs* e_route     = TO_ROUTE_FULL(src->id(), dst->id());
 
   if (e_route != nullptr) {
@@ -76,7 +76,7 @@ void FullZone::add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoin
 {
   addRouteCheckParams(src, dst, gw_src, gw_dst, link_list, symmetrical);
 
 {
   addRouteCheckParams(src, dst, gw_src, gw_dst, link_list, symmetrical);
 
-  unsigned int table_size = getTableSize();
+  unsigned int table_size = get_table_size();
 
   if (not routing_table_)
     routing_table_ = new RouteCreationArgs*[table_size * table_size]();
 
   if (not routing_table_)
     routing_table_ = new RouteCreationArgs*[table_size * table_size]();
index 5eb5139..a46eb0a 100644 (file)
@@ -44,11 +44,11 @@ std::unordered_map<std::string, std::string>* NetZone::getProperties()
 }
 
 /** Retrieve the property value (or nullptr if not set) */
 }
 
 /** Retrieve the property value (or nullptr if not set) */
-const char* NetZone::getProperty(const char* key)
+const char* NetZone::get_property(const char* key)
 {
   return properties_.at(key).c_str();
 }
 {
   return properties_.at(key).c_str();
 }
-void NetZone::setProperty(const char* key, const char* value)
+void NetZone::set_property(const char* key, const char* value)
 {
   simgrid::simix::simcall([this, key, value] { properties_[key] = value; });
 }
 {
   simgrid::simix::simcall([this, key, value] { properties_[key] = value; });
 }
@@ -133,12 +133,12 @@ void sg_zone_get_sons(sg_netzone_t netzone, xbt_dict_t whereto)
 
 const char* sg_zone_get_property_value(sg_netzone_t netzone, const char* name)
 {
 
 const char* sg_zone_get_property_value(sg_netzone_t netzone, const char* name)
 {
-  return netzone->getProperty(name);
+  return netzone->get_property(name);
 }
 
 void sg_zone_set_property_value(sg_netzone_t netzone, const char* name, char* value)
 {
 }
 
 void sg_zone_set_property_value(sg_netzone_t netzone, const char* name, char* value)
 {
-  netzone->setProperty(name, value);
+  netzone->set_property(name, value);
 }
 
 void sg_zone_get_hosts(sg_netzone_t netzone, xbt_dynar_t whereto)
 }
 
 void sg_zone_get_hosts(sg_netzone_t netzone, xbt_dynar_t whereto)
index d7d9c84..fcab8b4 100644 (file)
@@ -406,7 +406,7 @@ void STag_surfxml_prop()
     XBT_DEBUG("Set zone property %s -> %s", A_surfxml_prop_id, A_surfxml_prop_value);
     simgrid::s4u::NetZone* netzone = simgrid::s4u::Engine::get_instance()->netzone_by_name_or_null(A_surfxml_zone_id);
 
     XBT_DEBUG("Set zone property %s -> %s", A_surfxml_prop_id, A_surfxml_prop_value);
     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);
+    netzone->set_property(A_surfxml_prop_id, A_surfxml_prop_value);
   } else {
     if (not current_property_set)
       current_property_set = new std::map<std::string, std::string>; // Maybe, it should raise an error
   } else {
     if (not current_property_set)
       current_property_set = new std::map<std::string, std::string>; // Maybe, it should raise an error