AsImpl::AsImpl(As* father, const char* name) : As(father, name)
{
+ xbt_assert(nullptr == xbt_lib_get_or_null(as_router_lib, name, ROUTING_ASR_LEVEL),
+ "Refusing to create a second AS called \"%s\".", name);
+
netcard_ = new simgrid::kernel::routing::NetCardImpl(name, simgrid::kernel::routing::NetCard::Type::As,
static_cast<AsImpl*>(father));
xbt_lib_set(as_router_lib, name, ROUTING_ASR_LEVEL, (void*)netcard_);
Host::Host(const char* name)
: name_(name)
{
+ xbt_dict_set(host_list, name, this, nullptr);
}
Host::~Host() {
Host* Host::by_name_or_create(const char* name)
{
Host* host = by_name_or_null(name);
- if (host == nullptr) {
+ if (host == nullptr)
host = new Host(name);
- xbt_dict_set(host_list, name, host, nullptr);
- }
+
return host;
}
surf_config_models_setup();
}
- xbt_assert(nullptr == xbt_lib_get_or_null(as_router_lib, AS->id, ROUTING_ASR_LEVEL),
- "Refusing to create a second AS called \"%s\".", AS->id);
-
_sg_cfg_init_status = 2; /* HACK: direct access to the global controlling the level of configuration to prevent
* any further config now that we created some real content */
if (current_routing == nullptr && routing_platf->root_ == nullptr) { /* it is the first one */
routing_platf->root_ = new_as;
- } else if (current_routing != nullptr && routing_platf->root_ != nullptr) {
- xbt_assert(!xbt_dict_get_or_null(current_routing->children(), AS->id), "The AS '%s' already exists", AS->id);
+ } else if (current_routing != nullptr && routing_platf->root_ != nullptr) {
/* set the father behavior */
if (current_routing->hierarchy_ == simgrid::kernel::routing::AsImpl::RoutingMode::unset)
current_routing->hierarchy_ = simgrid::kernel::routing::AsImpl::RoutingMode::recursive;
/* add to the sons dictionary */
xbt_dict_set(current_routing->children(), AS->id, (void *) new_as, nullptr);
+
} else {
THROWF(arg_error, 0, "All defined components must belong to a AS");
}