From: schnorr Date: Mon, 13 Dec 2010 16:45:14 +0000 (+0000) Subject: [trace] recursive search for a type in the type hierarchy X-Git-Tag: v3.6_beta2~720 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/73fc9f6b6089d7cb8a76dcf5a015e105943c1df5 [trace] recursive search for a type in the type hierarchy git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9203 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/instr/instr_private.h b/src/instr/instr_private.h index 55e647cf4b..2ab9aeac8a 100644 --- a/src/instr/instr_private.h +++ b/src/instr/instr_private.h @@ -218,6 +218,7 @@ void TRACE_sd_task_destroy(SD_task_t task); /* instr_routing.c */ container_t newContainer (const char *name, e_container_types kind, container_t father); container_t getContainer (const char *name); +type_t getType (const char *name); void destroyContainer (container_t container); void instr_routing_define_callbacks (void); int instr_link_is_traced (const char *name); diff --git a/src/instr/instr_routing.c b/src/instr/instr_routing.c index b866969aa3..42dfda5caa 100644 --- a/src/instr/instr_routing.c +++ b/src/instr/instr_routing.c @@ -236,6 +236,25 @@ container_t getContainer (const char *name) return recursiveGetContainer(name, rootContainer); } +static type_t recursiveGetType (const char *name, type_t root) +{ + if (strcmp (root->name, name) == 0) return root; + + xbt_dict_cursor_t cursor = NULL; + type_t child; + char *child_name; + xbt_dict_foreach(root->children, cursor, child_name, child) { + type_t ret = recursiveGetType(name, child); + if (ret) return ret; + } + return NULL; +} + +type_t getType (const char *name) +{ + return recursiveGetType (name, rootType); +} + void destroyContainer (container_t container) { //remove me from my father