Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace] creation of a type also defines its own color, when appropriate
[simgrid.git] / src / instr / instr_paje.c
index e1a22ee..e6edfda 100644 (file)
@@ -13,14 +13,14 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_paje, instr, "Paje tracing event system (
 static type_t rootType = NULL;              /* the root type */
 static container_t rootContainer = NULL;    /* the root container */
 static xbt_dict_t allContainers = NULL;     /* all created containers indexed by name */
-xbt_dynar_t allLinkTypes = NULL;     /* all link types defined */
-xbt_dynar_t allHostTypes = NULL;     /* all host types defined */
+xbt_dict_t trivaNodeTypes = NULL;     /* all link types defined */
+xbt_dict_t trivaEdgeTypes = NULL;     /* all host types defined */
 
 void instr_paje_init (container_t root)
 {
   allContainers = xbt_dict_new ();
-  allLinkTypes = xbt_dynar_new (sizeof(s_type_t), NULL);
-  allHostTypes = xbt_dynar_new (sizeof(s_type_t), NULL);
+  trivaNodeTypes = xbt_dict_new ();
+  trivaEdgeTypes = xbt_dict_new ();
   rootContainer = root;
 }
 
@@ -30,13 +30,14 @@ static long long int newTypeId ()
   return counter++;
 }
 
-static type_t newType (const char *typename, const char *key, e_entity_types kind, type_t father)
+static type_t newType (const char *typename, const char *key, const char *color, e_entity_types kind, type_t father)
 {
   type_t ret = xbt_new0(s_type_t, 1);
   ret->name = xbt_strdup (typename);
   ret->father = father;
   ret->kind = kind;
   ret->children = xbt_dict_new ();
+  ret->color = xbt_strdup (color);
 
   long long int id = newTypeId();
   char str_id[INSTR_DEFAULT_STR_SIZE];
@@ -58,15 +59,15 @@ type_t getContainerType (const char *typename, type_t father)
 {
   type_t ret;
   if (father == NULL){
-    ret = newType (typename, typename, TYPE_CONTAINER, father);
-    if (father) pajeDefineContainerType(ret->id, ret->father->id, ret->name);
+    ret = newType (typename, typename, NULL, TYPE_CONTAINER, father);
+    if (father) new_pajeDefineContainerType (ret);
     rootType = ret;
   }else{
     //check if my father type already has my typename
     ret = (type_t)xbt_dict_get_or_null (father->children, typename);
     if (ret == NULL){
-      ret = newType (typename, typename, TYPE_CONTAINER, father);
-      pajeDefineContainerType(ret->id, ret->father->id, ret->name);
+      ret = newType (typename, typename, NULL, TYPE_CONTAINER, father);
+      new_pajeDefineContainerType (ret);
     }
   }
   return ret;
@@ -76,13 +77,14 @@ type_t getEventType (const char *typename, const char *color, type_t father)
 {
   type_t ret = xbt_dict_get_or_null (father->children, typename);
   if (ret == NULL){
-    ret = newType (typename, typename, TYPE_EVENT, father);
-    //INFO4("EventType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id);
-    if (color){
-      pajeDefineEventTypeWithColor (ret->id, ret->father->id, ret->name, color);
+    char white[INSTR_DEFAULT_STR_SIZE] = "1 1 1";
+    if (!color){
+      ret = newType (typename, typename, white, TYPE_EVENT, father);
     }else{
-      pajeDefineEventType(ret->id, ret->father->id, ret->name);
+      ret = newType (typename, typename, color, TYPE_EVENT, father);
     }
+    //INFO4("EventType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id);
+    new_pajeDefineEventType(ret);
   }
   return ret;
 }
@@ -91,13 +93,14 @@ type_t getVariableType (const char *typename, const char *color, type_t father)
 {
   type_t ret = xbt_dict_get_or_null (father->children, typename);
   if (ret == NULL){
-    ret = newType (typename, typename, TYPE_VARIABLE, father);
-    //INFO4("VariableType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id);
-    if (color){
-      pajeDefineVariableTypeWithColor(ret->id, ret->father->id, ret->name, color);
+    char white[INSTR_DEFAULT_STR_SIZE] = "1 1 1";
+    if (!color){
+      ret = newType (typename, typename, white, TYPE_VARIABLE, father);
     }else{
-      pajeDefineVariableType(ret->id, ret->father->id, ret->name);
+      ret = newType (typename, typename, color, TYPE_VARIABLE, father);
     }
+    //INFO4("VariableType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id);
+    new_pajeDefineVariableType (ret);
   }
   return ret;
 }
@@ -115,14 +118,13 @@ char *getVariableTypeIdByName (const char *name, type_t father)
 
 type_t getLinkType (const char *typename, type_t father, type_t source, type_t dest)
 {
-  //FIXME should check using source and dest here and not by the typename (g5k example)
   char key[INSTR_DEFAULT_STR_SIZE];
   snprintf (key, INSTR_DEFAULT_STR_SIZE, "%s-%s-%s", typename, source->id, dest->id);
   type_t ret = xbt_dict_get_or_null (father->children, key);
   if (ret == NULL){
-    ret = newType (typename, key, TYPE_LINK, father);
+    ret = newType (typename, key, NULL, TYPE_LINK, father);
     //INFO8("LinkType %s(%s), child of %s(%s)  %s(%s)->%s(%s)", ret->name, ret->id, father->name, father->id, source->name, source->id, dest->name, dest->id);
-    pajeDefineLinkType(ret->id, ret->father->id, source->id, dest->id, ret->name);
+    new_pajeDefineLinkType(ret, source, dest);
   }
   return ret;
 }
@@ -131,9 +133,9 @@ type_t getStateType (const char *typename, type_t father)
 {
   type_t ret = xbt_dict_get_or_null (father->children, typename);
   if (ret == NULL){
-    ret = newType (typename, typename, TYPE_STATE, father);
+    ret = newType (typename, typename, NULL, TYPE_STATE, father);
     //INFO4("StateType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id);
-    pajeDefineStateType(ret->id, ret->father->id, ret->name);
+    new_pajeDefineStateType(ret);
   }
   return ret;
 }
@@ -187,22 +189,15 @@ container_t newContainer (const char *name, e_container_types kind, container_t
   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);
+    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 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);
+    //register NODE types for triva configuration
+    xbt_dict_set (trivaNodeTypes, new->type->name, xbt_strdup("1"), xbt_free);
   }
   return new;
 }
@@ -268,7 +263,7 @@ void destroyContainer (container_t container)
   }
 
   //trace my destruction
-  pajeDestroyContainer(SIMIX_get_clock(), container->type->id, container->id);
+  new_pajeDestroyContainer(container);
 
   //free
   xbt_free (container->name);