Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
please sonar
[simgrid.git] / src / msg / msg_environment.cpp
1 /* Copyright (c) 2004-2016. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include "simgrid/s4u/NetZone.hpp"
7 #include "simgrid/s4u/engine.hpp"
8 #include "src/msg/msg_private.h"
9
10 #if HAVE_LUA
11 #include <lua.h>
12 #include <lauxlib.h>
13 #include <lualib.h>
14 #endif
15
16 /********************************* MSG **************************************/
17
18 /** \ingroup msg_simulation
19  * \brief A platform constructor.
20  *
21  * Creates a new platform, including hosts, links and the routing_table.
22  * \param file a filename of a xml description of a platform. This file follows this DTD :
23  *
24  *     \include simgrid.dtd
25  *
26  * Here is a small example of such a platform 
27  *
28  *     \include small_platform.xml
29  *
30  * Have a look in the directory examples/msg/ to have a big example.
31  */
32 void MSG_create_environment(const char *file)
33 {
34   SIMIX_create_environment(file);
35 }
36
37 void MSG_post_create_environment() {
38   xbt_lib_cursor_t cursor;
39   void **data;
40   char *name;
41
42   /* Initialize MSG storages */
43   xbt_lib_foreach(storage_lib, cursor, name, data) {
44     if(data[SIMIX_STORAGE_LEVEL])
45       __MSG_storage_create(xbt_dict_cursor_get_elm(cursor));
46   }
47 }
48
49 msg_netzone_t MSG_environment_get_routing_root()
50 {
51   return simgrid::s4u::Engine::instance()->netRoot();
52 }
53
54 const char* MSG_environment_as_get_name(msg_netzone_t netzone)
55 {
56   return netzone->name();
57 }
58
59 msg_netzone_t MSG_environment_as_get_by_name(const char* name)
60 {
61   return simgrid::s4u::Engine::instance()->netzoneByNameOrNull(name);
62 }
63
64 xbt_dict_t MSG_environment_as_get_routing_sons(msg_netzone_t netzone)
65 {
66   return netzone->children();
67 }
68
69 const char* MSG_environment_as_get_property_value(msg_netzone_t netzone, const char* name)
70 {
71   return netzone->property(name);
72 }
73
74 void MSG_environment_as_set_property_value(msg_netzone_t netzone, const char* name, char* value)
75 {
76   netzone->setProperty(name, value);
77 }
78
79 xbt_dynar_t MSG_environment_as_get_hosts(msg_netzone_t netzone)
80 {
81   return netzone->hosts();
82 }