Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines.
[simgrid.git] / include / xbt / PropertyHolder.hpp
1 /* Copyright (c) 2015-2021. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #ifndef XBT_PROPERTYHOLDER_HPP
7 #define XBT_PROPERTYHOLDER_HPP
8
9 #include <memory>
10 #include <string>
11 #include <unordered_map>
12
13 namespace simgrid {
14 namespace xbt {
15
16 /** @brief a PropertyHolder can be given a set of textual properties
17  *
18  * Common PropertyHolders are elements of the platform file, such as Host, Link or Storage.
19  */
20 class PropertyHolder { // DO NOT DERIVE THIS CLASS, or the diamond inheritance mayhem will get you
21   std::unique_ptr<std::unordered_map<std::string, std::string>> properties_ = nullptr;
22
23 public:
24   PropertyHolder()                      = default;
25   PropertyHolder(const PropertyHolder&) = delete;
26   PropertyHolder& operator=(const PropertyHolder&) = delete;
27
28   const char* get_property(const std::string& key) const;
29   void set_property(const std::string& id, const std::string& value);
30
31   const std::unordered_map<std::string, std::string>* get_properties();
32   template <class Assoc> void set_properties(const Assoc& properties);
33 };
34
35 } // namespace xbt
36 } // namespace simgrid
37
38 #endif