+ long long int counter = newContainedId();
+ char id_str[INSTR_DEFAULT_STR_SIZE];
+ snprintf (id_str, INSTR_DEFAULT_STR_SIZE, "%lld", counter);
+
+ container_t new = xbt_new0(s_container_t, 1);
+ new->name = xbt_strdup (name); // name of the container
+ new->id = xbt_strdup (id_str); // id (or alias) of the container
+ new->father = father;
+ // level depends on level of father
+ if (new->father){
+ new->level = new->father->level+1;
+ }else{
+ new->level = 0;
+ }
+ // type definition (method depends on kind of this new container)
+ new->kind = kind;
+ if (new->kind == INSTR_AS){
+ //if this container is of an AS, its type name depends on its level
+ char as_typename[INSTR_DEFAULT_STR_SIZE];
+ snprintf (as_typename, INSTR_DEFAULT_STR_SIZE, "L%d", new->level);
+ if (new->father){
+ new->type = getContainerType (as_typename, new->father->type);
+ }else{
+ new->type = getContainerType ("0", NULL);
+ }
+ }else{
+ //otherwise, the name is its kind
+ switch (new->kind){
+ case INSTR_HOST: new->type = getContainerType ("HOST", new->father->type); break;
+ case INSTR_LINK: new->type = getContainerType ("LINK", new->father->type); break;
+ case INSTR_ROUTER: new->type = getContainerType ("ROUTER", new->father->type); break;
+ case INSTR_SMPI: new->type = getContainerType ("MPI", new->father->type); break;
+ case INSTR_MSG_PROCESS: new->type = getContainerType ("MSG_PROCESS", new->father->type); break;
+ case INSTR_MSG_TASK: new->type = getContainerType ("MSG_TASK", new->father->type); break;
+ default: xbt_die ("Congratulations, you have found a bug on newContainer function of instr_routing.c"); break;
+ }
+ }
+ new->children = xbt_dict_new();
+ if (new->father){
+ xbt_dict_set(new->father->children, new->name, new, NULL);
+ pajeCreateContainer (SIMIX_get_clock(), new->id, new->type->id, new->father->id, new->name);
+ }
+
+ //register hosts, routers, links containers
+ if (new->kind == INSTR_HOST || new->kind == INSTR_LINK || new->kind == INSTR_ROUTER) {
+ xbt_dict_set (allContainers, new->name, new, NULL);
+ }
+
+ //register the host container types
+ if (new->kind == INSTR_HOST){
+ xbt_dynar_push_as (allHostTypes, type_t, new->type);
+ }
+
+ //register the link container types
+ if (new->kind == INSTR_LINK){
+ xbt_dynar_push_as(allLinkTypes, type_t, new->type);
+ }
+ return new;