Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
get rid of smx_file_t
[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_ATTRIB_PUBLIC std::map<std::string, Storage*>* allStorages();
21
22 XBT_PUBLIC_CLASS Storage
23 {
24   friend s4u::Engine;
25   friend simgrid::surf::StorageImpl;
26
27 public:
28   explicit Storage(surf::StorageImpl * pimpl) : pimpl_(pimpl) {}
29   virtual ~Storage() = default;
30   /** Retrieve a Storage by its name. It must exist in the platform file */
31   static Storage* byName(const char* name);
32   const char* name();
33   const char* type();
34   Host* host();
35   sg_size_t sizeFree();
36   sg_size_t sizeUsed();
37   /** Retrieve the total amount of space of this storage element */
38   sg_size_t size();
39
40   xbt_dict_t properties();
41   const char* property(const char* key);
42   void setProperty(const char* key, char* value);
43   std::map<std::string, sg_size_t>* content();
44
45   void setUserdata(void* data) { userdata_ = data; }
46   void* userdata() { return userdata_; }
47
48   /* The signals */
49   /** @brief Callback signal fired when a new Link is created */
50   static simgrid::xbt::signal<void(s4u::Storage&)> onCreation;
51
52   /** @brief Callback signal fired when a Link is destroyed */
53   static simgrid::xbt::signal<void(s4u::Storage&)> onDestruction;
54
55   Host* attached_to_              = nullptr;
56   surf::StorageImpl* const pimpl_ = nullptr;
57
58 private:
59   std::string name_;
60   void* userdata_ = nullptr;
61 };
62
63 } /* namespace s4u */
64 } /* namespace simgrid */
65
66 #endif /* INCLUDE_SIMGRID_S4U_STORAGE_HPP_ */