/** @brief Retrieve the engine singleton */
static s4u::Engine *instance();
- /** @brief Retrieve the root AS, containing all others */
+ /** @brief Retrieve the root netzone, containing all others */
simgrid::s4u::NetZone* netRoot();
- /** @brief Retrieve the AS of the given name (or nullptr if not found) */
+ /** @brief Retrieve the netzone of the given name (or nullptr if not found) */
simgrid::s4u::NetZone* netzoneByNameOrNull(const char* name);
+ /** @brief Retrieve the netcard of the given name (or nullptr if not found) */
+ simgrid::kernel::routing::NetCard* netcardByNameOrNull(const char* name);
+
template<class F>
void registerFunction(const char* name)
{
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#include <simgrid/s4u/host.hpp>
+#include "simgrid/s4u/engine.hpp"
+#include "simgrid/s4u/host.hpp"
#include <xbt/dict.h>
#include <xbt/lib.h>
xbt_assert(newContainer->netcard, "Element '%s' not found",name);
break;
case INSTR_ROUTER:
- newContainer->netcard = static_cast<sg_netcard_t>(xbt_dict_get_or_null(netcards_dict, name));
+ newContainer->netcard = simgrid::s4u::Engine::instance()->netcardByNameOrNull(name);
xbt_assert(newContainer->netcard, "Element '%s' not found",name);
break;
case INSTR_AS:
- newContainer->netcard = static_cast<sg_netcard_t>(xbt_dict_get_or_null(netcards_dict, name));
+ newContainer->netcard = simgrid::s4u::Engine::instance()->netcardByNameOrNull(name);
xbt_assert(newContainer->netcard, "Element '%s' not found",name);
break;
default:
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "src/kernel/routing/NetCard.hpp"
+#include "simgrid/s4u/engine.hpp"
+#include "simgrid/s4u/host.hpp"
#include "surf/surf_routing.h"
-#include <simgrid/s4u/host.hpp>
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route, surf, "Routing part of surf");
simgrid::kernel::routing::NetCard* sg_netcard_by_name_or_null(const char* name)
{
sg_host_t host = sg_host_by_name(name);
- return (host != nullptr) ? host->pimpl_netcard
- : static_cast<simgrid::kernel::routing::NetCard*>(xbt_dict_get_or_null(netcards_dict, name));
+ return (host != nullptr) ? host->pimpl_netcard : simgrid::s4u::Engine::instance()->netcardByNameOrNull(name);
}
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#include "xbt/log.h"
-
+#include "src/kernel/routing/NetZoneImpl.hpp"
+#include "simgrid/s4u/engine.hpp"
#include "simgrid/s4u/host.hpp"
#include "src/kernel/routing/NetCard.hpp"
-#include "src/kernel/routing/NetZoneImpl.hpp"
#include "src/surf/cpu_interface.hpp"
#include "src/surf/network_interface.hpp"
+#include "xbt/log.h"
+
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_route);
namespace simgrid {
NetZoneImpl::NetZoneImpl(NetZone* father, const char* name) : NetZone(father, name)
{
- xbt_assert(nullptr == xbt_dict_get_or_null(netcards_dict, name), "Refusing to create a second NetZone called '%s'.",
- name);
+ xbt_assert(nullptr == simgrid::s4u::Engine::instance()->netcardByNameOrNull(name),
+ "Refusing to create a second NetZone called '%s'.", name);
netcard_ = new NetCard(name, NetCard::Type::NetZone, static_cast<NetZoneImpl*>(father));
xbt_dict_set(netcards_dict, name, static_cast<void*>(netcard_), nullptr);
#include <boost/algorithm/string.hpp>
-#include <simgrid/s4u/host.hpp>
+#include "simgrid/s4u/engine.hpp"
+#include "simgrid/s4u/host.hpp"
#include "src/kernel/routing/NetCard.hpp"
#include "src/kernel/routing/VivaldiZone.hpp"
if (src->isNetZone()) {
char* srcName = bprintf("router_%s", src->cname());
char* dstName = bprintf("router_%s", dst->cname());
- route->gw_src = (sg_netcard_t)xbt_dict_get_or_null(netcards_dict, srcName);
- route->gw_dst = (sg_netcard_t)xbt_dict_get_or_null(netcards_dict, dstName);
+ route->gw_src = simgrid::s4u::Engine::instance()->netcardByNameOrNull(srcName);
+ route->gw_dst = simgrid::s4u::Engine::instance()->netcardByNameOrNull(dstName);
xbt_free(srcName);
xbt_free(dstName);
}
return netzoneByNameRecursive(netRoot(), name);
}
+/** @brief Retrieve the netcard of the given name (or nullptr if not found) */
+simgrid::kernel::routing::NetCard* Engine::netcardByNameOrNull(const char* name)
+{
+ return static_cast<simgrid::kernel::routing::NetCard*>(xbt_dict_get_or_null(netcards_dict, name));
+}
}
}
if (current_routing->hierarchy_ == simgrid::kernel::routing::NetZoneImpl::RoutingMode::unset)
current_routing->hierarchy_ = simgrid::kernel::routing::NetZoneImpl::RoutingMode::base;
- xbt_assert(nullptr == xbt_dict_get_or_null(netcards_dict, router->id),
+ xbt_assert(nullptr == simgrid::s4u::Engine::instance()->netcardByNameOrNull(router->id),
"Refusing to create a router named '%s': this name already describes a node.", router->id);
simgrid::kernel::routing::NetCard* netcard =
if (!router.id || !strcmp(router.id, ""))
router.id = newid = bprintf("%s%s_router%s", cluster->prefix, cluster->id, cluster->suffix);
sg_platf_new_router(&router);
- current_as->router_ = (simgrid::kernel::routing::NetCard*)xbt_dict_get_or_null(netcards_dict, router.id);
+ current_as->router_ = simgrid::s4u::Engine::instance()->netcardByNameOrNull(router.id);
free(newid);
//Make the backbone
! output sort
$ $SG_TEST_EXENV ${bindir:=.}/maxmin_bench medium 5 test
> [0.000000]: [surf_kernel/DEBUG] Add SURF levels
-> [0.000000]: [surf_kernel/DEBUG] Add routing levels
> [0.000000]: [surf_kernel/DEBUG] Create all Libs
> [0.000000]: [surf_maxmin/DEBUG] Setting selective_update_active flag to 1
> [0.000000]: [surf_maxmin/DEBUG] Active constraints : 100
! output sort
$ $SG_TEST_EXENV ${bindir:=.}/maxmin_bench small 10 test
> [0.000000]: [surf_kernel/DEBUG] Add SURF levels
-> [0.000000]: [surf_kernel/DEBUG] Add routing levels
> [0.000000]: [surf_kernel/DEBUG] Create all Libs
> [0.000000]: [surf_maxmin/DEBUG] Setting selective_update_active flag to 1
> [0.000000]: [surf_maxmin/DEBUG] Active constraints : 10