Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace] recursive search for a type in the type hierarchy
authorschnorr <schnorr@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 13 Dec 2010 16:45:14 +0000 (16:45 +0000)
committerschnorr <schnorr@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 13 Dec 2010 16:45:14 +0000 (16:45 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9203 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/instr/instr_private.h
src/instr/instr_routing.c

index 55e647c..2ab9aea 100644 (file)
@@ -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);
 /* 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);
 void destroyContainer (container_t container);
 void instr_routing_define_callbacks (void);
 int instr_link_is_traced (const char *name);
index b866969..42dfda5 100644 (file)
@@ -236,6 +236,25 @@ container_t getContainer (const char *name)
   return recursiveGetContainer(name, rootContainer);
 }
 
   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
 void destroyContainer (container_t container)
 {
   //remove me from my father