Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
b99651b339fb9cd5635b65f98180dead9fd90ff1
[simgrid.git] / include / simgrid / s4u / storage.hpp
1 /* Copyright (c) 2006-2015. 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 <string>
11
12 #include <boost/unordered_map.hpp>
13
14 #include <xbt/base.h>
15
16 #include <simgrid/simix.h>
17 #include <simgrid/s4u/forward.hpp>
18
19 namespace simgrid {
20 namespace s4u {
21
22 XBT_PUBLIC_CLASS Storage {
23   friend s4u::Engine;
24
25   Storage(std::string name, smx_storage_t inferior);
26   virtual ~Storage();
27
28 public:
29   /** Retrieve a Storage by its name. It must exist in the platform file */
30   static Storage &byName(const char* name);
31   const char *name();
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
37   /* TODO: missing API:
38 XBT_PUBLIC(xbt_dict_t) MSG_storage_get_properties(msg_storage_t storage);
39 XBT_PUBLIC(void) MSG_storage_set_property_value(msg_storage_t storage, const char *name, char *value,void_f_pvoid_t free_ctn);
40 XBT_PUBLIC(const char *)MSG_storage_get_property_value(msg_storage_t storage, const char *name);
41 XBT_PUBLIC(xbt_dynar_t) MSG_storages_as_dynar(void);
42 XBT_PUBLIC(xbt_dict_t) MSG_storage_get_content(msg_storage_t storage);
43 XBT_PUBLIC(msg_error_t) MSG_storage_file_move(msg_file_t fd, msg_host_t dest, char* mount, char* fullname);
44 XBT_PUBLIC(const char *) MSG_storage_get_host(msg_storage_t storage);
45    */
46 protected:
47   smx_storage_t inferior();
48
49 public:
50   void setUserdata(void *data) {userdata_ = data;}
51   void *userdata() {return userdata_;}
52   
53 private:
54   static boost::unordered_map<std::string, Storage *> *storages_;
55
56   std::string name_;
57   smx_storage_t pimpl_ = nullptr;
58   void *userdata_ = nullptr;
59 };
60
61 } /* namespace s4u */
62 } /* namespace simgrid */
63
64 #endif /* INCLUDE_SIMGRID_S4U_STORAGE_HPP_ */