1 /* Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2010. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "msg_private.h"
8 #include "xbt/sysdep.h"
17 /** \defgroup msg_easier_life Platform and Application management
18 * \brief This section describes functions to manage the platform creation
19 * and the application deployment. You should also have a look at
20 * \ref MSG_examples to have an overview of their usage.
22 /** @addtogroup msg_easier_life
23 * \htmlonly <!-- DOXYGEN_NAVBAR_LABEL="Platforms and Applications" --> \endhtmlonly
27 /********************************* MSG **************************************/
29 /** \ingroup msg_easier_life
30 * \brief A name directory service...
32 * Finds a m_host_t using its name.
33 * \param name the name of an host.
34 * \return the corresponding host
36 m_host_t MSG_get_host_by_name(const char *name)
38 smx_host_t simix_h = NULL;
39 simix_h = SIMIX_req_host_get_by_name(name);
44 return (m_host_t) SIMIX_req_host_get_data(simix_h);
47 /** \ingroup msg_easier_life
48 * \brief A platform constructor.
50 * Creates a new platform, including hosts, links and the
52 * \param file a filename of a xml description of a platform. This file
55 * \include simgrid.dtd
57 * Here is a small example of such a platform
59 * \include small_platform.xml
61 * Have a look in the directory examples/msg/ to have a big example.
63 void MSG_create_environment(const char *file)
65 xbt_lib_cursor_t cursor;
69 SIMIX_create_environment(file);
71 /* Initialize MSG hosts */
72 xbt_lib_foreach(host_lib, cursor, name, data) {
73 if(data[SIMIX_HOST_LEVEL])
74 __MSG_host_create((smx_host_t)data[SIMIX_HOST_LEVEL], NULL);
79 * \brief A platform constructor bypassing the parser.
81 * load lua script file to set up new platform, including hosts,links
82 * and the routing table
85 void MSG_load_platform_script(const char *script_file)
88 lua_State *L = lua_open();
91 if (luaL_loadfile(L, script_file) || lua_pcall(L, 0, 0, 0)) {
92 printf("error: %s\n", lua_tostring(L, -1));
97 ("Lua is not available!! to call MSG_load_platform_script, lua should be available...");