Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix MC which uses simgrid::xbt::string
[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 <xbt/dict.h>
9
10 namespace simgrid {
11 namespace surf {
12
13 /** @brief a PropertyHolder can be given a set of textual properties
14  *
15  * Common PropertyHolders are elements of the platform file, such as Host, Link or Storage.
16  */
17 class PropertyHolder { // DO NOT DERIVE THIS CLASS, or the diamond inheritance mayhem will get you
18
19 public:
20   explicit PropertyHolder();
21   ~PropertyHolder();
22
23   const char *getProperty(const char*id);
24   void setProperty(const char*id, const char*value);
25
26   /* FIXME: This should not be exposed, as users may do bad things with the dict they got (it's not a copy).
27    * But some user API expose this call so removing it is not so easy.
28    */
29   xbt_dict_t getProperties();
30 private:
31   xbt_dict_t properties_ = nullptr;
32 };
33
34 } /* namespace surf */
35 } /* namespace simgrid */
36
37 #endif /* SRC_SURF_PROPERTYHOLDER_HPP_ */