Exemple #1
0
int main(int argc, char **argv)
{
  /* initialisation of SD */
  int size;
  SD_init(&argc, argv);
  xbt_lib_cursor_t cursor = NULL;
  char *key, *data;

  /* creation of the environment */
  SD_create_environment(argv[1]);

  size = xbt_lib_length(host_lib) + xbt_lib_length(as_router_lib);

  printf("Workstation number: %d, link number: %d, elmts number: %d\n",
         SD_workstation_get_number(), SD_link_get_number(), size);

  xbt_lib_foreach(host_lib, cursor, key, data) {
    printf("   - Seen: \"%s\" is type : %d\n", key,
           (int) routing_get_network_element_type(key));
  }
Exemple #2
0
/**
 * \brief Returns the link list
 *
 * Use SD_link_get_number() to know the array size.
 *
 * \return an array of \ref SD_link_t containing all links
 * \see SD_link_get_number()
 */
const SD_link_t *SD_link_get_list(void)
{

  xbt_lib_cursor_t cursor;
  char *key;
  void **data;
  int i;

  if (sd_global->link_list == NULL) {   /* this is the first time the function is called */
    sd_global->link_list = xbt_new(SD_link_t, xbt_lib_length(link_lib));

    i = 0;
    xbt_lib_foreach(link_lib, cursor, key, data) {
        sd_global->link_list[i++] = (SD_link_t) data[SD_LINK_LEVEL];
    }
Exemple #3
0
/**
 * \brief Returns the workstation list
 *
 * Use SD_workstation_get_number() to know the array size.
 *
 * \return an array of \ref SD_workstation_t containing all workstations
 * \see SD_workstation_get_number()
 */
const SD_workstation_t *SD_workstation_get_list(void)
{

  xbt_lib_cursor_t cursor;
  char *key;
  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);
    }
  }
Exemple #4
0
msg_host_t *MSG_get_host_table(void)
{
      void **array;
    int i = 0;
    xbt_lib_cursor_t cursor;
    char *key;
    void **data;

    if (xbt_lib_length(host_lib) == 0)
    return NULL;
    else
    array = xbt_new0(void *, xbt_lib_length(host_lib));

    xbt_lib_foreach(host_lib, cursor, key, data) {
      if(routing_get_network_element_type(key) == SURF_NETWORK_ELEMENT_HOST)
        array[i++] = data[MSG_HOST_LEVEL];
    }

    return (msg_host_t *)array;
}
Exemple #5
0
/** \ingroup m_host_management
 * \brief Return the current number MSG hosts.
 */
int MSG_get_host_number(void)
{
  return xbt_lib_length(host_lib);
}
Exemple #6
0
/**
 * \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);
}