Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
don't pass property set to the storage constructor, there is no need
[simgrid.git] / src / surf / HostImpl.hpp
1 /* Copyright (c) 2004-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 #include "surf_interface.hpp"
8 #include "storage_interface.hpp"
9 #include "cpu_interface.hpp"
10 #include "network_interface.hpp"
11 #include "src/surf/PropertyHolder.hpp"
12
13 #include <xbt/base.h>
14
15 #ifndef SURF_HOST_INTERFACE_HPP_
16 #define SURF_HOST_INTERFACE_HPP_
17
18 /***********
19  * Classes *
20  ***********/
21
22 namespace simgrid {
23 namespace surf {
24
25 class XBT_PRIVATE HostModel;
26 class XBT_PRIVATE HostImpl;
27 class XBT_PRIVATE HostAction;
28
29
30 }
31 }
32
33 /*********
34  * Tools *
35  *********/
36
37 XBT_PUBLIC_DATA(simgrid::surf::HostModel*) surf_host_model;
38
39 /*********
40  * Model *
41  *********/
42
43 namespace simgrid {
44 namespace surf {
45
46 /** @ingroup SURF_host_interface
47  * @brief SURF Host model interface class
48  * @details A model is an object which handle the interactions between its Resources and its Actions
49  */
50 class HostModel : public Model {
51 public:
52   HostModel() : Model() {}
53
54   virtual void adjustWeightOfDummyCpuActions();
55   virtual Action *executeParallelTask(int host_nb, sg_host_t *host_list,
56       double *flops_amount, double *bytes_amount, double rate);
57 };
58
59 /************
60  * Resource *
61  ************/
62 /** @ingroup SURF_host_interface
63  * @brief SURF Host interface class
64  * @details An host represents a machine with a aggregation of a Cpu, a RoutingEdge and a Storage
65  */
66 class HostImpl : public simgrid::surf::PropertyHolder {
67
68 public:
69   HostImpl(s4u::Host* host, xbt_dynar_t storage);
70   virtual ~HostImpl();
71
72 public:
73   /** @brief Return the storage of corresponding mount point */
74   virtual simgrid::surf::Storage *findStorageOnMountList(const char* storage);
75
76   /** @brief Get the xbt_dict_t of mount_point: Storage */
77   virtual xbt_dict_t getMountedStorageList();
78
79   /** @brief Get the xbt_dynar_t of storages attached to the Host */
80   virtual xbt_dynar_t getAttachedStorageList();
81
82   /**
83    * @brief Open a file
84    *
85    * @param fullpath The full path to the file
86    * @return The StorageAction corresponding to the opening
87    */
88   virtual Action *open(const char* fullpath);
89
90   /**
91    * @brief Close a file
92    *
93    * @param fd The file descriptor to close
94    * @return The StorageAction corresponding to the closing
95    */
96   virtual Action *close(surf_file_t fd);
97
98   /**
99    * @brief Unlink a file
100    * @details [long description]
101    *
102    * @param fd [description]
103    * @return [description]
104    */
105   virtual int unlink(surf_file_t fd);
106
107   /**
108    * @brief Get the size in bytes of the file
109    *
110    * @param fd The file descriptor to read
111    * @return The size in bytes of the file
112    */
113   virtual sg_size_t getSize(surf_file_t fd);
114
115   /**
116    * @brief Read a file
117    *
118    * @param fd The file descriptor to read
119    * @param size The size in bytes to read
120    * @return The StorageAction corresponding to the reading
121    */
122   virtual Action *read(surf_file_t fd, sg_size_t size);
123
124   /**
125    * @brief Write a file
126    *
127    * @param fd The file descriptor to write
128    * @param size The size in bytes to write
129    * @return The StorageAction corresponding to the writing
130    */
131   virtual Action *write(surf_file_t fd, sg_size_t size);
132
133   /**
134    * @brief Get the information of a file descriptor
135    * @details The returned xbt_dynar_t contains:
136    *  - the size of the file,
137    *  - the mount point,
138    *  - the storage name,
139    *  - the storage typeId,
140    *  - the storage content type
141    *
142    * @param fd The file descriptor
143    * @return An xbt_dynar_t with the file information
144    */
145   virtual xbt_dynar_t getInfo(surf_file_t fd);
146
147   /**
148    * @brief Get the current position of the file descriptor
149    *
150    * @param fd The file descriptor
151    * @return The current position of the file descriptor
152    */
153   virtual sg_size_t fileTell(surf_file_t fd);
154
155   /**
156    * @brief Set the position indicator associated with the file descriptor to a new position
157    * @details [long description]
158    *
159    * @param fd The file descriptor
160    * @param offset The offset from the origin
161    * @param origin Position used as a reference for the offset
162    *  - SEEK_SET: beginning of the file
163    *  - SEEK_CUR: current position indicator
164    *  - SEEK_END: end of the file
165    * @return MSG_OK if successful, otherwise MSG_TASK_CANCELED
166    */
167   virtual int fileSeek(surf_file_t fd, sg_offset_t offset, int origin);
168
169   /**
170    * @brief Move a file to another location on the *same mount point*.
171    * @details [long description]
172    *
173    * @param fd The file descriptor
174    * @param fullpath The new full path
175    * @return MSG_OK if successful, MSG_TASK_CANCELED and a warning if the new
176    * full path is not on the same mount point
177    */
178   virtual int fileMove(surf_file_t fd, const char* fullpath);
179
180 public:
181   xbt_dynar_t storage_        = nullptr;
182   simgrid::s4u::Host* piface_ = nullptr;
183
184   /** @brief Get the list of virtual machines on the current Host */
185   xbt_dynar_t getVms();
186
187   simgrid::s4u::Host* getHost() { return piface_; }
188 };
189
190 }
191 }
192
193 #endif /* SURF_Host_INTERFACE_HPP_ */