Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
moving include/surf to src/include/surf (continued)
[simgrid.git] / src / msg / environment.c
1 /*      $Id$     */
2
3 /* Copyright (c) 2002,2003,2004 Arnaud Legrand. All rights reserved.        */
4
5 /* This program is free software; you can redistribute it and/or modify it
6  * under the terms of the license (GNU LGPL) which comes with this package. */
7
8 #include"private.h"
9 #include"xbt/sysdep.h"
10 #include "xbt/error.h"
11 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(environment, msg,
12                                 "Logging specific to MSG (environment)");
13
14 /********************************* MSG **************************************/
15
16 /** \ingroup msg_easier_life
17  * \brief A name directory service...
18  *
19  * Finds a m_host_t using its name.
20  * \param name the name of an host.
21  * \return the corresponding host
22  */
23 m_host_t MSG_get_host_by_name(const char *name)
24 {
25   xbt_fifo_item_t i = NULL;
26   m_host_t host = NULL;
27
28   xbt_assert0(((msg_global != NULL)
29           && (msg_global->host != NULL)), "Environment not set yet");
30
31   xbt_fifo_foreach(msg_global->host,i,host,m_host_t) {
32     if(strcmp(host->name, name) == 0) return host;
33   }
34   return NULL;
35 }
36
37 /** \ingroup msg_easier_life
38  * \brief A platform constructor.
39  *
40  * Creates a new platform, including hosts, links and the
41  * routing_table. 
42  * \param file a filename of a xml description of a platform. This file 
43  * follows this DTD :
44  *
45  *     \include surfxml.dtd
46  *
47  * Here is a small example of such a platform 
48  *
49  *     \include small_platform.xml
50  *
51  * Have a look in the directory examples/msg/ to have a big example.
52  */
53 void MSG_create_environment(const char *file) {
54   xbt_dict_cursor_t cursor = NULL;
55   char *name = NULL;
56   void *workstation = NULL;
57
58   surf_workstation_resource_init_CLM03(file);
59 /*   surf_workstation_resource_init_KCCFLN05(file); */
60
61   xbt_dict_foreach(workstation_set, cursor, name, workstation) {
62     __MSG_host_create(name, workstation, NULL);
63   }
64
65   return;
66 }
67