Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill dead code
[simgrid.git] / include / simgrid / s4u / storage.hpp
1 /* Copyright (c) 2006-2015, 2017. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef INCLUDE_SIMGRID_S4U_STORAGE_HPP_
8 #define INCLUDE_SIMGRID_S4U_STORAGE_HPP_
9
10 #include <map>
11 #include <simgrid/s4u/forward.hpp>
12 #include <simgrid/simix.h>
13 #include <string>
14 #include <unordered_map>
15 #include <xbt/base.h>
16
17 namespace simgrid {
18 namespace s4u {
19
20 XBT_PUBLIC_CLASS Storage {
21   friend s4u::Engine;
22
23   Storage(std::string name, smx_storage_t inferior);
24
25 public:
26   Storage() = default;
27   virtual ~Storage();
28   /** Retrieve a Storage by its name. It must exist in the platform file */
29   static Storage &byName(const char* name);
30   const char *name();
31   const char* host();
32   sg_size_t sizeFree();
33   sg_size_t sizeUsed();
34   /** Retrieve the total amount of space of this storage element */
35   sg_size_t size();
36   xbt_dict_t properties();
37   const char* property(const char* key);
38   void setProperty(const char* key, char* value);
39   std::map<std::string, sg_size_t*>* content();
40   std::unordered_map<std::string, Storage*>* allStorages();
41
42 protected:
43   smx_storage_t inferior();
44
45 public:
46   void setUserdata(void *data) {userdata_ = data;}
47   void *userdata() {return userdata_;}
48   
49 private:
50   static std::unordered_map<std::string, Storage*>* storages_;
51
52   std::string hostname_;
53   std::string name_;
54   sg_size_t size_      = 0;
55   smx_storage_t pimpl_ = nullptr;
56   void* userdata_      = nullptr;
57 };
58
59 } /* namespace s4u */
60 } /* namespace simgrid */
61
62 #endif /* INCLUDE_SIMGRID_S4U_STORAGE_HPP_ */