Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of framagit.org:simgrid/simgrid
[simgrid.git] / src / surf / PropertyHolder.hpp
index 04ff488..2c7cdce 100644 (file)
@@ -5,6 +5,8 @@
 
 #ifndef SRC_SURF_PROPERTYHOLDER_HPP_
 #define SRC_SURF_PROPERTYHOLDER_HPP_
+
+#include <memory>
 #include <string>
 #include <unordered_map>
 
@@ -19,18 +21,17 @@ class PropertyHolder { // DO NOT DERIVE THIS CLASS, or the diamond inheritance m
 
 public:
   PropertyHolder() = default;
-  ~PropertyHolder();
+  PropertyHolder(const PropertyHolder&) = delete;
+  PropertyHolder& operator=(const PropertyHolder&) = delete;
 
-  const char* get_property(const std::string& key);
-  void set_property(const std::string& id, std::string value);
+  const char* get_property(const std::string& key) const;
+  void set_property(const std::string& id, const std::string& value);
 
-  /* FIXME: This should not be exposed, as users may do bad things with the map they got (it's not a copy).
-   * But some user API expose this call so removing it is not so easy.
-   */
-  std::unordered_map<std::string, std::string>* get_properties();
+  const std::unordered_map<std::string, std::string>* get_properties();
+  template <class Assoc> void set_properties(const Assoc& properties);
 
 private:
-  std::unordered_map<std::string, std::string>* properties_ = nullptr;
+  std::unique_ptr<std::unordered_map<std::string, std::string>> properties_ = nullptr;
 };
 
 } /* namespace surf */