From: Martin Quinson Date: Sat, 9 Jun 2018 20:16:38 +0000 (+0200) Subject: start snake_casing NetZone. Many cleanups to come X-Git-Tag: v3.20~130 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/453ce02e0133358ef34d58e920521b6a29fe2283 start snake_casing NetZone. Many cleanups to come --- diff --git a/examples/s4u/platform-properties/s4u-platform-properties.cpp b/examples/s4u/platform-properties/s4u-platform-properties.cpp index e616163996..62e2b84b4b 100644 --- a/examples/s4u/platform-properties/s4u-platform-properties.cpp +++ b/examples/s4u/platform-properties/s4u-platform-properties.cpp @@ -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"); - 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* props = simgrid::s4u::Actor::self()->get_properties(); diff --git a/include/simgrid/s4u/NetZone.hpp b/include/simgrid/s4u/NetZone.hpp index e8ecc4faec..d8e242b718 100644 --- a/include/simgrid/s4u/NetZone.hpp +++ b/include/simgrid/s4u/NetZone.hpp @@ -43,12 +43,16 @@ public: void getHosts(std::vector * whereto); // retrieve my content as a vector of hosts int getHostCount(); +private: + std::unordered_map properties_; + +public: /** Get the properties assigned to a host */ std::unordered_map* 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 */ @@ -83,16 +87,24 @@ public: { add_bypass_route(src, dst, gw_src, gw_dst, link_list, symmetrical); } - -protected: - unsigned int getTableSize() { return vertices_.size(); } - std::vector 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 vertices_; - std::unordered_map properties_; +protected: + unsigned int get_table_size() { return vertices_.size(); } + std::vector getVertices() { return vertices_; } + +private: NetZone* father_ = nullptr; std::string name_; diff --git a/src/kernel/routing/FloydZone.cpp b/src/kernel/routing/FloydZone.cpp index 8b4b9b55a4..dd92bc8fa1 100644 --- a/src/kernel/routing/FloydZone.cpp +++ b/src/kernel/routing/FloydZone.cpp @@ -33,7 +33,7 @@ FloydZone::~FloydZone() { 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++) @@ -46,7 +46,7 @@ FloydZone::~FloydZone() 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); @@ -89,7 +89,7 @@ void FloydZone::add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoi std::vector& 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); @@ -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 */ - unsigned int table_size = getTableSize(); + unsigned int table_size = get_table_size(); if (not link_table_) { /* Create Cost, Predecessor and Link tables */ diff --git a/src/kernel/routing/FullZone.cpp b/src/kernel/routing/FullZone.cpp index 4549c63f38..16d3969952 100644 --- a/src/kernel/routing/FullZone.cpp +++ b/src/kernel/routing/FullZone.cpp @@ -22,7 +22,7 @@ FullZone::FullZone(NetZone* father, std::string name) : RoutedZone(father, name) void FullZone::seal() { - unsigned int table_size = getTableSize(); + unsigned int table_size = get_table_size(); /* Create table if needed */ if (not routing_table_) @@ -44,7 +44,7 @@ void FullZone::seal() 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++) @@ -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()); - 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) { @@ -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); - unsigned int table_size = getTableSize(); + unsigned int table_size = get_table_size(); if (not routing_table_) routing_table_ = new RouteCreationArgs*[table_size * table_size](); diff --git a/src/s4u/s4u_Netzone.cpp b/src/s4u/s4u_Netzone.cpp index 5eb5139489..a46eb0a371 100644 --- a/src/s4u/s4u_Netzone.cpp +++ b/src/s4u/s4u_Netzone.cpp @@ -44,11 +44,11 @@ std::unordered_map* NetZone::getProperties() } /** 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(); } -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; }); } @@ -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) { - return netzone->getProperty(name); + return netzone->get_property(name); } 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) diff --git a/src/surf/xml/surfxml_sax_cb.cpp b/src/surf/xml/surfxml_sax_cb.cpp index d7d9c84c3e..fcab8b4bed 100644 --- a/src/surf/xml/surfxml_sax_cb.cpp +++ b/src/surf/xml/surfxml_sax_cb.cpp @@ -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); - 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; // Maybe, it should raise an error