Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
[simgrid.git] / src / surf / PropertyHolder.hpp
1 /* Copyright (c) 2015. 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 <map>
9 #include <string>
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();
23
24   const char* getProperty(std::string key);
25   void setProperty(std::string id, std::string value);
26
27   /* FIXME: This should not be exposed, as users may do bad things with the dict they got (it's not a copy).
28    * But some user API expose this call so removing it is not so easy.
29    */
30   std::map<std::string, std::string>* getProperties();
31
32 private:
33   std::map<std::string, std::string>* properties_ = nullptr;
34 };
35
36 } /* namespace surf */
37 } /* namespace simgrid */
38
39 #endif /* SRC_SURF_PROPERTYHOLDER_HPP_ */