Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[travis] detect linux as we should
[simgrid.git] / src / msg / msg_environment.c
1 /* Copyright (c) 2004-2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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. */
6
7 #include "msg_private.h"
8 #include "xbt/sysdep.h"
9 #include "xbt/log.h"
10
11 #ifdef HAVE_LUA
12 #include <lua.h>
13 #include <lauxlib.h>
14 #include <lualib.h>
15 #endif
16
17 /********************************* MSG **************************************/
18
19 /** \ingroup msg_simulation
20  * \brief A platform constructor.
21  *
22  * Creates a new platform, including hosts, links and the
23  * routing_table. 
24  * \param file a filename of a xml description of a platform. This file 
25  * follows this DTD :
26  *
27  *     \include simgrid.dtd
28  *
29  * Here is a small example of such a platform 
30  *
31  *     \include small_platform.xml
32  *
33  * Have a look in the directory examples/msg/ to have a big example.
34  */
35 void MSG_create_environment(const char *file)
36 {
37   SIMIX_create_environment(file);
38 }
39
40 void MSG_post_create_environment(void) {
41   xbt_lib_cursor_t cursor;
42   void **data;
43   char *name;
44
45   /* Initialize MSG hosts */
46   xbt_lib_foreach(host_lib, cursor, name, data) {
47         __MSG_host_create(xbt_dict_cursor_get_elm(cursor));
48   }
49
50   /* Initialize MSG storages */
51   xbt_lib_foreach(storage_lib, cursor, name, data) {
52     if(data[SIMIX_STORAGE_LEVEL])
53       __MSG_storage_create(xbt_dict_cursor_get_elm(cursor));
54   }
55
56 }
57
58 msg_as_t MSG_environment_get_routing_root() {
59   return surf_AS_get_routing_root();
60 }
61
62 const char *MSG_environment_as_get_name(msg_as_t as) {
63   return surf_AS_get_name(as);
64 }
65
66 msg_as_t MSG_environment_as_get_by_name(const char * name) {
67   return surf_AS_get_by_name(name);
68 }
69
70 xbt_dict_t MSG_environment_as_get_routing_sons(msg_as_t as) {
71   xbt_dict_t res = surf_AS_get_routing_sons(as);
72   return res;
73 }
74
75 const char *MSG_environment_as_get_property_value(msg_as_t as, const char *name)
76 {
77   xbt_dict_t dict = xbt_lib_get_or_null(as_router_lib, MSG_environment_as_get_name(as), ROUTING_PROP_ASR_LEVEL);
78   if (dict==NULL)
79     return NULL;
80   return xbt_dict_get_or_null(dict, name);
81 }
82
83 const char *MSG_environment_as_get_model(msg_as_t as) {
84   return surf_AS_get_model(as);
85 }
86
87 xbt_dynar_t MSG_environment_as_get_hosts(msg_as_t as) {
88   return surf_AS_get_hosts(as);
89 }