+ void **data;
+ int i;
+
+ xbt_assert(SD_workstation_get_number() > 0, "There is no workstation!");
+
+ if (sd_global->workstation_list == NULL) { /* this is the first time the function is called */
+ sd_global->workstation_list =
+ xbt_new(SD_workstation_t, xbt_lib_length(host_lib));
+
+ i = 0;
+ xbt_lib_foreach(host_lib, cursor, key, data) {
+ if(data[SD_HOST_LEVEL])
+ sd_global->workstation_list[i++] = xbt_dict_cursor_get_elm(cursor);
+ }
+ }
+ return sd_global->workstation_list;
+}
+
+/**
+ * \brief Returns the number of workstations
+ *
+ * \return the number of existing workstations
+ * \see SD_workstation_get_list()
+ */
+int SD_workstation_get_number(void)
+{
+ return xbt_lib_length(host_lib);
+}
+
+/**
+ * \brief Returns the user data of a workstation
+ *
+ * \param workstation a workstation
+ * \return the user data associated with this workstation (can be \c NULL)
+ * \see SD_workstation_set_data()
+ */
+void *SD_workstation_get_data(SD_workstation_t workstation)
+{
+ return SD_workstation_priv(workstation)->data;
+}
+
+/**
+ * \brief Sets the user data of a workstation
+ *
+ * The new data can be \c NULL. The old data should have been freed first
+ * if it was not \c NULL.
+ *
+ * \param workstation a workstation
+ * \param data the new data you want to associate with this workstation
+ * \see SD_workstation_get_data()
+ */
+void SD_workstation_set_data(SD_workstation_t workstation, void *data)
+{
+ SD_workstation_priv(workstation)->data = data;
+}
+
+/**
+ * \brief Returns the name of a workstation
+ *
+ * \param workstation a workstation
+ * \return the name of this workstation (cannot be \c NULL)
+ */
+const char *SD_workstation_get_name(SD_workstation_t workstation)
+{
+ return sg_host_name(workstation);
+}
+
+/**
+ * \brief Returns the value of a given workstation property
+ *
+ * \param ws a workstation
+ * \param name a property name
+ * \return value of a property (or NULL if property not set)
+ */
+const char *SD_workstation_get_property_value(SD_workstation_t ws,
+ const char *name)
+{
+ return xbt_dict_get_or_null(SD_workstation_get_properties(ws), name);
+}
+
+
+/**
+ * \brief Returns a #xbt_dict_t consisting of the list of properties assigned to this workstation
+ *
+ * \param workstation a workstation
+ * \return the dictionary containing the properties associated with the workstation
+ */
+xbt_dict_t SD_workstation_get_properties(SD_workstation_t workstation)
+{
+ return surf_resource_get_properties(surf_workstation_resource_priv(workstation));
+}
+
+
+/** @brief Displays debugging informations about a workstation */
+void SD_workstation_dump(SD_workstation_t ws)
+{
+ xbt_dict_t props;
+ xbt_dict_cursor_t cursor=NULL;
+ char *key,*data;
+ SD_task_t task = NULL;
+
+ XBT_INFO("Displaying workstation %s", SD_workstation_get_name(ws));
+ XBT_INFO(" - power: %.0f", SD_workstation_get_power(ws));
+ XBT_INFO(" - available power: %.2f", SD_workstation_get_available_power(ws));
+ switch (SD_workstation_priv(ws)->access_mode){
+ case SD_WORKSTATION_SHARED_ACCESS:
+ XBT_INFO(" - access mode: Space shared");
+ break;
+ case SD_WORKSTATION_SEQUENTIAL_ACCESS:
+ XBT_INFO(" - access mode: Exclusive");
+ task = SD_workstation_get_current_task(ws);
+ if(task)
+ XBT_INFO(" current running task: %s",
+ SD_task_get_name(task));
+ else
+ XBT_INFO(" no task running");
+ break;
+ default: break;
+ }
+ props = SD_workstation_get_properties(ws);
+
+ if (!xbt_dict_is_empty(props)){
+ XBT_INFO(" - properties:");
+
+ xbt_dict_foreach(props,cursor,key,data) {
+ XBT_INFO(" %s->%s",key,data);
+ }
+ }
+}
+
+/**
+ * \brief Returns the route between two workstations
+ *
+ * Use SD_route_get_size() to know the array size.
+ *
+ * \param src a workstation
+ * \param dst another workstation
+ * \return a new array of \ref SD_link_t representating the route between these two workstations
+ * \see SD_route_get_size(), SD_link_t
+ */
+const SD_link_t *SD_route_get_list(SD_workstation_t src,
+ SD_workstation_t dst)
+{
+ void *surf_src;
+ void *surf_dst;
+ xbt_dynar_t surf_route;
+ const char *link_name;
+ void *surf_link;
+ unsigned int cpt;
+
+ if (sd_global->recyclable_route == NULL) {
+ /* first run */
+ sd_global->recyclable_route = xbt_new(SD_link_t, SD_link_get_number());
+ }
+
+ surf_src = src;
+ surf_dst = dst;