1 /* Copyright (c) 2006-2015, 2017. The SimGrid Team.
2 * All rights reserved. */
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. */
7 #ifndef INCLUDE_SIMGRID_S4U_STORAGE_HPP_
8 #define INCLUDE_SIMGRID_S4U_STORAGE_HPP_
11 #include <simgrid/s4u/forward.hpp>
12 #include <simgrid/simix.h>
14 #include <unordered_map>
20 XBT_ATTRIB_PUBLIC std::map<std::string, Storage*>* allStorages();
22 XBT_PUBLIC_CLASS Storage
25 friend simgrid::surf::StorageImpl;
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* getName();
33 const char* getType();
35 sg_size_t getSize(); /** Retrieve the total amount of space of this storage element */
36 sg_size_t getSizeFree();
37 sg_size_t getSizeUsed();
39 std::map<std::string, std::string>* getProperties();
40 const char* getProperty(const char* key);
41 void setProperty(const char* key, const char* value);
42 std::map<std::string, sg_size_t>* getContent();
44 void setUserdata(void* data) { userdata_ = data; }
45 void* getUserdata() { return userdata_; }
47 surf::StorageImpl* getImpl() { return pimpl_; }
50 /** @brief Callback signal fired when a new Link is created */
51 static simgrid::xbt::signal<void(s4u::Storage&)> onCreation;
53 /** @brief Callback signal fired when a Link is destroyed */
54 static simgrid::xbt::signal<void(s4u::Storage&)> onDestruction;
56 Host* attached_to_ = nullptr;
59 surf::StorageImpl* const pimpl_ = nullptr;
61 void* userdata_ = nullptr;
65 } /* namespace simgrid */
67 #endif /* INCLUDE_SIMGRID_S4U_STORAGE_HPP_ */