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 msg_netzone_t MSG_zone_get_root()
41 return simgrid::s4u::Engine::instance()->netRoot();
44 const char* MSG_zone_get_name(msg_netzone_t netzone)
46 return netzone->name();
49 msg_netzone_t MSG_zone_get_by_name(const char* name)
51 return simgrid::s4u::Engine::instance()->netzoneByNameOrNull(name);
54 void MSG_zone_get_sons(msg_netzone_t netzone, xbt_dict_t whereto)
56 for (auto elem : *netzone->children()) {
57 xbt_dict_set(whereto, elem->name(), static_cast<void*>(elem), nullptr);
61 const char* MSG_zone_get_property_value(msg_netzone_t netzone, const char* name)
63 return netzone->property(name);
66 void MSG_zone_set_property_value(msg_netzone_t netzone, const char* name, char* value)
68 netzone->setProperty(name, value);
71 void MSG_zone_get_hosts(msg_netzone_t netzone, xbt_dynar_t whereto)
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);