Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Unify models apis
[simgrid.git] / src / surf / workstation_interface.hpp
index 9368025..6b0b975 100644 (file)
@@ -43,20 +43,22 @@ extern surf_callback(void, WorkstationPtr) workstationDestructedCallbacks;
 
 /** @ingroup SURF_callbacks
  * @brief Callbacks handler which emit the callbacks after Workstation State changed *
- * @details Callback functions have the following signature: `void(WorkstationActionPtr)`
+ * @details Callback functions have the following signature: `void(WorkstationActionPtr action, e_surf_resource_state_t old, e_surf_resource_state_t current)`
  */
-extern surf_callback(void, WorkstationPtr) workstationStateChangedCallbacks;
+extern surf_callback(void, WorkstationPtr, e_surf_resource_state_t, e_surf_resource_state_t) workstationStateChangedCallbacks;
 
 /** @ingroup SURF_callbacks
  * @brief Callbacks handler which emit the callbacks after WorkstationAction State changed *
- * @details Callback functions have the following signature: `void(WorkstationActionPtr)`
+ * @details Callback functions have the following signature: `void(WorkstationActionPtr action, e_surf_resource_state_t old, e_surf_resource_state_t current)`
  */
-extern surf_callback(void, WorkstationActionPtr) workstationActionStateChangedCallbacks;
+extern surf_callback(void, WorkstationActionPtr, e_surf_action_state_t, e_surf_action_state_t) workstationActionStateChangedCallbacks;
 
 /*********
  * Tools *
  *********/
 extern WorkstationModelPtr surf_workstation_model;
