1 /* Copyright (c) 2006-2018. The SimGrid Team. All rights reserved. */
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. */
6 #ifndef INCLUDE_SIMGRID_S4U_STORAGE_HPP_
7 #define INCLUDE_SIMGRID_S4U_STORAGE_HPP_
9 #include <simgrid/s4u/forward.hpp>
10 #include <simgrid/simix.h>
11 #include <xbt/Extendable.hpp>
16 #include <unordered_map>
20 extern template class XBT_PUBLIC Extendable<simgrid::s4u::Storage>;
24 XBT_PUBLIC void getStorageList(std::map<std::string, Storage*>* whereTo);
26 class XBT_PUBLIC Storage : public simgrid::xbt::Extendable<Storage> {
28 friend simgrid::surf::StorageImpl;
31 explicit Storage(std::string name, surf::StorageImpl * pimpl);
32 virtual ~Storage() = default;
33 /** Retrieve a Storage by its name. It must exist in the platform file */
34 static Storage* byName(std::string name);
35 /** @brief Retrieves the name of that storage as a C++ string */
36 std::string const& getName() const;
37 /** @brief Retrieves the name of that storage as a C string */
38 const char* getCname() const;
39 const char* getType();
42 std::map<std::string, std::string>* getProperties();
43 const char* getProperty(std::string key);
44 void setProperty(std::string, std::string value);
46 void setUserdata(void* data) { userdata_ = data; }
47 void* getUserdata() { return userdata_; }
49 sg_size_t read(sg_size_t size);
50 sg_size_t write(sg_size_t size);
51 surf::StorageImpl* getImpl() { return pimpl_; }
54 /** @brief Callback signal fired when a new Link is created */
55 static simgrid::xbt::signal<void(s4u::Storage&)> onCreation;
57 /** @brief Callback signal fired when a Link is destroyed */
58 static simgrid::xbt::signal<void(s4u::Storage&)> onDestruction;
60 Host* attached_to_ = nullptr;
63 surf::StorageImpl* const pimpl_ = nullptr;
65 void* userdata_ = nullptr;
69 } /* namespace simgrid */
71 #endif /* INCLUDE_SIMGRID_S4U_STORAGE_HPP_ */