Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
give s_val PJ_value as a constructor
authorTakishipp <toufik.boubehziz@gmail.com>
Thu, 20 Jul 2017 14:46:51 +0000 (16:46 +0200)
committerTakishipp <toufik.boubehziz@gmail.com>
Thu, 20 Jul 2017 14:46:51 +0000 (16:46 +0200)
src/instr/instr_interface.cpp
src/instr/instr_paje_values.cpp
src/instr/instr_private.h
src/surf/instr_routing.cpp

index 43c2b18..ac336cc 100644 (file)
@@ -196,7 +196,7 @@ void TRACE_declare_mark_value_with_color (const char *mark_type, const char *mar
     mark_color = white;
 
   XBT_DEBUG("MARK,declare_value %s %s %s", mark_type, mark_value, mark_color);
     mark_color = white;
 
   XBT_DEBUG("MARK,declare_value %s %s %s", mark_type, mark_value, mark_color);
-  PJ_value_new (mark_value, mark_color, type);
+  s_val rett(mark_value, mark_color, type);
 }
 
 /** \ingroup TRACE_mark
 }
 
 /** \ingroup TRACE_mark
index 88ad1bb..2c4f8bd 100644 (file)
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_paje_values, instr, "Paje tracing event system (values)");
 
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_paje_values, instr, "Paje tracing event system (values)");
 
-val_t PJ_value_new (const char *name, const char *color, type_t father)
+val_t s_val::PJ_value_update (const char *name, const char *color, type_t father)
 {
 {
+  this->ret = xbt_new0(s_val, 1);
+  this->ret->name = xbt_strdup (name);
+  this->ret->father = father;
+  this->ret->color = xbt_strdup (color);
+
+  char str_id[INSTR_DEFAULT_STR_SIZE];
+  snprintf (str_id, INSTR_DEFAULT_STR_SIZE, "%lld", instr_new_paje_id());
+  this->ret->id = xbt_strdup (str_id);
+
+  xbt_dict_set (father->values, name, ret, nullptr);
+  XBT_DEBUG("new value %s, child of %s", this->ret->name, this->ret->father->name);
+  LogEntityValue(this->ret);
+  return this->ret;
+}
+
+s_val::s_val(const char *name, const char *color, type_t father){
   if (name == nullptr || father == nullptr){
     THROWF (tracing_error, 0, "can't create a value with a nullptr name (or a nullptr father)");
   }
   if (name == nullptr || father == nullptr){
     THROWF (tracing_error, 0, "can't create a value with a nullptr name (or a nullptr father)");
   }
-
-  val_t ret = xbt_new0(s_val_t, 1);
-  ret->name = xbt_strdup (name);
-  ret->father = father;
-  ret->color = xbt_strdup (color);
+  this->ret = xbt_new0(s_val, 1);
+  this->ret->name = xbt_strdup (name);
+  this->ret->father = father;
+  this->ret->color = xbt_strdup (color);
 
   char str_id[INSTR_DEFAULT_STR_SIZE];
   snprintf (str_id, INSTR_DEFAULT_STR_SIZE, "%lld", instr_new_paje_id());
 
   char str_id[INSTR_DEFAULT_STR_SIZE];
   snprintf (str_id, INSTR_DEFAULT_STR_SIZE, "%lld", instr_new_paje_id());
-  ret->id = xbt_strdup (str_id);
+  this->ret->id = xbt_strdup (str_id);
 
   xbt_dict_set (father->values, name, ret, nullptr);
   XBT_DEBUG("new value %s, child of %s", ret->name, ret->father->name);
 
   xbt_dict_set (father->values, name, ret, nullptr);
   XBT_DEBUG("new value %s, child of %s", ret->name, ret->father->name);
-  LogEntityValue(ret);
-  return ret;
-}
+  LogEntityValue(this->ret);
+};
 
 val_t PJ_value_get_or_new (const char *name, const char *color, type_t father)
 {
 
 val_t PJ_value_get_or_new (const char *name, const char *color, type_t father)
 {
@@ -38,7 +52,8 @@ val_t PJ_value_get_or_new (const char *name, const char *color, type_t father)
     ret = PJ_value_get(name, father);
   }
   catch(xbt_ex& e) {
     ret = PJ_value_get(name, father);
   }
   catch(xbt_ex& e) {
-    ret = PJ_value_new(name, color, father);
+    s_val rett(name, color, father);
+    ret = rett.ret;
   }
   return ret;
 }
   }
   return ret;
 }
index d3d45c2..bc6112d 100644 (file)
@@ -81,8 +81,11 @@ class s_val {
   char *name;
   char *color;
   type_t father;
   char *name;
   char *color;
   type_t father;
+  val_t ret;
+  s_val(const char *name, const char *color, type_t father);
+  val_t PJ_value_update (const char *name, const char *color, type_t father);
 };
 };
-typedef s_val s_val_t;
+
 
 //--------------------------------------------------
 typedef enum {
 
 //--------------------------------------------------
 typedef enum {
@@ -352,7 +355,6 @@ XBT_PRIVATE XBT_PRIVATE void PJ_type_free (type_t type);
 XBT_PRIVATE void recursiveDestroyType (type_t type);
 
 /* instr_paje_values.c */
 XBT_PRIVATE void recursiveDestroyType (type_t type);
 
 /* instr_paje_values.c */