+XBT_PUBLIC(void) workstation_parse_init(sg_platf_host_cbarg_t host);
+XBT_PUBLIC(void) workstation_add_traces();
 
 /*********
  * Model *
@@ -67,9 +69,9 @@ extern WorkstationModelPtr surf_workstation_model;
  */
 class WorkstationModel : public Model {
 public:
-    /** 
+    /**
    * @brief WorkstationModel constructor
-   * 
+   *
    * @param name the name of the model
    */
   WorkstationModel(const char *name);
@@ -84,16 +86,19 @@ public:
    */
   ~WorkstationModel();
 
+  virtual WorkstationPtr createWorkstation(const char *name)=0;
+  void addTraces(){DIE_IMPOSSIBLE;}
+
   /**
    * @brief [brief description]
    * @details [long description]
    */
   virtual void adjustWeightOfDummyCpuActions();
-  
+
   /**
    * @brief [brief description]
    * @details [long description]
-   * 
+   *
    * @param workstation_nb [description]
    * @param workstation_list [description]
    * @param computation_amount [description]
@@ -110,7 +115,7 @@ public:
  /**
   * @brief [brief description]
   * @details [long description]
-  * 
+  *
   * @param src [description]
   * @param dst [description]
   * @param size [description]
@@ -138,7 +143,7 @@ public:
 
   /**
    * @brief Workstation constructor
-   * 
+   *
    * @param model WorkstationModel associated to this Workstation
    * @param name The name of the Workstation
    * @param props Dictionary of properties associated to this Workstation
@@ -151,7 +156,7 @@ public:
 
   /**
    * @brief Workstation constructor
-   * 
+   *
    * @param model WorkstationModel associated to this Workstation
    * @param name The name of the Workstation
    * @param props Dictionary of properties associated to this Workstation
@@ -179,7 +184,7 @@ public:
 
   /**
    * @brief Execute some quantity of computation
-   * 
+   *
    * @param size The value of the processing amount (in flop) needed to process
    * @return The CpuAction corresponding to the processing
    * @see Cpu
@@ -188,7 +193,7 @@ public:
 
   /**
    * @brief Make a process sleep for duration seconds
-   * 
+   *
    * @param duration The number of seconds to sleep
    * @return The CpuAction corresponding to the sleeping
    * @see Cpu
@@ -197,7 +202,7 @@ public:
 
   /**
    * @brief Get the number of cores of the associated Cpu
-   * 
+   *
    * @return The number of cores of the associated Cpu
    * @see Cpu
    */
@@ -205,7 +210,7 @@ public:
 
   /**
    * @brief Get the speed of the associated Cpu
-   * 
+   *
    * @param load [TODO]
    * @return The speed of the associated Cpu
    * @see Cpu
@@ -215,7 +220,7 @@ public:
   /**
    * @brief Get the available speed of the associated Cpu
    * @details [TODO]
-   * 
+   *
    * @return The available speed of the associated Cpu
    * @see Cpu
    */
@@ -223,7 +228,7 @@ public:
 
   /**
    * @brief Get the associated Cpu power peak
-   * 
+   *
    * @return The associated Cpu power peak
    * @see Cpu
    */
@@ -235,7 +240,7 @@ public:
 
   /**
    * @brief Return the storage of corresponding mount point
-   * 
+   *
    * @param storage The mount point
    * @return The corresponding Storage
    */
@@ -243,31 +248,30 @@ public:
 
   /**
    * @brief Get the xbt_dict_t of mount_point: Storage
-   * 
+   *
    * @return The xbt_dict_t of mount_point: Storage
    */
   virtual xbt_dict_t getMountedStorageList();
 
   /**
-   * @brief Get the xbt_dict_t of storages attached to the workstation
+   * @brief Get the xbt_dynar_t of storages attached to the workstation
    *
-   * @return The xbt_dict_t of Storage
+   * @return The xbt_dynar_t of Storage names
    */
-  virtual xbt_dict_t getAttachedStorageList();
+  virtual xbt_dynar_t getAttachedStorageList();
 
   /**
    * @brief Open a file
-   * 
-   * @param mount The mount point
-   * @param path The path to the file
-   * 
+   *
+   * @param fullpath The full path to the file
+   *
    * @return The StorageAction corresponding to the opening
    */
-  virtual ActionPtr open(const char* mount, const char* path);
+  virtual ActionPtr open(const char* fullpath);
 
   /**
    * @brief Close a file
-   * 
+   *
    * @param fd The file descriptor to close
    * @return The StorageAction corresponding to the closing
    */
@@ -276,25 +280,15 @@ public:
   /**
    * @brief Unlink a file
    * @details [long description]
-   * 
+   *
    * @param fd [description]
    * @return [description]
    */
   virtual int unlink(surf_file_t fd);
 
-  /**
-   * @brief List directory contents of a path
-   * @details [long description]
-   * 
-   * @param mount [description]
-   * @param path The path to the directory
-   * @return The StorageAction corresponding to the ls action
-   */
-  virtual ActionPtr ls(const char* mount, const char *path);
-
   /**
    * @brief Get the size in bytes of the file
-   * 
+   *
    * @param fd The file descriptor to read
    * @return The size in bytes of the file
    */
@@ -302,7 +296,7 @@ public:
 
   /**
    * @brief Read a file
-   * 
+   *
    * @param fd The file descriptor to read
    * @param size The size in bytes to read
    * @return The StorageAction corresponding to the reading
@@ -311,7 +305,7 @@ public:
 
   /**
    * @brief Write a file
-   * 
+   *
    * @param fd The file descriptor to write
    * @param size The size in bytes to write
    * @return The StorageAction corresponding to the writing
@@ -326,7 +320,7 @@ public:
    *  - the storage name,
    *  - the storage typeId,
    *  - the storage content type
-   * 
+   *
    * @param fd The file descriptor
    * @return An xbt_dynar_t with the file informations
    */
@@ -334,32 +328,16 @@ public:
 
   /**
    * @brief Get the current position of the file descriptor
-   *  
+   *
    * @param fd The file descriptor
    * @return The current position of the file descriptor
    */
   virtual sg_size_t fileTell(surf_file_t fd);
 
   /**
-   * @brief Get the available space of the storage at the mount point 
-   * 
-   * @param name The mount point
-   * @return The amount of availble space in bytes
-   */
-  virtual sg_size_t getFreeSize(const char* name);
-
-  /**
-   * @brief Get the used space of the storage at the mount point
-   * 
-   * @param name The mount point
-   * @return The amount of used space in bytes
-   */
-  virtual sg_size_t getUsedSize(const char* name);
-
-  /**
-   * @brief Set the position indictator assiociated with the file descriptor to a new position
+   * @brief Set the position indicator associated with the file descriptor to a new position
    * @details [long description]
-   * 
+   *
    * @param fd The file descriptor
    * @param offset The offset from the origin
    * @param origin Position used as a reference for the offset
@@ -370,6 +348,17 @@ public:
    */
   virtual int fileSeek(surf_file_t fd, sg_size_t offset, int origin);
 
+  /**
+   * @brief Move a file to another location on the *same mount point*.
+   * @details [long description]
+   *
+   * @param fd The file descriptor
+   * @param fullpath The new full path
+   * @return MSG_OK if successful, MSG_TASK_CANCELED and a warning if the new
+   * full path is not on the same mount point
+   */
+  virtual int fileMove(surf_file_t fd, const char* fullpath);
+
   xbt_dynar_t p_storage;
   RoutingEdgePtr p_netElm;
   CpuPtr p_cpu;
@@ -377,7 +366,7 @@ public:
 
   /**
    * @brief Get the list of virtual machines on the current Workstation
-   * 
+   *
    * @return The list of VMs
    */
   xbt_dynar_t getVms();
@@ -386,7 +375,7 @@ public:
   /**
    * @brief [brief description]
    * @details [long description]
-   * 
+   *
    * @param params [description]
    */
   void getParams(ws_params_t params);
@@ -394,7 +383,7 @@ public:
   /**
    * @brief [brief description]
    * @details [long description]
-   * 
+   *
    * @param params [description]
    */
   void setParams(ws_params_t params);
@@ -412,7 +401,7 @@ class WorkstationAction : public Action {
 public:
   /**
    * @brief WorkstationAction constructor
-   * 
+   *
    * @param model The WorkstationModel associated to this WorkstationAction
    * @param cost The cost of this WorkstationAction in [TODO]
    * @param failed [description]
@@ -422,7 +411,7 @@ public:
 
   /**
    * @brief WorkstationAction constructor
-   * 
+   *
    * @param model The WorkstationModel associated to this WorkstationAction
    * @param cost The cost of this WorkstationAction in [TODO]
    * @param failed [description]