+ static long long int container_id = 0;
+ char id_str[INSTR_DEFAULT_STR_SIZE];
+ snprintf (id_str, INSTR_DEFAULT_STR_SIZE, "%lld", container_id++);
+
+ 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;
+ XBT_DEBUG("new container %s, child of %s", name, father->name);
+ }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);
+ new_pajeCreateContainer (new);
+ }
+
+ //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 NODE types for triva configuration
+ xbt_dict_set (trivaNodeTypes, new->type->name, xbt_strdup("1"), xbt_free);
+ }
+ return new;
+}
+
+static container_t recursiveGetContainer (const char *name, container_t root)
+{
+ if (name == NULL || root == NULL) return NULL;
+ if (strcmp (root->name, name) == 0) return root;
+
+ xbt_dict_cursor_t cursor = NULL;
+ container_t child;
+ char *child_name;
+ xbt_dict_foreach(root->children, cursor, child_name, child) {
+ container_t ret = recursiveGetContainer(name, child);
+ if (ret) return ret;
+ }
+ return NULL;