1 /* Copyright (c) 2004-2016. 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 #include "surf_interface.hpp"
7 #include "storage_interface.hpp"
8 #include "cpu_interface.hpp"
9 #include "network_interface.hpp"
10 #include "src/surf/PropertyHolder.hpp"
14 #ifndef SURF_HOST_INTERFACE_HPP_
15 #define SURF_HOST_INTERFACE_HPP_
24 class XBT_PRIVATE HostModel;
25 class XBT_PRIVATE HostImpl;
26 class XBT_PRIVATE HostAction;
34 XBT_PUBLIC_DATA(simgrid::surf::HostModel*) surf_host_model;
43 /** @ingroup SURF_host_interface
44 * @brief SURF Host model interface class
45 * @details A model is an object which handle the interactions between its Resources and its Actions
47 class HostModel : public Model {
49 HostModel() : Model() {}
51 virtual void adjustWeightOfDummyCpuActions();
52 virtual Action* executeParallelTask(int host_nb, sg_host_t* host_list, double* flops_amount, double* bytes_amount,
59 /** @ingroup SURF_host_interface
60 * @brief SURF Host interface class
61 * @details An host represents a machine with a aggregation of a Cpu, a RoutingEdge and a Storage
63 class HostImpl : public simgrid::surf::PropertyHolder {
66 explicit HostImpl(s4u::Host* host);
70 /** @brief Return the storage of corresponding mount point */
71 virtual simgrid::surf::Storage* findStorageOnMountList(const char* storage);
73 /** @brief Get the xbt_dict_t of mount_point: Storage */
74 virtual xbt_dict_t getMountedStorageList();
76 /** @brief Get the xbt_dynar_t of storages attached to the Host */
77 virtual xbt_dynar_t getAttachedStorageList();
82 * @param fullpath The full path to the file
83 * @return The StorageAction corresponding to the opening
85 virtual Action* open(const char* fullpath);
90 * @param fd The file descriptor to close
91 * @return The StorageAction corresponding to the closing
93 virtual Action* close(surf_file_t fd);
96 * @brief Unlink a file
97 * @details [long description]
99 * @param fd [description]
100 * @return [description]
102 virtual int unlink(surf_file_t fd);
105 * @brief Get the size in bytes of the file
107 * @param fd The file descriptor to read
108 * @return The size in bytes of the file
110 virtual sg_size_t getSize(surf_file_t fd);
115 * @param fd The file descriptor to read
116 * @param size The size in bytes to read
117 * @return The StorageAction corresponding to the reading
119 virtual Action* read(surf_file_t fd, sg_size_t size);
122 * @brief Write a file
124 * @param fd The file descriptor to write
125 * @param size The size in bytes to write
126 * @return The StorageAction corresponding to the writing
128 virtual Action* write(surf_file_t fd, sg_size_t size);
131 * @brief Get the information of a file descriptor
132 * @details The returned xbt_dynar_t contains:
133 * - the size of the file,
135 * - the storage name,
136 * - the storage typeId,
137 * - the storage content type
139 * @param fd The file descriptor
140 * @return An xbt_dynar_t with the file information
142 virtual xbt_dynar_t getInfo(surf_file_t fd);
145 * @brief Get the current position of the file descriptor
147 * @param fd The file descriptor
148 * @return The current position of the file descriptor
150 virtual sg_size_t fileTell(surf_file_t fd);
153 * @brief Set the position indicator associated with the file descriptor to a new position
154 * @details [long description]
156 * @param fd The file descriptor
157 * @param offset The offset from the origin
158 * @param origin Position used as a reference for the offset
159 * - SEEK_SET: beginning of the file
160 * - SEEK_CUR: current position indicator
161 * - SEEK_END: end of the file
162 * @return MSG_OK if successful, otherwise MSG_TASK_CANCELED
164 virtual int fileSeek(surf_file_t fd, sg_offset_t offset, int origin);
167 * @brief Move a file to another location on the *same mount point*.
168 * @details [long description]
170 * @param fd The file descriptor
171 * @param fullpath The new full path
172 * @return MSG_OK if successful, MSG_TASK_CANCELED and a warning if the new
173 * full path is not on the same mount point
175 virtual int fileMove(surf_file_t fd, const char* fullpath);
178 xbt_dynar_t storage_ = nullptr;
179 simgrid::s4u::Host* piface_ = nullptr;
181 simgrid::s4u::Host* getHost() { return piface_; }
186 #endif /* SURF_Host_INTERFACE_HPP_ */