-XBT_PUBLIC(val_t)  PJ_value_new (const char *name, const char *color, type_t father);
 XBT_PUBLIC(val_t)  PJ_value_get_or_new (const char *name, const char *color, type_t father);
 XBT_PUBLIC(val_t)  PJ_value_get (const char *name, const type_t father);
 
 XBT_PUBLIC(val_t)  PJ_value_get_or_new (const char *name, const char *color, type_t father);
 XBT_PUBLIC(val_t)  PJ_value_get (const char *name, const type_t father);
 
index 420221a..827b7ad 100644 (file)
@@ -267,11 +267,11 @@ static void sg_instr_new_host(simgrid::s4u::Host& host)
     if (msg_process == nullptr){
       msg_process = PJ_type_container_new("MSG_PROCESS", container->type);
       type_t state = PJ_type_state_new ("MSG_PROCESS_STATE", msg_process);
     if (msg_process == nullptr){
       msg_process = PJ_type_container_new("MSG_PROCESS", container->type);
       type_t state = PJ_type_state_new ("MSG_PROCESS_STATE", msg_process);
-      PJ_value_new ("suspend", "1 0 1", state);
-      PJ_value_new ("sleep", "1 1 0", state);
-      PJ_value_new ("receive", "1 0 0", state);
-      PJ_value_new ("send", "0 0 1", state);
-      PJ_value_new ("task_execute", "0 1 1", state);
+      s_val PJ_value("suspend", "1 0 1", state);
+      PJ_value.PJ_value_update("sleep", "1 1 0", state);
+      PJ_value.PJ_value_update("receive", "1 0 0", state);
+      PJ_value.PJ_value_update("send", "0 0 1", state);
+      PJ_value.PJ_value_update("task_execute", "0 1 1", state);
       PJ_type_link_new ("MSG_PROCESS_LINK", PJ_type_get_root(), msg_process, msg_process);
       PJ_type_link_new ("MSG_PROCESS_TASK_LINK", PJ_type_get_root(), msg_process, msg_process);
     }
       PJ_type_link_new ("MSG_PROCESS_LINK", PJ_type_get_root(), msg_process, msg_process);
       PJ_type_link_new ("MSG_PROCESS_TASK_LINK", PJ_type_get_root(), msg_process, msg_process);
     }
@@ -282,11 +282,11 @@ static void sg_instr_new_host(simgrid::s4u::Host& host)
     if (msg_vm == nullptr){
       msg_vm = PJ_type_container_new("MSG_VM", container->type);
       type_t state = PJ_type_state_new ("MSG_VM_STATE", msg_vm);
     if (msg_vm == nullptr){
       msg_vm = PJ_type_container_new("MSG_VM", container->type);
       type_t state = PJ_type_state_new ("MSG_VM_STATE", msg_vm);
-      PJ_value_new ("suspend", "1 0 1", state);
-      PJ_value_new ("sleep", "1 1 0", state);
-      PJ_value_new ("receive", "1 0 0", state);
-      PJ_value_new ("send", "0 0 1", state);
-      PJ_value_new ("task_execute", "0 1 1", state);
+      s_val PJ_value("suspend", "1 0 1", state);
+      PJ_value.PJ_value_update ("sleep", "1 1 0", state);
+      PJ_value.PJ_value_update ("receive", "1 0 0", state);
+      PJ_value.PJ_value_update ("send", "0 0 1", state);
+      PJ_value.PJ_value_update ("task_execute", "0 1 1", state);
       PJ_type_link_new ("MSG_VM_LINK", PJ_type_get_root(), msg_vm, msg_vm);
       PJ_type_link_new ("MSG_VM_PROCESS_LINK", PJ_type_get_root(), msg_vm, msg_vm);
     }
       PJ_type_link_new ("MSG_VM_LINK", PJ_type_get_root(), msg_vm, msg_vm);
       PJ_type_link_new ("MSG_VM_PROCESS_LINK", PJ_type_get_root(), msg_vm, msg_vm);
     }
@@ -403,7 +403,7 @@ void instr_new_user_state_type (const char *father_type, const char *new_typenam
 static void recursiveNewValueForUserStateType (const char *type_name, const char *value, const char *color, type_t root)
 {
   if (not strcmp(root->name, type_name)) {
 static void recursiveNewValueForUserStateType (const char *type_name, const char *value, const char *color, type_t root)
 {
   if (not strcmp(root->name, type_name)) {
-    PJ_value_new (value, color, root);
+    s_val PJ_value (value, color, root);
   }
   xbt_dict_cursor_t cursor = nullptr;
   type_t child_type;
   }
   xbt_dict_cursor_t cursor = nullptr;
   type_t child_type;