Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
tidy up PropertyHolder
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 9 Dec 2019 16:15:48 +0000 (17:15 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 9 Dec 2019 16:15:48 +0000 (17:15 +0100)
+ change namespace
+ move files
+ use it for netzones too

13 files changed:
MANIFEST.in
include/simgrid/kernel/routing/NetZoneImpl.hpp
include/simgrid/s4u/NetZone.hpp
include/xbt/PropertyHolder.hpp [moved from src/surf/PropertyHolder.hpp with 83% similarity]
src/kernel/actor/ActorImpl.hpp
src/kernel/resource/DiskImpl.hpp
src/s4u/s4u_Netzone.cpp
src/surf/HostImpl.hpp
src/surf/StorageImpl.hpp
src/surf/network_interface.hpp
src/surf/sg_platf.cpp
src/xbt/PropertyHolder.cpp [moved from src/surf/PropertyHolder.cpp with 95% similarity]
tools/cmake/DefinePackages.cmake

index cd3d19a..9cc9214 100644 (file)
@@ -1993,6 +1993,7 @@ include include/smpi/smpi_helpers_internal.h
 include include/smpi/smpi_main.h
 include include/xbt.h
 include include/xbt/Extendable.hpp
+include include/xbt/PropertyHolder.hpp
 include include/xbt/asserts.h
 include include/xbt/automaton.h
 include include/xbt/automaton.hpp
@@ -2513,8 +2514,6 @@ include src/smpi/smpirun.in
 include src/smpi/smpitools.sh
 include src/surf/HostImpl.cpp
 include src/surf/HostImpl.hpp
-include src/surf/PropertyHolder.cpp
-include src/surf/PropertyHolder.hpp
 include src/surf/StorageImpl.cpp
 include src/surf/StorageImpl.hpp
 include src/surf/cpu_cas01.cpp
@@ -2560,6 +2559,7 @@ include src/surf/xml/simgrid_dtd.h
 include src/surf/xml/surfxml_parseplatf.cpp
 include src/surf/xml/surfxml_sax_cb.cpp
 include src/xbt/OsSemaphore.hpp
+include src/xbt/PropertyHolder.cpp
 include src/xbt/automaton/automaton.c
 include src/xbt/automaton/automaton_lexer.yy.c
 include src/xbt/automaton/automatonparse_promela.c
index 4b07544..4c48344 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <simgrid/forward.h>
 #include <simgrid/s4u/NetZone.hpp>
+#include <xbt/PropertyHolder.hpp>
 #include <xbt/graph.h>
 
 #include <map>
@@ -47,8 +48,8 @@ class BypassRoute;
  * called Autonomous Systems in this article).
  *
  */
