示例#1
0
/**
 * \brief Returns the number of existing hosts.
 * \param L a Lua state
 * \return number of values returned to Lua
 *
 * - Return value (number): number of hosts
 */
static int l_host_number(lua_State * L)
{
  xbt_dynar_t hosts = sg_hosts_as_dynar();
  lua_pushinteger(L, xbt_dynar_length(hosts));
  xbt_dynar_free(&hosts);
  return 1;
}
示例#2
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
 * \remark The workstation order in the returned array is generally different from the workstation creation/declaration order in the XML platform (we use a hash table internally).
 * \see SD_workstation_get_number()
 */
const SD_workstation_t *SD_workstation_get_list(void) {
  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_dynar_to_array(sg_hosts_as_dynar());

  return sd_global->workstation_list;
}
示例#3
0
/**
 * \brief Returns the host given its index.
 * \param L a Lua state
 * \return number of values returned to Lua
 *
 * - Argument 1 (number): an index (1 is the first)
 * - Return value (host): the host at this index
 */
static int l_host_at(lua_State * L)
{
  int index = luaL_checkinteger(L, 1);
  xbt_dynar_t hosts = sg_hosts_as_dynar();
  sg_host_t host = xbt_dynar_get_as(hosts,index - 1,sg_host_t);// lua indexing start by 1 (lua[1] <=> C[0])
  lua_newtable(L);              /* create a table, put the userdata on top of it */
  sg_host_t *lua_host = (sg_host_t *) lua_newuserdata(L, sizeof(sg_host_t));
  *lua_host = host;
  luaL_getmetatable(L, HOST_MODULE_NAME);
  lua_setmetatable(L, -2);
  lua_setfield(L, -2, HOST_FIELDNAME);        /* put the userdata as field of the table */
  xbt_dynar_free(&hosts);
  return 1;
}
示例#4
0
/** @brief Returns the host list
 *
 * Uses sg_host_count() to know the array size.
 *
 * \return an array of \ref sg_host_t containing all the hosts in the platform.
 * \remark The host order in this array is generally different from the
 * creation/declaration order in the XML platform (we use a hash table
 * internally).
 * \see sg_host_count()
 */
sg_host_t *sg_host_list(void) {
  xbt_assert(sg_host_count() > 0, "There is no host!");
  return (sg_host_t*)xbt_dynar_to_array(sg_hosts_as_dynar());
}
示例#5
0
/** \ingroup m_host_management
 * \brief Return a dynar containing all the hosts declared at a given point of time
 * \remark The host order in the returned array is generally different from the host creation/declaration order in the XML platform (we use a hash table internally)
 */
xbt_dynar_t MSG_hosts_as_dynar(void) {
  return sg_hosts_as_dynar();
}