Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
convert getCname to get_cname
[simgrid.git] / include / simgrid / s4u / Storage.hpp
1 /* Copyright (c) 2006-2018. The SimGrid Team. All rights reserved.          */
2
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. */
5
6 #ifndef INCLUDE_SIMGRID_S4U_STORAGE_HPP_
7 #define INCLUDE_SIMGRID_S4U_STORAGE_HPP_
8
9 #include <simgrid/s4u/forward.hpp>
10 #include <simgrid/simix.h>
11 #include <xbt/Extendable.hpp>
12 #include <xbt/base.h>
13
14 #include <map>
15 #include <string>
16 #include <unordered_map>
17
18 namespace simgrid {
19 namespace xbt {
20 extern template class XBT_PUBLIC Extendable<simgrid::s4u::Storage>;
21 }
22 namespace s4u {
23
24 XBT_PUBLIC void getStorageList(std::map<std::string, Storage*>* whereTo);
25
26 class XBT_PUBLIC Storage : public simgrid::xbt::Extendable<Storage> {
27   friend s4u::Engine;
28   friend simgrid::surf::StorageImpl;
29
30 public:
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
36   XBT_ATTRIB_DEPRECATED_v323("Please use Storage::get_name()") std::string const& getName() const { return get_name(); }
37   XBT_ATTRIB_DEPRECATED_v323("Please use Storage::get_cname()") const char* getCname() const { return get_cname(); }
38
39   /** @brief Retrieves the name of that storage as a C++ string */
40   std::string const& get_name() const;
41   /** @brief Retrieves the name of that storage as a C string */
42   const char* get_cname() const;
43
44   const char* getType();
45   Host* getHost();
46
47   std::map<std::string, std::string>* getProperties();
48   const char* getProperty(std::string key);
49   void setProperty(std::string, std::string value);
50
51   void setUserdata(void* data) { userdata_ = data; }
52   void* getUserdata() { return userdata_; }
53
54   sg_size_t read(sg_size_t size);
55   sg_size_t write(sg_size_t size);
56   surf::StorageImpl* getImpl() { return pimpl_; }
57
58   /* The signals */
59   /** @brief Callback signal fired when a new Link is created */
60   static simgrid::xbt::signal<void(s4u::Storage&)> onCreation;
61
62   /** @brief Callback signal fired when a Link is destroyed */
63   static simgrid::xbt::signal<void(s4u::Storage&)> onDestruction;
64
65   Host* attached_to_              = nullptr;
66
67 private:
68   surf::StorageImpl* const pimpl_ = nullptr;
69   std::string name_;
70   void* userdata_ = nullptr;
71 };
72
73 } /* namespace s4u */
74 } /* namespace simgrid */
75
76 #endif /* INCLUDE_SIMGRID_S4U_STORAGE_HPP_ */