Exemplo n.º 1
0
long dataset_number(std::string& host_name, std::string storage_type){
    /**
        Returns a number of dataset on a given storage.
         
        Parameters:
        ----------
        @host_name -- name of host
        @storage_type -- DISK or TAPE
    */
    std::string storage_name = host_name + storage_type;
    msg_storage_t st = MSG_storage_get_by_name(storage_name.c_str());

    xbt_dict_cursor_t cursor = NULL;
    char *key;
    double data;
    long amount = 0;

    xbt_dict_t storage_content = MSG_storage_get_content(st);
    xbt_dict_foreach(storage_content, cursor, key, data){
        amount++;
    }

    xbt_dict_free(&storage_content);
    xbt_dict_cursor_free(&cursor);
    return amount;
}
Exemplo n.º 2
0
/**
 * @brief Get current data, or free the cursor if there is no data left
 *
 * @returns true if it's ok, false if there is no more data
 */
inline int xbt_dict_cursor_get_or_free(xbt_dict_cursor_t * cursor, char **key, void **data)
{
  xbt_dictelm_t current;

  XBT_CDEBUG(xbt_dict_cursor, "xbt_dict_get_or_free");

  if (!cursor || !(*cursor))
    return FALSE;

  current = (*cursor)->current;
  if (current == NULL) {        /* no data left */
    xbt_dict_cursor_free(cursor);
    return FALSE;
  }

  *key = current->key;
  *data = current->content;
  return TRUE;
}