-class XBT_PUBLIC NetZoneImpl {
-  friend simgrid::kernel::EngineImpl; // it destroys netRoot_
+class XBT_PUBLIC NetZoneImpl : public xbt::PropertyHolder {
+  friend EngineImpl; // it destroys netRoot_
 
 protected:
   explicit NetZoneImpl(NetZoneImpl* father, const std::string& name, resource::NetworkModel* network_model);
@@ -60,8 +61,8 @@ public:
   s4u::NetZone* get_iface() { return &piface_; }
 
   /** @brief Make a host within that NetZone */
-  simgrid::s4u::Host* create_host(const std::string& name, const std::vector<double>& speed_per_pstate, int core_count,
-                                  const std::map<std::string, std::string>* props);
+  s4u::Host* create_host(const std::string& name, const std::vector<double>& speed_per_pstate, int core_count,
+                         const std::map<std::string, std::string>* props);
   /** @brief Creates a new route in this NetZone */
   virtual void add_bypass_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
                                 std::vector<resource::LinkImpl*>& link_list, bool symmetrical);
index 609542f..e95407b 100644 (file)
@@ -44,18 +44,16 @@ public:
 
 private:
   kernel::routing::NetZoneImpl* const pimpl_;
-  std::unordered_map<std::string, std::string> properties_;
 
 public:
   /** Get the properties assigned to a netzone */
   const std::unordered_map<std::string, std::string>* get_properties() const;
-
-  std::vector<NetZone*> get_children();
-
   /** Retrieve the property value (or nullptr if not set) */
   const char* get_property(const std::string& key) const;
   void set_property(const std::string& key, const std::string& value);
 
+  std::vector<NetZone*> get_children();
+
   /* Add content to the netzone, at parsing time. It should be sealed afterward. */
   int add_component(kernel::routing::NetPoint* elm); /* A host, a router or a netzone, whatever */
   void add_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst, kernel::routing::NetPoint* gw_src,
similarity index 83%
rename from src/surf/PropertyHolder.hpp
rename to include/xbt/PropertyHolder.hpp
index 2c7cdce..763fd29 100644 (file)
@@ -3,15 +3,15 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#ifndef SRC_SURF_PROPERTYHOLDER_HPP_
-#define SRC_SURF_PROPERTYHOLDER_HPP_
+#ifndef XBT_PROPERTYHOLDER_HPP
+#define XBT_PROPERTYHOLDER_HPP
 
 #include <memory>
 #include <string>
 #include <unordered_map>
 
 namespace simgrid {
-namespace surf {
+namespace xbt {
 
 /** @brief a PropertyHolder can be given a set of textual properties
  *
@@ -20,7 +20,7 @@ namespace surf {
 class PropertyHolder { // DO NOT DERIVE THIS CLASS, or the diamond inheritance mayhem will get you
 
 public:
-  PropertyHolder() = default;
+  PropertyHolder()                      = default;
   PropertyHolder(const PropertyHolder&) = delete;
   PropertyHolder& operator=(const PropertyHolder&) = delete;
 
@@ -34,7 +34,7 @@ private:
   std::unique_ptr<std::unordered_map<std::string, std::string>> properties_ = nullptr;
 };
 
-} /* namespace surf */
-} /* namespace simgrid */
+} // namespace xbt
+} // namespace simgrid
 
-#endif /* SRC_SURF_PROPERTYHOLDER_HPP_ */
+#endif
index 831fb73..c0883ae 100644 (file)
@@ -8,7 +8,7 @@
 
 #include "simgrid/s4u/Actor.hpp"
 #include "src/simix/popping_private.hpp"
-#include "src/surf/PropertyHolder.hpp"
+#include "xbt/PropertyHolder.hpp"
 #include <boost/intrusive/list.hpp>
 #include <functional>
 #include <list>
@@ -19,7 +19,7 @@ namespace simgrid {
 namespace kernel {
 namespace actor {
 
-class XBT_PUBLIC ActorImpl : public surf::PropertyHolder {
+class XBT_PUBLIC ActorImpl : public xbt::PropertyHolder {
   s4u::Host* host_   = nullptr; /* the host on which the actor is running */
   // XBT_DEPRECATED_v329
   void* userdata_    = nullptr; /* kept for compatibility, it should be replaced with moddata */
index 269a360..9ce6640 100644 (file)
@@ -8,8 +8,8 @@
 #include "simgrid/kernel/resource/Resource.hpp"
 #include "simgrid/s4u/Disk.hpp"
 #include "simgrid/s4u/Io.hpp"
-#include "src/surf/PropertyHolder.hpp"
 #include "src/surf/surf_interface.hpp"
+#include <xbt/PropertyHolder.hpp>
 
 #include <map>
 
@@ -47,7 +47,7 @@ public:
 /************
  * Resource *
  ************/
-class DiskImpl : public Resource, public surf::PropertyHolder {
+class DiskImpl : public Resource, public xbt::PropertyHolder {
   bool currently_destroying_ = false;
   s4u::Host* host_           = nullptr;
   s4u::Disk piface_;
index 807bf42..b5cdbce 100644 (file)
@@ -21,19 +21,18 @@ xbt::signal<void(NetZone const&)> NetZone::on_seal;
 
 const std::unordered_map<std::string, std::string>* NetZone::get_properties() const
 {
-  return &properties_;
+  return pimpl_->get_properties();
 }
 
 /** Retrieve the property value (or nullptr if not set) */
 const char* NetZone::get_property(const std::string& key) const
 {
-  auto prop = properties_.find(key);
-  return prop == properties_.end() ? nullptr : prop->second.c_str();
+  return pimpl_->get_property(key);
 }
 
 void NetZone::set_property(const std::string& key, const std::string& value)
 {
-  kernel::actor::simcall([this, &key, &value] { properties_[key] = value; });
+  kernel::actor::simcall([this, &key, &value] { pimpl_->set_property(key, value); });
 }
 
 /** @brief Returns the list of direct children (no grand-children) */
index 0aef460..d48e4bb 100644 (file)
@@ -8,10 +8,10 @@
 
 #include "src/kernel/actor/ActorImpl.hpp"
 #include "src/kernel/resource/DiskImpl.hpp"
-#include "src/surf/PropertyHolder.hpp"
 #include "src/surf/StorageImpl.hpp"
 #include "src/surf/cpu_interface.hpp"
 #include "src/surf/network_interface.hpp"
+#include <xbt/PropertyHolder.hpp>
 
 #include <vector>
 
@@ -42,7 +42,7 @@ public:
  * @brief SURF Host interface class
  * @details An host represents a machine with a aggregation of a Cpu, a RoutingEdge and a Storage
  */
-class XBT_PRIVATE HostImpl : public simgrid::surf::PropertyHolder {
+class XBT_PRIVATE HostImpl : public xbt::PropertyHolder {
   std::vector<kernel::actor::ProcessArg*> actors_at_boot_;
   s4u::Host* piface_ = nullptr; // FIXME: why don't we store a s4u::Host here as we do everywhere else?
 
index bd885d0..338268c 100644 (file)
@@ -8,8 +8,8 @@
 #include "simgrid/kernel/resource/Resource.hpp"
 #include "simgrid/s4u/Io.hpp"
 #include "simgrid/s4u/Storage.hpp"
-#include "src/surf/PropertyHolder.hpp"
 #include "surf_interface.hpp"
+#include "xbt/PropertyHolder.hpp"
 
 #include <map>
 
@@ -59,7 +59,7 @@ public:
  * @brief SURF storage interface class
  * @details A Storage represent a storage unit (e.g.: hard drive, usb key)
  */
-class StorageImpl : public Resource, public surf::PropertyHolder {
+class StorageImpl : public Resource, public xbt::PropertyHolder {
   s4u::Storage piface_;
 
 public:
index d5ecd17..69fbcb2 100644 (file)
@@ -10,7 +10,7 @@
 #include "simgrid/kernel/resource/Resource.hpp"
 #include "simgrid/s4u/Link.hpp"
 #include "src/kernel/lmm/maxmin.hpp"
-#include "src/surf/PropertyHolder.hpp"
+#include <xbt/PropertyHolder.hpp>
 
 #include <list>
 #include <unordered_map>
@@ -107,7 +107,7 @@ public:
  * @brief SURF network link interface class
  * @details A Link represents the link between two [hosts](@ref simgrid::surf::HostImpl)
  */
-class LinkImpl : public Resource, public surf::PropertyHolder {
+class LinkImpl : public Resource, public xbt::PropertyHolder {
   bool currently_destroying_ = false;
   s4u::Link piface_;
 
index 318a719..e57d0d0 100644 (file)
@@ -646,8 +646,8 @@ void sg_platf_new_Zone_set_properties(std::unordered_map<std::string, std::strin
 {
   xbt_assert(current_routing, "Cannot set properties of the current Zone: none under construction");
 
-  for (auto kv = props->begin(); kv != props->end(); ++kv)
-    current_routing->get_iface()->set_property(kv->first, kv->second);
+  if (props)
+    current_routing->set_properties(*props);
 }
 
 /**
similarity index 95%
rename from src/surf/PropertyHolder.cpp
rename to src/xbt/PropertyHolder.cpp
index bf262b9..8b62106 100644 (file)
@@ -3,12 +3,12 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#include "PropertyHolder.hpp"
+#include <xbt/PropertyHolder.hpp>
 
 #include <map>
 
 namespace simgrid {
-namespace surf {
+namespace xbt {
 
 /** @brief Return the property associated to the provided key (or nullptr if not existing) */
 const char* PropertyHolder::get_property(const std::string& key) const
@@ -52,5 +52,5 @@ template <class Assoc> void PropertyHolder::set_properties(const Assoc& properti
 template void PropertyHolder::set_properties(const std::map<std::string, std::string>& properties);
 template void PropertyHolder::set_properties(const std::unordered_map<std::string, std::string>& properties);
 
-} /* namespace surf */
-} /* namespace simgrid */
+} // namespace xbt
+} // namespace simgrid
index 3db1ff9..725e75d 100644 (file)
@@ -55,7 +55,6 @@ set(EXTRA_DIST
   src/surf/storage_n11.hpp
   src/surf/surf_interface.hpp
   src/surf/surf_private.hpp
-  src/surf/PropertyHolder.hpp
   src/surf/host_clm03.hpp
   src/surf/HostImpl.hpp
   src/surf/ptask_L07.hpp
@@ -284,6 +283,7 @@ set(XBT_SRC
   src/xbt/memory_map.cpp
   src/xbt/memory_map.hpp
   src/xbt/OsSemaphore.hpp
+  src/xbt/PropertyHolder.cpp
   src/xbt/parmap.cpp
   src/xbt/random.cpp
   src/xbt/snprintf.c
@@ -353,7 +353,6 @@ set(SURF_SRC
   src/surf/network_constant.cpp
   src/surf/network_interface.cpp
   src/surf/network_wifi.cpp
-  src/surf/PropertyHolder.cpp
   src/surf/sg_platf.cpp
   src/surf/StorageImpl.cpp
   src/surf/storage_n11.cpp
@@ -776,6 +775,7 @@ set(headers_to_install
   include/xbt/mallocator.h
   include/xbt/misc.h
   include/xbt/module.h
+  include/xbt/PropertyHolder.hpp
   include/xbt/parmap.h
   include/xbt/range.hpp
   include/xbt/random.hpp