Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Revert "msg_private.h is a C++ header so add pp"
[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/As.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_as_t MSG_environment_get_routing_root() {
54   return simgrid::s4u::Engine::instance()->rootAs();
55 }
56
57 const char *MSG_environment_as_get_name(msg_as_t as) {
58   return as->name();
59 }
60
61 msg_as_t MSG_environment_as_get_by_name(const char * name) {
62   return simgrid::s4u::Engine::instance()->asByNameOrNull(name);
63 }
64
65 xbt_dict_t MSG_environment_as_get_routing_sons(msg_as_t as) {
66   return as->children();
67 }
68
69 const char *MSG_environment_as_get_property_value(msg_as_t as, const char *name)
70 {
71   xbt_dict_t dict = static_cast<xbt_dict_t> (xbt_lib_get_or_null(as_router_lib, MSG_environment_as_get_name(as),
72                                                                  ROUTING_PROP_ASR_LEVEL));
73   if (dict==nullptr)
74     return nullptr;
75   return static_cast<const char*>(xbt_dict_get_or_null(dict, name));
76 }
77
78 xbt_dynar_t MSG_environment_as_get_hosts(msg_as_t as) {
79   return as->hosts();
80 }