1 /* Copyright (c) 2004-2017. The SimGrid Team. All rights reserved. */
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. */
6 #include "simgrid/s4u/Engine.hpp"
7 #include "simgrid/s4u/NetZone.hpp"
8 #include "src/msg/msg_private.h"
18 /********************************* MSG **************************************/
20 /** \ingroup msg_simulation
21 * \brief A platform constructor.
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 :
26 * \include simgrid.dtd
28 * Here is a small example of such a platform
30 * \include small_platform.xml
32 * Have a look in the directory examples/msg/ to have a big example.
34 void MSG_create_environment(const char *file)
36 SIMIX_create_environment(file);
39 void MSG_post_create_environment() {
40 xbt_lib_cursor_t cursor;
44 /* Initialize MSG storages */
45 xbt_lib_foreach(storage_lib, cursor, name, data) {
46 if(data[SIMIX_STORAGE_LEVEL])
47 __MSG_storage_create(xbt_dict_cursor_get_elm(cursor));
51 msg_netzone_t MSG_environment_get_routing_root()
53 return simgrid::s4u::Engine::instance()->netRoot();
56 const char* MSG_environment_as_get_name(msg_netzone_t netzone)
58 return netzone->name();
61 msg_netzone_t MSG_environment_as_get_by_name(const char* name)
63 return simgrid::s4u::Engine::instance()->netzoneByNameOrNull(name);
66 xbt_dict_t MSG_environment_as_get_routing_sons(msg_netzone_t netzone)
68 xbt_dict_t res = xbt_dict_new_homogeneous(nullptr);
69 for (auto elem : *netzone->children()) {
70 xbt_dict_set(res, elem->name(), static_cast<void*>(elem), nullptr);
75 const char* MSG_environment_as_get_property_value(msg_netzone_t netzone, const char* name)
77 return netzone->property(name);
80 void MSG_environment_as_set_property_value(msg_netzone_t netzone, const char* name, char* value)
82 netzone->setProperty(name, value);
85 xbt_dynar_t MSG_environment_as_get_hosts(msg_netzone_t netzone)
87 xbt_dynar_t res = xbt_dynar_new(sizeof(sg_host_t), nullptr);
89 for (auto host : *netzone->hosts()) {
90 xbt_dynar_push(res, &host);