Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
1c3ea9beb5e933c1d23e94565866320d4ab65b40
[simgrid.git] / src / msg / msg_environment.cpp
1 /* Copyright (c) 2004-2017. 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/Engine.hpp"
7 #include "simgrid/s4u/NetZone.hpp"
8 #include "src/msg/msg_private.h"
9
10 #if SIMGRID_HAVE_LUA
11 #include <lua.h>
12 #include <lauxlib.h>
13 #include <lualib.h>
14 #endif
15
16 SG_BEGIN_DECL()
17
18 /********************************* MSG **************************************/
19
20 /** \ingroup msg_simulation
21  * \brief A platform constructor.
22  *
23  * Creates a new platform, including hosts, links and the routing_table.
24  * \param file a filename of a xml description of a platform. This file follows this DTD :
25  *
26  *     \include simgrid.dtd
27  *
28  * Here is a small example of such a platform 
29  *
30  *     \include small_platform.xml
31  *
32  * Have a look in the directory examples/msg/ to have a big example.
33  */
34 void MSG_create_environment(const char *file)
35 {
36   SIMIX_create_environment(file);
37 }
38
39 msg_netzone_t MSG_zone_get_root()
40 {
41   return simgrid::s4u::Engine::instance()->netRoot();
42 }
43
44 const char* MSG_zone_get_name(msg_netzone_t netzone)
45 {
46   return netzone->name();
47 }
48
49 msg_netzone_t MSG_zone_get_by_name(const char* name)
50 {
51   return simgrid::s4u::Engine::instance()->netzoneByNameOrNull(name);
52 }
53
54 void MSG_zone_get_sons(msg_netzone_t netzone, xbt_dict_t whereto)
55 {
56   for (auto elem : *netzone->children()) {
57     xbt_dict_set(whereto, elem->name(), static_cast<void*>(elem), nullptr);
58   }
59 }
60
61 const char* MSG_zone_get_property_value(msg_netzone_t netzone, const char* name)
62 {
63   return netzone->property(name);
64 }
65
66 void MSG_zone_set_property_value(msg_netzone_t netzone, const char* name, char* value)
67 {
68   netzone->setProperty(name, value);
69 }
70
71 void MSG_zone_get_hosts(msg_netzone_t netzone, xbt_dynar_t whereto)
72 {
73   /* converts vector to dynar */
74   std::vector<simgrid::s4u::Host*> hosts;
75   netzone->hosts(&hosts);
76   for (auto host : hosts)
77     xbt_dynar_push(whereto, &host);
78 }
79
80 SG_END_DECL()