Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Completely rework the properties of netzones
[simgrid.git] / src / msg / msg_environment.cpp
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 #include "simgrid/s4u/NetZone.hpp"
12 #include "simgrid/s4u/engine.hpp"
13
14 #if HAVE_LUA
15 #include <lua.h>
16 #include <lauxlib.h>
17 #include <lualib.h>
18 #endif
19
20 /********************************* MSG **************************************/
21
22 /** \ingroup msg_simulation
23  * \brief A platform constructor.
24  *
25  * Creates a new platform, including hosts, links and the routing_table.
26  * \param file a filename of a xml description of a platform. This file follows this DTD :
27  *
28  *     \include simgrid.dtd
29  *
30  * Here is a small example of such a platform 
31  *
32  *     \include small_platform.xml
33  *
34  * Have a look in the directory examples/msg/ to have a big example.
35  */
36 void MSG_create_environment(const char *file)
37 {
38   SIMIX_create_environment(file);
39 }
40
41 void MSG_post_create_environment() {
42   xbt_lib_cursor_t cursor;
43   void **data;
44   char *name;
45
46   /* Initialize MSG storages */
47   xbt_lib_foreach(storage_lib, cursor, name, data) {
48     if(data[SIMIX_STORAGE_LEVEL])
49       __MSG_storage_create(xbt_dict_cursor_get_elm(cursor));
50   }
51 }
52
53 msg_netzone_t MSG_environment_get_routing_root()
54 {
55   return simgrid::s4u::Engine::instance()->netRoot();
56 }
57
58 const char* MSG_environment_as_get_name(msg_netzone_t netzone)
59 {
60   return netzone->name();
61 }
62
63 msg_netzone_t MSG_environment_as_get_by_name(const char* name)
64 {
65   return simgrid::s4u::Engine::instance()->netzoneByNameOrNull(name);
66 }
67
68 xbt_dict_t MSG_environment_as_get_routing_sons(msg_netzone_t netzone)
69 {
70   return netzone->children();
71 }
72
73 const char* MSG_environment_as_get_property_value(msg_netzone_t netzone, const char* name)
74 {
75   return netzone->property(name);
76 }
77
78 void MSG_environment_as_set_property_value(msg_netzone_t netzone, const char* name, char* value)
79 {
80   netzone->setProperty(name, value);
81 }
82
83 xbt_dynar_t MSG_environment_as_get_hosts(msg_netzone_t netzone)
84 {
85   return netzone->hosts();
86 }