Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
move CPU models to kernel::resource too
[simgrid.git] / src / surf / PropertyHolder.hpp
1 /* Copyright (c) 2015-2019. 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 SRC_SURF_PROPERTYHOLDER_HPP_
7 #define SRC_SURF_PROPERTYHOLDER_HPP_
8 #include <string>
9 #include <unordered_map>
10
11 namespace simgrid {
12 namespace surf {
13
14 /** @brief a PropertyHolder can be given a set of textual properties
15  *
16  * Common PropertyHolders are elements of the platform file, such as Host, Link or Storage.
17  */
18 class PropertyHolder { // DO NOT DERIVE THIS CLASS, or the diamond inheritance mayhem will get you
19
20 public:
21   PropertyHolder() = default;
22   PropertyHolder(const PropertyHolder&) = delete;
23   PropertyHolder& operator=(const PropertyHolder&) = delete;
24   ~PropertyHolder();
25
26   const char* get_property(const std::string& key) const;
27   void set_property(const std::string& id, const std::string& value);
28
29   /* FIXME: This should not be exposed, as users may do bad things with the map they got (it's not a copy).
30    * But some user API expose this call so removing it is not so easy.
31    */
32   std::unordered_map<std::string, std::string>* get_properties();
33
34 private:
35   std::unordered_map<std::string, std::string>* properties_ = nullptr;
36 };
37
38 } /* namespace surf */
39 } /* namespace simgrid */
40
41 #endif /* SRC_SURF_PROPERTYHOLDER_HPP_ */