Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'toufic' of github.com:Takishipp/simgrid
authorTakishipp <toufik.boubehziz@gmail.com>
Wed, 3 May 2017 08:51:48 +0000 (10:51 +0200)
committerTakishipp <toufik.boubehziz@gmail.com>
Wed, 3 May 2017 08:51:48 +0000 (10:51 +0200)
17 files changed:
src/instr/instr_TI_trace.cpp
src/instr/instr_config.cpp
src/instr/instr_interface.cpp
src/instr/instr_paje_containers.cpp
src/instr/instr_paje_trace.cpp
src/instr/instr_paje_types.cpp
src/instr/instr_paje_values.cpp
src/instr/instr_private.h
src/instr/instr_resource_utilization.cpp
src/instr/instr_trace.cpp
src/msg/instr_msg_process.cpp
src/msg/instr_msg_task.cpp
src/msg/msg_vm.cpp
src/smpi/colls/smpi_automatic_selector.cpp
src/smpi/instr_smpi.cpp
src/surf/instr_routing.cpp
src/surf/instr_surf.cpp

index 3dbb4e5..1b191e0 100644 (file)
@@ -57,7 +57,7 @@ void TRACE_TI_end()
   XBT_DEBUG("Filename %s is closed", filename);
 }
 
-void print_TICreateContainer(paje_event_t event)
+void print_TICreateContainer(PajeEvent* event)
 {
   //if we are in the mode with only one file
   static FILE *temp = nullptr;
@@ -70,7 +70,8 @@ void print_TICreateContainer(paje_event_t event)
 
   if (!xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file") || temp == nullptr) {
     char *folder_name = bprintf("%s_files", TRACE_get_filename());
-    char *filename = bprintf("%s/%f_%s.txt", folder_name, prefix, ((createContainer_t) event->data)->container->name);
+    char *filename = bprintf("%s/%f_%s.txt", folder_name, prefix,
+     static_cast<CreateContainerEvent*>(event)->container->name);
 #ifdef WIN32
     _mkdir(folder_name);
 #else
@@ -84,35 +85,35 @@ void print_TICreateContainer(paje_event_t event)
     xbt_free(filename);
   }
 
-  xbt_dict_set(tracing_files, ((createContainer_t) event->data)->container->name, (void *) temp, nullptr);
+  xbt_dict_set(tracing_files, ((CreateContainerEvent*) event)->container->name, (void *) temp, nullptr);
 }
 
-void print_TIDestroyContainer(paje_event_t event)
+void print_TIDestroyContainer(PajeEvent* event)
 {
   if (!xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file")|| xbt_dict_length(tracing_files) == 1) {
-    FILE* f = (FILE*)xbt_dict_get_or_null(tracing_files, ((destroyContainer_t) event->data)->container->name);
+    FILE* f = (FILE*)xbt_dict_get_or_null(tracing_files, ((DestroyContainerEvent *) event)->container->name);
     fclose(f);
   }
-  xbt_dict_remove(tracing_files, ((destroyContainer_t) event->data)->container->name);
+  xbt_dict_remove(tracing_files, ((DestroyContainerEvent*) event)->container->name);
 }
 
-void print_TIPushState(paje_event_t event)
+void print_TIPushState(PajeEvent* event)
 {
   int i;
 
   //char* function=nullptr;
-  if (((pushState_t) event->data)->extra == nullptr)
+  if (((PushStateEvent*) event->data)->extra == nullptr)
     return;
-  instr_extra_data extra = (instr_extra_data) (((pushState_t) event->data)->extra);
+  instr_extra_data extra = (instr_extra_data) (((PushStateEvent*) event->data)->extra);
 
   char *process_id = nullptr;
   //FIXME: dirty extract "rank-" from the name, as we want the bare process id here
-  if (strstr(((pushState_t) event->data)->container->name, "rank-") == nullptr)
-    process_id = xbt_strdup(((pushState_t) event->data)->container->name);
+  if (strstr(((PushStateEvent*) event->data)->container->name, "rank-") == nullptr)
+    process_id = xbt_strdup(((PushStateEvent*) event->data)->container->name);
   else
-    process_id = xbt_strdup(((pushState_t) event->data)->container->name + 5);
+    process_id = xbt_strdup(((PushStateEvent*) event->data)->container->name + 5);
 
-  FILE* trace_file =  (FILE* )xbt_dict_get(tracing_files, ((pushState_t) event->data)->container->name);
+  FILE* trace_file =  (FILE* )xbt_dict_get(tracing_files, ((PushStateEvent*) event)->container->name);
 
   switch (extra->type) {
   case TRACING_INIT:
@@ -215,7 +216,7 @@ void print_TIPushState(paje_event_t event)
   case TRACING_ISSEND:
   default:
     XBT_WARN ("Call from %s impossible to translate into replay command : Not implemented (yet)",
-         ((pushState_t) event->data)->value->name);
+         ((PushStateEvent*) event->data)->value->name);
     break;
   }
 
index 1726c2d..b586f95 100644 (file)
@@ -104,7 +104,6 @@ int TRACE_start()
     const char* format = xbt_cfg_get_string(OPT_TRACING_FORMAT);
     XBT_DEBUG("Tracing format %s\n", format);
     if(!strcmp(format, "Paje")){
-      TRACE_paje_init();
       TRACE_paje_start();
     }else if (!strcmp(format, "TI")){
       TRACE_TI_init();
index 2952e59..7946c2b 100644 (file)
@@ -249,7 +249,7 @@ void TRACE_mark(const char *mark_type, const char *mark_value)
 
   val_t value = PJ_value_get (mark_value, type);
   XBT_DEBUG("MARK %s %s", mark_type, mark_value);
-  new_pajeNewEvent (MSG_get_clock(), PJ_container_get_root(), type, value);
+  new NewEvent (MSG_get_clock(), PJ_container_get_root(), type, value);
 }
 
 /** \ingroup TRACE_mark
@@ -289,13 +289,13 @@ static void instr_user_variable(double time, const char *resource, const char *v
       type_t type = PJ_type_get (variable, container->type);
       switch (what){
       case INSTR_US_SET:
-        new_pajeSetVariable(time, container, type, value);
+        new SetVariableEvent(time, container, type, value);
         break;
       case INSTR_US_ADD:
-        new_pajeAddVariable(time, container, type, value);
+        new AddVariableEvent(time, container, type, value);
         break;
       case INSTR_US_SUB:
-        new_pajeSubVariable(time, container, type, value);
+        new SubVariableEvent(time, container, type, value);
         break;
       default:
         THROW_IMPOSSIBLE;
@@ -964,7 +964,7 @@ void TRACE_host_set_state (const char *host, const char *state, const char *valu
   container_t container = PJ_container_get(host);
   type_t type = PJ_type_get (state, container->type);
   val_t val = PJ_value_get_or_new (value, nullptr, type); /* if user didn't declare a value with a color, use nullptr color */
-  new_pajeSetState(MSG_get_clock(), container, type, val);
+  new SetStateEvent(MSG_get_clock(), container, type, val);
 }
 
 /** \ingroup TRACE_user_variables
@@ -983,7 +983,7 @@ void TRACE_host_push_state (const char *host, const char *state, const char *val
   container_t container = PJ_container_get(host);
   type_t type = PJ_type_get (state, container->type);
   val_t val = PJ_value_get_or_new (value, nullptr, type); /* if user didn't declare a value with a color, use nullptr color */
-  new_pajePushState(MSG_get_clock(), container, type, val);
+  new PushStateEvent(MSG_get_clock(), container, type, val);
 }
 
 /** \ingroup TRACE_user_variables
@@ -1000,7 +1000,7 @@ void TRACE_host_pop_state (const char *host, const char *state)
 {
   container_t container = PJ_container_get(host);
   type_t type = PJ_type_get (state, container->type);
-  new_pajePopState(MSG_get_clock(), container, type);
+  new PopStateEvent(MSG_get_clock(), container, type);
 }
 
 /** \ingroup TRACE_user_variables
@@ -1017,7 +1017,7 @@ void TRACE_host_reset_state (const char *host, const char *state)
 {
   container_t container = PJ_container_get(host);
   type_t type = PJ_type_get (state, container->type);
-  new_pajeResetState(MSG_get_clock(), container, type);
+  new ResetStateEvent(MSG_get_clock(), container, type);
 }
 
 /** \ingroup TRACE_API
index 7a98c74..9b50d75 100644 (file)
@@ -138,7 +138,7 @@ container_t PJ_container_new (const char *name, e_container_types kind, containe
   newContainer->children = xbt_dict_new_homogeneous(nullptr);
   if (newContainer->father){
     xbt_dict_set(newContainer->father->children, newContainer->name, newContainer, nullptr);
-    new_pajeCreateContainer (newContainer);
+    new CreateContainerEvent(newContainer);
   }
 
   //register all kinds by name
@@ -206,7 +206,7 @@ void PJ_container_free (container_t container)
   if (!TRACE_disable_destroy() && container != PJ_container_get_root()){
     //do not trace the container destruction if user requests
     //or if the container is root
-    new_pajeDestroyContainer(container);
+    new DestroyContainerEvent(container);
   }
 
   //remove it from allContainers data structure
index 7573537..d436124 100644 (file)
@@ -7,6 +7,7 @@
 #include "src/instr/instr_private.h"
 #include "xbt/virtu.h" /* sg_cmdline */
 #include <sstream>
+#include <vector>
 #include <iomanip> /** std::setprecision **/
 #include "simgrid/sg_config.h"
 
@@ -17,12 +18,20 @@ extern s_instr_trace_writer_t active_writer;
 
 static std::stringstream stream;
 
-static void print_paje_debug(std::string functionName, paje_event_t event) {
-  XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event->event_type, TRACE_precision(),
-            event->timestamp);
+void buffer_debug(std::vector<PajeEvent*> *buf);
+void buffer_debug(std::vector<PajeEvent*> *buf) {
+  return;
+  XBT_DEBUG(">>>>>> Dump the state of the buffer. %zu events", buf->size());
+  for (auto event :*buf){
+    event->print();
+    XBT_DEBUG("%p %s", event, stream.str().c_str());
+    stream.str("");
+    stream.clear();
+  }
+  XBT_DEBUG("<<<<<<");
 }
 
-template<typename T> static void init_stream(paje_event_t event) {
+static void init_stream(PajeEvent* event) {
   stream << std::fixed << std::setprecision(TRACE_precision());
   stream << (int) event->event_type;
 }
@@ -30,71 +39,19 @@ template<typename T> static void init_stream(paje_event_t event) {
 static void print_row() {
   stream << std::endl;
   fprintf(tracing_file, "%s", stream.str().c_str());
+  XBT_DEBUG("Dump %s", stream.str().c_str());
   stream.str("");
   stream.clear();
 }
 
-static void print_timestamp(paje_event_t event) {
+static void print_timestamp(PajeEvent* event) {
   stream << " ";
   /* prevent 0.0000 in the trace - this was the behavior before the transition to c++ */
   if (event->timestamp < 1e-12)
     stream << 0;
   else 
     stream << event->timestamp;
-}
-
-template<typename T> static void print_default_pajeLink_row(paje_event_t& event) {
-  init_stream<T>(event);
-  print_timestamp(event);
-  stream << " " << static_cast<T>(event->data)->type->id
-         << " " << static_cast<T>(event->data)->container->id
-         << " " << static_cast<T>(event->data)->value;
-}
-
-template<typename T> static void print_default_pajeState_row(paje_event_t& event) {
-  init_stream<T>(event);
-  print_timestamp(event);
-  stream << " " << static_cast<T>(event->data)->type->id
-         << " " << static_cast<T>(event->data)->container->id;
-}
-
-template<typename T> static void print_default_pajeType_row(paje_event_t& event) {
-  init_stream<T>(event);
-  stream << " " << static_cast<T>(event->data)->type->id
-         << " " << static_cast<T>(event->data)->type->father->id
-         << " " << static_cast<T>(event->data)->type->name;
-}
-
-template<typename T> static void print_default_pajeVariable_row(paje_event_t& event) {
-  init_stream<T>(event);
-  print_timestamp(event);
-  stream << " " << static_cast<T>(event->data)->type->id
-         << " " << static_cast<T>(event->data)->container->id
-         << " " << static_cast<T>(event->data)->value;
-         
-  print_row();
-}
-
-void TRACE_paje_init() {
-  active_writer.print_DefineContainerType = &print_pajeDefineContainerType;
-  active_writer.print_DefineVariableType  = &print_pajeDefineVariableType;
-  active_writer.print_DefineStateType     = &print_pajeDefineStateType;
-  active_writer.print_DefineEventType     = &print_pajeDefineEventType;
-  active_writer.print_DefineLinkType      = &print_pajeDefineLinkType;
-  active_writer.print_DefineEntityValue   = &print_pajeDefineEntityValue;
-  active_writer.print_CreateContainer     = &print_pajeCreateContainer;
-  active_writer.print_DestroyContainer    = &print_pajeDestroyContainer;
-  active_writer.print_SetVariable         = &print_pajeSetVariable;
-  active_writer.print_AddVariable         = &print_pajeAddVariable;
-  active_writer.print_SubVariable         = &print_pajeSubVariable;
-  active_writer.print_SetState            = &print_pajeSetState;
-  active_writer.print_PushState           = &print_pajePushState;
-  active_writer.print_PopState            = &print_pajePopState;
-  active_writer.print_ResetState          = &print_pajeResetState;
-  active_writer.print_StartLink           = &print_pajeStartLink;
-  active_writer.print_EndLink             = &print_pajeEndLink;
-  active_writer.print_NewEvent            = &print_pajeNewEvent;
-}
+}  
 
 void TRACE_paje_start() {
   char *filename = TRACE_get_filename();
@@ -132,114 +89,146 @@ void TRACE_paje_end() {
   XBT_DEBUG("Filename %s is closed", filename);
 }
 
-void print_pajeDefineContainerType(paje_event_t event) {
-  print_paje_debug(__FUNCTION__, event);
-  print_default_pajeType_row<defineContainerType_t>(event);
+void DefineContainerEvent::print() {
+  XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+  init_stream(this);
+  stream << " " << type->id
+         << " " << type->father->id
+         << " " << type->name;
   print_row();
 }
 
-void print_pajeDefineVariableType(paje_event_t event) {
-  print_paje_debug(__FUNCTION__, event);
-  print_default_pajeType_row<defineVariableType_t>(event);
-  if(static_cast<defineVariableType_t>(event->data)->type->color)
-    stream << " \"" << static_cast<defineVariableType_t>(event->data)->type->color << "\"";
+void DefineVariableTypeEvent::print() {
+  XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+  init_stream(this);
+  stream << " " << type->id
+         << " " << type->father->id
+         << " " << type->name;
+  if (type->color)
+    stream << " \"" << type->color << "\"";
   print_row();
 }
 
-void print_pajeDefineStateType(paje_event_t event) {
-  print_paje_debug(__FUNCTION__, event);
-  print_default_pajeType_row<defineStateType_t>(event);
+void DefineStateTypeEvent::print() {
+  XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+  init_stream(this);
+  stream << " " << type->id
+         << " " << type->father->id
+         << " " << type->name;
   print_row();
 }
 
-void print_pajeDefineEventType(paje_event_t event) {
-  print_paje_debug(__FUNCTION__, event);
-  print_default_pajeType_row<defineEventType_t>(event);
+void DefineEventTypeEvent::print() {
+  XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+  init_stream(this);
+  stream << " " << type->id
+         << " " << type->father->id
+         << " " << type->name;
   print_row();
 }
 
-void print_pajeDefineLinkType(paje_event_t event) {
-  print_paje_debug(__FUNCTION__, event);
-  init_stream<defineLinkType_t>(event);
-  stream << " " << static_cast<defineLinkType_t>(event->data)->type->id 
-         << " " << static_cast<defineLinkType_t>(event->data)->type->father->id 
-         << " " << static_cast<defineLinkType_t>(event->data)->source->id 
-         << " " << static_cast<defineLinkType_t>(event->data)->dest->id 
-         << " " << static_cast<defineLinkType_t>(event->data)->type->name;
+void DefineLinkTypeEvent::print() {
+  XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+  init_stream (this);
+  stream << " " << type->id 
+         << " " << type->father->id 
+         << " " << source->id 
+         << " " << dest->id 
+         << " " << type->name;
   print_row();
 }
 
-void print_pajeDefineEntityValue (paje_event_t event) {
-  print_paje_debug(__FUNCTION__, event);
-  init_stream<defineEntityValue_t>(event);
-  stream << " "   << static_cast<defineEntityValue_t>(event->data)->value->id
-         << " "   << static_cast<defineEntityValue_t>(event->data)->value->father->id
-         << " "   << static_cast<defineEntityValue_t>(event->data)->value->name;
-  if(static_cast<defineEntityValue_t>(event->data)->value->color)
-    stream << " \"" << static_cast<defineEntityValue_t>(event->data)->value->color << "\"";
+void DefineEntityValueEvent::print() {
+  XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+  init_stream(this);
+  stream << " "   << value->id
+         << " "   << value->father->id
+         << " "   << value->name;
+  if(value->color)
+    stream << " \"" << value->color << "\"";
   print_row();
 }
 
-void print_pajeCreateContainer(paje_event_t event) {
-  print_paje_debug(__FUNCTION__, event);
-  init_stream<createContainer_t>(event);
-  print_timestamp(event);
-  stream << " "   << static_cast<createContainer_t>(event->data)->container->id
-         << " "   << static_cast<createContainer_t>(event->data)->container->type->id
-         << " "   << static_cast<createContainer_t>(event->data)->container->father->id
-         << " \"" << static_cast<createContainer_t>(event->data)->container->name << "\"";
+void CreateContainerEvent::print() {
+  XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+  init_stream(this);
+  print_timestamp(this);
+  stream << " "   << container->id
+         << " "   << container->type->id
+         << " "   << container->father->id
+         << " \"" << container->name << "\"";
 
   print_row();
 }
 
-void print_pajeDestroyContainer(paje_event_t event) {
-  print_paje_debug(__FUNCTION__, event);
-  init_stream<createContainer_t>(event);
-  print_timestamp(event);
-  stream << " "   << static_cast<createContainer_t>(event->data)->container->type->id
-         << " "   << static_cast<createContainer_t>(event->data)->container->id;
+void DestroyContainerEvent::print() {
+  XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+  init_stream(this);
+  print_timestamp(this);
+  stream << " "   << container->type->id
+         << " "   << container->id;
 
   print_row();
 }
 
-void print_pajeSetVariable(paje_event_t event) {
-  print_paje_debug(__FUNCTION__, event);
-  print_default_pajeVariable_row<setVariable_t>(event);
+void SetVariableEvent::print() {
+  XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+  init_stream(this);
+  print_timestamp(this);
+  stream << " " << type->id
+         << " " << container->id
+         << " " << value;
+  print_row();
 }
 
-void print_pajeAddVariable(paje_event_t event) {
-  print_paje_debug(__FUNCTION__, event);
-  print_default_pajeVariable_row<addVariable_t>(event);
+void AddVariableEvent::print() {
+  XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+  init_stream(this);
+  print_timestamp(this);
+  stream << " " << type->id
+         << " " << container->id
+         << " " << value;
+  print_row();
 }
 
-void print_pajeSubVariable(paje_event_t event) {
-  print_paje_debug(__FUNCTION__, event);
-  print_default_pajeVariable_row<subVariable_t>(event);
+void SubVariableEvent::print() {
+  XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+  init_stream(this);
+  print_timestamp(this);
+  stream << " " << type->id
+         << " " << container->id
+         << " " << value;
+  print_row();
 }
 
-void print_pajeSetState(paje_event_t event) {
-  print_paje_debug(__FUNCTION__, event);
-
-  print_default_pajeState_row<setState_t>(event);
-  stream << " " << static_cast<setState_t>(event->data)->value->id;
+void SetStateEvent::print() {
+  XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+  init_stream(this);
+  print_timestamp(this);
+  stream << " " << type->id
+         << " " << container->id;
+  stream << " " <<value->id;
 #if HAVE_SMPI
   if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
-    stream << " \"" << static_cast<setState_t>(event->data)->filename
-           << "\" " << static_cast<setState_t>(event->data)->linenumber;
+    stream << " \"" << filename
+           << "\" " << linenumber;
   }
 #endif
   print_row();
 }
 
-void print_pajePushState(paje_event_t event) {
-  print_paje_debug(__FUNCTION__, event);
-  print_default_pajeState_row<pushState_t>(event);
-  stream << " " << static_cast<pushState_t>(event->data)->value->id;
+void PushStateEvent::print() {
+  XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+  init_stream(this);
+  print_timestamp(this);
+  stream << " " << type->id
+         << " " << container->id;
+  stream << " " <<value->id;
 
   if (TRACE_display_sizes()) {
     stream << " ";
-    if (static_cast<pushState_t>(event->data)->extra != nullptr) {
-      stream << static_cast<instr_extra_data>(static_cast<pushState_t>(event->data)->extra)->send_size;
+    if (extra != nullptr) {
+      stream << static_cast<instr_extra_data>(extra)->send_size;
     }
     else {
       stream << 0;
@@ -247,59 +236,73 @@ void print_pajePushState(paje_event_t event) {
   }
 #if HAVE_SMPI
   if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
-    stream << " \"" << static_cast<pushState_t>(event->data)->filename
-           << "\" " << static_cast<pushState_t>(event->data)->linenumber;
+    stream << " \"" << filename
+           << "\" " << linenumber;
   }
 #endif
   print_row();
 
-  if (static_cast<pushState_t>(event->data)->extra != nullptr) {
-    if (static_cast<instr_extra_data>(static_cast<pushState_t>(event->data)->extra)->sendcounts != nullptr)
-      xbt_free(static_cast<instr_extra_data>(static_cast<pushState_t>(event->data)->extra)->sendcounts);
-    if (static_cast<instr_extra_data>(static_cast<pushState_t>(event->data)->extra)->recvcounts != nullptr)
-      xbt_free(static_cast<instr_extra_data>(static_cast<pushState_t>(event->data)->extra)->recvcounts);
-    xbt_free(static_cast<pushState_t>(event->data)->extra);
+  if (extra != nullptr) {
+    if (static_cast<instr_extra_data>(extra)->sendcounts != nullptr)
+      xbt_free(static_cast<instr_extra_data>(extra)->sendcounts);
+    if (static_cast<instr_extra_data>(extra)->recvcounts != nullptr)
+      xbt_free(static_cast<instr_extra_data>(extra)->recvcounts);
+    xbt_free(extra);
   }
 }
 
-void print_pajePopState(paje_event_t event) {
-  print_paje_debug(__FUNCTION__, event);
-  print_default_pajeState_row<popState_t>(event);
+void PopStateEvent::print() {
+  XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+  init_stream(this);
+  print_timestamp(this);
+  stream << " " << type->id
+         << " " << container->id;
   print_row();
 }
 
-void print_pajeResetState(paje_event_t event) {
-  print_paje_debug(__FUNCTION__, event);
-  print_default_pajeState_row<resetState_t>(event);
+void ResetStateEvent::print() {
+  XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+  init_stream(this);
+  print_timestamp(this);
+  stream << " " << type->id
+         << " " << container->id;
   print_row();
 }
 
-void print_pajeStartLink(paje_event_t event) {
-  print_paje_debug(__FUNCTION__, event);
-  print_default_pajeLink_row<startLink_t>(event);
-  stream << " " << static_cast<startLink_t>(event->data)->sourceContainer->id
-         << " " << static_cast<startLink_t>(event->data)->key;
+void StartLinkEvent::print() {
+  XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+  init_stream(this);
+  print_timestamp(this);
+  stream << " " <<type->id
+         << " " <<container->id
+         << " " <<value;
+  stream << " " << sourceContainer->id
+         << " " << key;
 
   if (TRACE_display_sizes()) {
-    stream << " " << static_cast<startLink_t>(event->data)->size;
+    stream << " " << size;
   }
   print_row();
 }
 
-void print_pajeEndLink(paje_event_t event) {
-  print_paje_debug(__FUNCTION__, event);
-  print_default_pajeLink_row<startLink_t>(event);
-  stream << " " << static_cast<endLink_t>(event->data)->destContainer->id
-         << " " << static_cast<endLink_t>(event->data)->key;
+void EndLinkEvent::print() {
+  XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+  init_stream(this);
+  print_timestamp(this);
+  stream << " " <<type->id
+         << " " <<container->id
+         << " " <<value;
+  stream << " " << destContainer->id
+         << " " << key;
   print_row();
 }
 
-void print_pajeNewEvent (paje_event_t event) {
-  print_paje_debug(__FUNCTION__, event);
-  init_stream<newEvent_t>(event);
-  print_timestamp(event);
-  stream << " " << static_cast<newEvent_t>(event->data)->type->id
-         << " " << static_cast<newEvent_t>(event->data)->container->id
-         << " " << static_cast<newEvent_t>(event->data)->value->id;
+void NewEvent::print () {
+  XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+  init_stream (this);
+  print_timestamp(this);
+  stream << " " << type->id
+         << " " << container->id
+         << " " << value->id;
   print_row();
 }
index eb40012..c9baee5 100644 (file)
@@ -130,20 +130,20 @@ type_t PJ_type_container_new (const char *name, type_t father)
 
   if(father){
     XBT_DEBUG("ContainerType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id);
-    new_pajeDefineContainerType (ret);
+    new DefineContainerEvent(ret);
   }
   return ret;
 }
 
 type_t PJ_type_event_new (const char *name, type_t father)
-{
+{ 
   if (name == nullptr){
     THROWF (tracing_error, 0, "can't create an event type with a nullptr name");
   }
 
   type_t ret = newType (name, name, nullptr, TYPE_EVENT, father);
   XBT_DEBUG("EventType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id);
-  new_pajeDefineEventType(ret);
+  new DefineEventTypeEvent(ret);
   return ret;
 }
 
@@ -162,7 +162,7 @@ type_t PJ_type_variable_new (const char *name, const char *color, type_t father)
     ret = newType (name, name, color, TYPE_VARIABLE, father);
   }
   XBT_DEBUG("VariableType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id);
-  new_pajeDefineVariableType (ret);
+  new DefineVariableTypeEvent (ret);
   return ret;
 }
 
@@ -179,7 +179,7 @@ type_t PJ_type_link_new (const char *name, type_t father, type_t source, type_t
   ret = newType (name, key, nullptr, TYPE_LINK, father);
   XBT_DEBUG("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);
-  new_pajeDefineLinkType(ret, source, dest);
+  new DefineLinkTypeEvent(ret, source, dest);
   return ret;
 }
 
@@ -193,6 +193,6 @@ type_t PJ_type_state_new (const char *name, type_t father)
 
   ret = newType (name, name, nullptr, TYPE_STATE, father);
   XBT_DEBUG("StateType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id);
-  new_pajeDefineStateType(ret);
+  new DefineStateTypeEvent(ret);
   return ret;
 }
index 7d69e51..d07eb6f 100644 (file)
@@ -27,7 +27,7 @@ val_t PJ_value_new (const char *name, const char *color, type_t father)
 
   xbt_dict_set (father->values, name, ret, nullptr);
   XBT_DEBUG("new value %s, child of %s", ret->name, ret->father->name);
-  new_pajeDefineEntityValue(ret);
+  new DefineEntityValueEvent(ret);
   return ret;
 }
 
index b6c49e6..0102392 100644 (file)
@@ -55,25 +55,36 @@ typedef enum {
   TYPE_EVENT
 } e_entity_types;
 
-typedef struct s_type *type_t;
-typedef struct s_type {
+//--------------------------------------------------
+class s_type;
+typedef s_type *type_t;
+class s_type {
+  public:
   char *id;
   char *name;
   char *color;
   e_entity_types kind;
-  struct s_type *father;
+  s_type *father;
   xbt_dict_t children;
   xbt_dict_t values; //valid for all types except variable and container
-}s_type_t;
+};
 
-typedef struct s_val *val_t;
-typedef struct s_val {
+typedef s_type s_type_t;
+
+//--------------------------------------------------
+class s_val;
+typedef s_val *val_t;
+
+class s_val {
+  public:
   char *id;
   char *name;
   char *color;
   type_t father;
-}s_val_t;
+};
+typedef s_val s_val_t;
 
+//--------------------------------------------------
 typedef enum {
   INSTR_HOST,
   INSTR_LINK,
@@ -85,101 +96,148 @@ typedef enum {
   INSTR_MSG_TASK
 } e_container_types;
 
-typedef struct s_container *container_t;
-typedef struct s_container {
+//--------------------------------------------------
+class s_container;
+typedef s_container *container_t;
+
+class s_container {
+  public: 
   sg_netpoint_t netpoint;
   char *name;     /* Unique name of this container */
   char *id;       /* Unique id of this container */
   type_t type;    /* Type of this container */
   int level;      /* Level in the hierarchy, root level is 0 */
   e_container_types kind; /* This container is of what kind */
-  struct s_container *father;
+  s_container *father;
   xbt_dict_t children;
-}s_container_t;
+};
+typedef s_container s_container_t;
 
-typedef struct paje_event *paje_event_t;
-typedef struct paje_event {
+//--------------------------------------------------
+class PajeEvent {
+  public:
   double timestamp;
   e_event_type event_type;
-  void (*print) (paje_event_t event);
-  void (*free) (paje_event_t event);
+  virtual void print() = 0;
   void *data;
-} s_paje_event_t;
+  virtual ~PajeEvent();
+};
 
-typedef struct s_defineContainerType *defineContainerType_t;
-typedef struct s_defineContainerType {
+class DefineContainerEvent : public PajeEvent
+{
+  public:
   type_t type;
-}s_defineContainerType_t;
+  void print() override;
+  DefineContainerEvent(type_t);
+};
+
+//--------------------------------------------------
 
-typedef struct s_defineVariableType *defineVariableType_t;
-typedef struct s_defineVariableType {
+
+//--------------------------------------------------
+
+class DefineVariableTypeEvent : public PajeEvent 
+{
+  public:
   type_t type;
-}s_defineVariableType_t;
+   DefineVariableTypeEvent(type_t type);
+   void print() override;
+};
+//--------------------------------------------------
 
-typedef struct s_defineStateType *defineStateType_t;
-typedef struct s_defineStateType {
+class DefineStateTypeEvent : public PajeEvent  {
   type_t type;
-}s_defineStateType_t;
+  public:
+  DefineStateTypeEvent(type_t type);
+  void print() override;
+};
 
-typedef struct s_defineEventType *defineEventType_t;
-typedef struct s_defineEventType {
+class DefineEventTypeEvent : public PajeEvent  {
   type_t type;
-}s_defineEventType_t;
+  public: 
+  DefineEventTypeEvent(type_t type);
+  void print() override;
+};
 
-typedef struct s_defineLinkType *defineLinkType_t;
-typedef struct s_defineLinkType {
+class DefineLinkTypeEvent : public PajeEvent  {
   type_t type;
   type_t source;
   type_t dest;
-}s_defineLinkType_t;
+  public:
+  DefineLinkTypeEvent(type_t type, type_t source, type_t dest);
+  void print() override;
+};
 
-typedef struct s_defineEntityValue *defineEntityValue_t;
-typedef struct s_defineEntityValue {
+class DefineEntityValueEvent : public PajeEvent  {
   val_t value;
-}s_defineEntityValue_t;
+  public:
+  DefineEntityValueEvent (val_t type);
+  void print() override;
+};
 
-typedef struct s_createContainer *createContainer_t;
-typedef struct s_createContainer {
+class CreateContainerEvent : public PajeEvent  {
+  public:
   container_t container;
-}s_createContainer_t;
+  explicit CreateContainerEvent (container_t container);
+  void print() override;
+};
 
-typedef struct s_destroyContainer *destroyContainer_t;
-typedef struct s_destroyContainer {
+class DestroyContainerEvent : public PajeEvent  {
+  public:
   container_t container;
-}s_destroyContainer_t;
+  DestroyContainerEvent (container_t container);
+  void print() override;
+};
+
 
-typedef struct s_setVariable *setVariable_t;
-typedef struct s_setVariable {
+class SetVariableEvent : public PajeEvent  {
   container_t container;
   type_t type;
   double value;
-}s_setVariable_t;
+  public:
+  SetVariableEvent (double timestamp, container_t container, type_t type, double value);
+  void print() override;
+};
 
-typedef struct s_addVariable *addVariable_t;
-typedef struct s_addVariable {
+
+class AddVariableEvent:public PajeEvent {
   container_t container;
   type_t type;
   double value;
-}s_addVariable_t;
+  public:
+  AddVariableEvent (double timestamp, container_t container, type_t type, double value);
+  void print() override;
+};
+
+//--------------------------------------------------
+
 
-typedef struct s_subVariable *subVariable_t;
-typedef struct s_subVariable {
+class SubVariableEvent : public PajeEvent  {
+  public:
   container_t container;
   type_t type;
-  double value;
-}s_subVariable_t;
-
-typedef struct s_setState *setState_t;
-typedef struct s_setState {
+  double value; 
+  public:
+  SubVariableEvent(double timestamp, container_t container, type_t type, double value);
+  void print() override;
+};
+//--------------------------------------------------
+
+class SetStateEvent : public PajeEvent  {
+  public:
   container_t container;
   type_t type;
   val_t value;
   const char* filename;
   int linenumber;
-}s_setState_t;
+  public:
+  SetStateEvent (double timestamp, container_t container, type_t type, val_t value);
+  void print() override;
+};
+
 
-typedef struct s_pushState *pushState_t;
-typedef struct s_pushState {
+class PushStateEvent : public PajeEvent  {
+  public:
   container_t container;
   type_t type;
   val_t value;
@@ -187,46 +245,70 @@ typedef struct s_pushState {
   const char* filename;
   int linenumber;
   void* extra;
-}s_pushState_t;
+  public:
+  PushStateEvent (double timestamp, container_t container, type_t type, val_t value);
+  PushStateEvent (double timestamp, container_t container, type_t type, val_t value,
+                                             void* extra);
+  void print() override;
+};
 
-typedef struct s_popState *popState_t;
-typedef struct s_popState {
+class PopStateEvent : public PajeEvent  {
   container_t container;
   type_t type;
   xbt_dynar_t extra;
-}s_popState_t;
+  public:
+  PopStateEvent (double timestamp, container_t container, type_t type);
+  void print() override;
+};
 
-typedef struct s_resetState *resetState_t;
-typedef struct s_resetState {
+class ResetStateEvent : public PajeEvent  {
   container_t container;
   type_t type;
-}s_resetState_t;
+  public:
+  ResetStateEvent (double timestamp, container_t container, type_t type);
+  void print() override;
+};
 
-typedef struct s_startLink *startLink_t;
-typedef struct s_startLink {
+class StartLinkEvent : public PajeEvent  {
+  public:
   container_t container;
   type_t type;
   container_t sourceContainer;
   char *value;
   char *key;
   int size;
-}s_startLink_t;
+  public:
+  StartLinkEvent (double timestamp, container_t container, type_t type, container_t sourceContainer,
+                                    const char *value, const char *key);
+  StartLinkEvent (double timestamp, container_t container, type_t type,
+                                            container_t sourceContainer, const char *value, const char *key, int size);
+  void print() override;
+};
 
-typedef struct s_endLink *endLink_t;
-typedef struct s_endLink {
+class EndLinkEvent : public PajeEvent  {
   container_t container;
   type_t type;
   container_t destContainer;
   char *value;
   char *key;
-}s_endLink_t;
+  public:
+  EndLinkEvent (double timestamp, container_t container, type_t type, container_t destContainer,
+                                  const char *value, const char *key);
+  void print() override;
+};
+
 
-typedef struct s_newEvent *newEvent_t;
-typedef struct s_newEvent {
+class NewEvent : public PajeEvent  {
+  public:
   container_t container;
   type_t type;
   val_t value;
-}s_newEvent_t;
+  public:
+  NewEvent (double timestamp, container_t container, type_t type, val_t value);
+  void print() override;
+
+};
+
 
 extern XBT_PRIVATE xbt_dict_t created_categories;
 extern XBT_PRIVATE xbt_dict_t declared_marks;
@@ -239,34 +321,10 @@ extern XBT_PRIVATE double TRACE_last_timestamp_to_dump;
 XBT_PRIVATE void TRACE_header(int basic, int size);
 
 /* from paje.c */
-XBT_PRIVATE void TRACE_paje_init();
 XBT_PRIVATE void TRACE_paje_start();
 XBT_PRIVATE void TRACE_paje_end();
 XBT_PRIVATE void TRACE_paje_dump_buffer (int force);
-XBT_PUBLIC(void) new_pajeDefineContainerType(type_t type);
-XBT_PUBLIC(void) new_pajeDefineVariableType(type_t type);
-XBT_PUBLIC(void) new_pajeDefineStateType(type_t type);
-XBT_PUBLIC(void) new_pajeDefineEventType(type_t type);
-XBT_PUBLIC(void) new_pajeDefineLinkType(type_t type, type_t source, type_t dest);
-XBT_PUBLIC(void) new_pajeDefineEntityValue (val_t type);
-XBT_PUBLIC(void) new_pajeCreateContainer (container_t container);
-XBT_PUBLIC(void) new_pajeDestroyContainer (container_t container);
-XBT_PUBLIC(void) new_pajeSetVariable (double timestamp, container_t container, type_t type, double value);
-XBT_PUBLIC(void) new_pajeAddVariable (double timestamp, container_t container, type_t type, double value);
-XBT_PUBLIC(void) new_pajeSubVariable (double timestamp, container_t container, type_t type, double value);
-XBT_PUBLIC(void) new_pajeSetState (double timestamp, container_t container, type_t type, val_t value);
-XBT_PUBLIC(void) new_pajePushState (double timestamp, container_t container, type_t type, val_t value);
-XBT_PUBLIC(void) new_pajePushStateWithExtra (double timestamp, container_t container, type_t type, val_t value,
-                                             void* extra);
-XBT_PUBLIC(void) new_pajePopState (double timestamp, container_t container, type_t type);
-XBT_PUBLIC(void) new_pajeResetState (double timestamp, container_t container, type_t type);
-XBT_PUBLIC(void) new_pajeStartLink (double timestamp, container_t container, type_t type, container_t sourceContainer,
-                                    const char *value, const char *key);
-XBT_PUBLIC(void) new_pajeStartLinkWithSize (double timestamp, container_t container, type_t type,
-                                            container_t sourceContainer, const char *value, const char *key, int size);
-XBT_PUBLIC(void) new_pajeEndLink (double timestamp, container_t container, type_t type, container_t destContainer,
-                                  const char *value, const char *key);
-XBT_PUBLIC(void) new_pajeNewEvent (double timestamp, container_t container, type_t type, val_t value);
+
 
 /* from instr_config.c */
 XBT_PRIVATE bool TRACE_needs_platform ();
@@ -345,56 +403,56 @@ XBT_PUBLIC(val_t)  PJ_value_get_or_new (const char *name, const char *color, typ
 XBT_PUBLIC(val_t)  PJ_value_get (const char *name, const type_t father);
 XBT_PRIVATE void PJ_value_free (val_t value);
 
-XBT_PRIVATE void print_pajeDefineContainerType(paje_event_t event);
-XBT_PRIVATE void print_pajeDefineVariableType(paje_event_t event);
-XBT_PRIVATE void print_pajeDefineStateType(paje_event_t event);
-XBT_PRIVATE void print_pajeDefineEventType(paje_event_t event);
-XBT_PRIVATE void print_pajeDefineLinkType(paje_event_t event);
-XBT_PRIVATE void print_pajeDefineEntityValue (paje_event_t event);
-XBT_PRIVATE void print_pajeCreateContainer(paje_event_t event);
-XBT_PRIVATE void print_pajeDestroyContainer(paje_event_t event);
-XBT_PRIVATE void print_pajeSetVariable(paje_event_t event);
-XBT_PRIVATE void print_pajeAddVariable(paje_event_t event);
-XBT_PRIVATE void print_pajeSubVariable(paje_event_t event);
-XBT_PRIVATE void print_pajeSetState(paje_event_t event);
-XBT_PRIVATE void print_pajePushState(paje_event_t event);
-XBT_PRIVATE void print_pajePopState(paje_event_t event);
-XBT_PRIVATE void print_pajeResetState(paje_event_t event);
-XBT_PRIVATE void print_pajeStartLink(paje_event_t event);
-XBT_PRIVATE void print_pajeEndLink(paje_event_t event);
-XBT_PRIVATE void print_pajeNewEvent (paje_event_t event);
-
-XBT_PRIVATE void print_TIPushState(paje_event_t event);
-XBT_PRIVATE void print_TICreateContainer(paje_event_t event);
-XBT_PRIVATE void print_TIDestroyContainer(paje_event_t event);
+XBT_PRIVATE void print_pajeDefineContainerType(PajeEvent* event);
+XBT_PRIVATE void print_pajeDefineVariableType(PajeEvent* event);
+XBT_PRIVATE void print_pajeDefineStateType(PajeEvent* event);
+XBT_PRIVATE void print_pajeDefineEventType(PajeEvent* event);
+XBT_PRIVATE void print_pajeDefineLinkType(PajeEvent* event);
+XBT_PRIVATE void print_pajeDefineEntityValue (PajeEvent* event);
+XBT_PRIVATE void print_pajeCreateContainer(PajeEvent* event);
+XBT_PRIVATE void print_pajeDestroyContainer(PajeEvent* event);
+XBT_PRIVATE void print_pajeSetVariable(PajeEvent* event);
+XBT_PRIVATE void print_pajeAddVariable(PajeEvent* event);
+XBT_PRIVATE void print_pajeSubVariable(PajeEvent* event);
+XBT_PRIVATE void print_pajeSetState(PajeEvent* event);
+XBT_PRIVATE void print_pajePushState(PajeEvent* event);
+XBT_PRIVATE void print_pajePopState(PajeEvent* event);
+XBT_PRIVATE void print_pajeResetState(PajeEvent* event);
+XBT_PRIVATE void print_pajeStartLink(PajeEvent* event);
+XBT_PRIVATE void print_pajeEndLink(PajeEvent* event);
+XBT_PRIVATE void print_pajeNewEvent (PajeEvent* event);
+
+XBT_PRIVATE void print_TIPushState(PajeEvent* event);
+XBT_PRIVATE void print_TICreateContainer(PajeEvent* event);
+XBT_PRIVATE void print_TIDestroyContainer(PajeEvent* event);
 XBT_PRIVATE void TRACE_TI_start();
 XBT_PRIVATE void TRACE_TI_end();
 XBT_PRIVATE void TRACE_TI_init();
 
-XBT_PRIVATE void print_NULL (paje_event_t event);
+XBT_PRIVATE void print_NULL (PajeEvent* event);
 XBT_PRIVATE void TRACE_paje_dump_buffer (int force);
 XBT_PRIVATE void dump_comment_file (const char *filename);
 XBT_PRIVATE void dump_comment (const char *comment);
 
 typedef struct instr_trace_writer {
-  void (*print_DefineContainerType) (paje_event_t event);
-  void (*print_DefineVariableType)(paje_event_t event);
-  void (*print_DefineStateType)(paje_event_t event);
-  void (*print_DefineEventType)(paje_event_t event);
-  void (*print_DefineLinkType)(paje_event_t event);
-  void (*print_DefineEntityValue)(paje_event_t event);
-  void (*print_CreateContainer)(paje_event_t event);
-  void (*print_DestroyContainer)(paje_event_t event);
-  void (*print_SetVariable)(paje_event_t event);
-  void (*print_AddVariable)(paje_event_t event);
-  void (*print_SubVariable)(paje_event_t event);
-  void (*print_SetState)(paje_event_t event);
-  void (*print_PushState)(paje_event_t event);
-  void (*print_PopState)(paje_event_t event);
-  void (*print_ResetState)(paje_event_t event);
-  void (*print_StartLink)(paje_event_t event);
-  void (*print_EndLink)(paje_event_t event);
-  void (*print_NewEvent) (paje_event_t event);
+  void (*print_DefineContainerType) (PajeEvent* event);
+  void (*print_DefineVariableType)(PajeEvent* event);
+  void (*print_DefineStateType)(PajeEvent* event);
+  void (*print_DefineEventType)(PajeEvent* event);
+  void (*print_DefineLinkType)(PajeEvent* event);
+  void (*print_DefineEntityValue)(PajeEvent* event);
+  void (*print_CreateContainer)(PajeEvent* event);
+  void (*print_DestroyContainer)(PajeEvent* event);
+  void (*print_SetVariable)(PajeEvent* event);
+  void (*print_AddVariable)(PajeEvent* event);
+  void (*print_SubVariable)(PajeEvent* event);
+  void (*print_SetState)(PajeEvent* event);
+  void (*print_PushState)(PajeEvent* event);
+  void (*print_PopState)(PajeEvent* event);
+  void (*print_ResetState)(PajeEvent* event);
+  void (*print_StartLink)(PajeEvent* event);
+  void (*print_EndLink)(PajeEvent* event);
+  void (*print_NewEvent) (PajeEvent* event);
 } s_instr_trace_writer_t;
 
 struct s_instr_extra_data;
index c7b0bcd..0cfed5e 100644 (file)
@@ -29,7 +29,7 @@ static void __TRACE_surf_check_variable_set_to_zero(double now, const char *vari
   if (!xbt_dict_get_or_null(platform_variables, key)) {
     container_t container = PJ_container_get (resource);
     type_t type = PJ_type_get (variable, container->type);
-    new_pajeSetVariable (now, container, type, 0);
+    new SetVariableEvent (now, container, type, 0);
     xbt_dict_set(platform_variables, key, (char*)"", nullptr);
   }
   xbt_free(key);
@@ -38,8 +38,8 @@ static void __TRACE_surf_check_variable_set_to_zero(double now, const char *vari
 static void instr_event (double now, double delta, type_t variable, container_t resource, double value)
 {
   __TRACE_surf_check_variable_set_to_zero(now, variable->name, resource->name);
-  new_pajeAddVariable(now, resource, variable, value);
-  new_pajeSubVariable(now + delta, resource, variable, value);
+  new AddVariableEvent(now, resource, variable, value);
+  new SubVariableEvent(now + delta, resource, variable, value);
 }
 
 /* TRACE_surf_link_set_utilization: entry point from SimGrid */
index e19005a..b226de9 100644 (file)
@@ -8,12 +8,15 @@
 #include "src/instr/instr_smpi.h"
 #include "src/smpi/private.hpp"
 #include "xbt/virtu.h" /* sg_cmdline */
+#include "typeinfo"
+
+#include <vector>
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_trace, instr, "tracing event system");
 
 FILE *tracing_file = nullptr;
 
-void print_NULL(paje_event_t event){}
+void print_NULL(PajeEvent* event){}
 
 /* The active set of functions for the selected trace format
  * By default, they all do nothing, hence the print_NULL to avoid segfaults */
@@ -22,7 +25,8 @@ s_instr_trace_writer_t active_writer = {&print_NULL, &print_NULL, &print_NULL, &
                                         &print_NULL, &print_NULL, &print_NULL, &print_NULL, &print_NULL, &print_NULL,
                                         &print_NULL, &print_NULL, &print_NULL, &print_NULL, &print_NULL, &print_NULL};
 
-std::vector<paje_event_t> buffer;
+std::vector<PajeEvent*> buffer;
+void buffer_debug(std::vector<PajeEvent*> *buf);
 
 void dump_comment (const char *comment)
 {
@@ -59,19 +63,19 @@ void TRACE_paje_dump_buffer (int force)
   if (!TRACE_is_enabled()) return;
   XBT_DEBUG("%s: dump until %f. starts", __FUNCTION__, TRACE_last_timestamp_to_dump);
   if (force){
-    for (auto event :buffer){
-      event->print (event);
-      event->free (event);
+    for (auto event : buffer){
+      event->print();
+      delete event;
     }
     buffer.clear();
   }else{
-    std::vector<paje_event_t>::iterator i = buffer.begin();
+    std::vector<PajeEvent*>::iterator i = buffer.begin();
     for (auto event :buffer){
       double head_timestamp = event->timestamp;
       if (head_timestamp > TRACE_last_timestamp_to_dump)
         break;
-      event->print (event);
-      event->free (event);
+      event->print();
+      delete event;
       ++i;
     }
     buffer.erase(buffer.begin(), i);
@@ -80,34 +84,44 @@ void TRACE_paje_dump_buffer (int force)
 }
 
 /* internal do the instrumentation module */
-static void insert_into_buffer (paje_event_t tbi)
+static void insert_into_buffer (PajeEvent* tbi)
 {
   if (TRACE_buffer() == 0){
-    tbi->print (tbi);
-    tbi->free (tbi);
+    tbi->print ();
+    delete tbi;
     return;
   }
+  buffer_debug(&buffer);
 
   XBT_DEBUG("%s: insert event_type=%d, timestamp=%f, buffersize=%zu)",
       __FUNCTION__, (int)tbi->event_type, tbi->timestamp, buffer.size());
-  std::vector<paje_event_t>::reverse_iterator i;
+  std::vector<PajeEvent*>::reverse_iterator i;
   for (i = buffer.rbegin(); i != buffer.rend(); ++i) {
-    paje_event_t e1 = *i;
+    PajeEvent* e1 = *i;
+    XBT_DEBUG("compare to %p is of type %d; timestamp:%f", e1,
+        (int)e1->event_type, e1->timestamp);
     if (e1->timestamp <= tbi->timestamp)
       break;
   }
   buffer.insert(i.base(), tbi);
   if (i == buffer.rend())
     XBT_DEBUG("%s: inserted at beginning", __FUNCTION__);
+  else if (i == buffer.rbegin())
+    XBT_DEBUG("%s: inserted at end", __FUNCTION__);
   else
-    XBT_DEBUG("%s: inserted at%s %zd", __FUNCTION__, (i == buffer.rbegin()) ? " end" :"pos =",
-        std::distance(buffer.rend(),i));
+    XBT_DEBUG("%s: inserted at pos= %zd from its end", __FUNCTION__,
+        std::distance(buffer.rbegin(),i));
+
+  buffer_debug(&buffer);
 }
 
-static void free_paje_event (paje_event_t event)
+PajeEvent:: ~PajeEvent()
 {
-  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
-  switch (event->event_type){
+  XBT_DEBUG("%s not implemented for %p: event_type=%d, timestamp=%f", __FUNCTION__,
+      this, (int)event_type, timestamp);
+//  xbt_backtrace_display_current();
+
+ /* switch (event->event_type){
   case PAJE_StartLink:
     xbt_free (((startLink_t)(event->data))->value);
     xbt_free (((startLink_t)(event->data))->key);
@@ -118,352 +132,270 @@ static void free_paje_event (paje_event_t event)
     break;
   default:
     break;
-  }
-  xbt_free (event->data);
-  xbt_free (event);
+  }*/
 }
 
-void new_pajeDefineContainerType(type_t type)
-{
-  paje_event_t event                           = xbt_new0(s_paje_event_t, 1);
-  event->event_type                            = PAJE_DefineContainerType;
-  event->timestamp                             = 0;
-  event->print                                 = active_writer.print_DefineContainerType;
-  event->free                                  = &free_paje_event;
-  event->data                                  = xbt_new0(s_defineContainerType_t, 1);
-  ((defineContainerType_t)(event->data))->type = type;
 
-  XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event->event_type);
+//--------------------------------------------------------
+
+DefineContainerEvent::DefineContainerEvent(type_t type)
+{
 
+  event_type                            = PAJE_DefineContainerType;
+  timestamp                             = 0;
+  this->type = type;
+  XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type);
   //print it
-  event->print (event);
-  event->free (event);
+  print ();
 }
 
-void new_pajeDefineVariableType(type_t type)
+
+DefineVariableTypeEvent::DefineVariableTypeEvent(type_t type)
 {
-  paje_event_t event                          = xbt_new0(s_paje_event_t, 1);
-  event->event_type                           = PAJE_DefineVariableType;
-  event->timestamp                            = 0;
-  event->print                                = active_writer.print_DefineVariableType;
-  event->free                                 = &free_paje_event;
-  event->data                                 = xbt_new0(s_defineVariableType_t, 1);
-  ((defineVariableType_t)(event->data))->type = type;
+  this->event_type                           = PAJE_DefineVariableType;
+  this->timestamp                            = 0;
+  this->type = type;
 
-  XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event->event_type);
+  XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type);
 
   //print it
-  event->print (event);
-  event->free (event);
+  print ();
 }
-
-void new_pajeDefineStateType(type_t type)
+// TODO convertir tt les constructeurs proprement.
+DefineStateTypeEvent::DefineStateTypeEvent(type_t type)
 {
-  paje_event_t event                       = xbt_new0(s_paje_event_t, 1);
-  event->event_type                        = PAJE_DefineStateType;
-  event->timestamp                         = 0;
-  event->print                             = active_writer.print_DefineStateType;
-  event->free                              = &free_paje_event;
-  event->data                              = xbt_new0(s_defineStateType_t, 1);
-  ((defineStateType_t)(event->data))->type = type;
+  this->event_type                        = PAJE_DefineStateType;
+  this->timestamp                         = 0;
+  this->type = type;
 
-  XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event->event_type);
+  XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type);
 
   //print it
-  event->print (event);
-  event->free (event);
+  print();
 }
 
-void new_pajeDefineEventType(type_t type)
+DefineEventTypeEvent::DefineEventTypeEvent(type_t type)
 {
-  paje_event_t event                       = xbt_new0(s_paje_event_t, 1);
-  event->event_type                        = PAJE_DefineEventType;
-  event->timestamp                         = 0;
-  event->print                             = active_writer.print_DefineEventType;
-  event->free                              = &free_paje_event;
-  event->data                              = xbt_new0(s_defineEventType_t, 1);
-  ((defineEventType_t)(event->data))->type = type;
+  this->event_type                        = PAJE_DefineEventType;
+  this->timestamp                         = 0;
+  this->type = type;
 
-  XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event->event_type);
+  XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type);
 
   //print it
-  event->print (event);
-  event->free (event);
+  print();
 }
 
-void new_pajeDefineLinkType(type_t type, type_t source, type_t dest)
+DefineLinkTypeEvent::DefineLinkTypeEvent(type_t type, type_t source, type_t dest)
 {
-  paje_event_t event                        = xbt_new0(s_paje_event_t, 1);
-  event->event_type                         = PAJE_DefineLinkType;
-  event->timestamp                          = 0;
-  event->print                              = active_writer.print_DefineLinkType;
-  event->free                               = &free_paje_event;
-  event->data                               = xbt_new0(s_defineLinkType_t, 1);
-  ((defineLinkType_t)(event->data))->type   = type;
-  ((defineLinkType_t)(event->data))->source = source;
-  ((defineLinkType_t)(event->data))->dest   = dest;
-
-  XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event->event_type);
+  this->event_type                         = PAJE_DefineLinkType;
+  this->timestamp                          = 0;
+  this->type   = type;
+  this->source = source;
+  this->dest   = dest;
+
+  XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type);
 
   //print it
-  event->print (event);
-  event->free (event);
+  print();
 }
 
-void new_pajeDefineEntityValue (val_t value)
+DefineEntityValueEvent::DefineEntityValueEvent (val_t value)
 {
-  paje_event_t event                          = xbt_new0(s_paje_event_t, 1);
-  event->event_type                           = PAJE_DefineEntityValue;
-  event->timestamp                            = 0;
-  event->print                                = active_writer.print_DefineEntityValue;
-  event->free                                 = &free_paje_event;
-  event->data                                 = xbt_new0(s_defineEntityValue_t, 1);
-  ((defineEntityValue_t)(event->data))->value = value;
+  this->event_type                           = PAJE_DefineEntityValue;
+  this->timestamp                            = 0;
+  this->value = value;
 
-  XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event->event_type);
+  XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type);
 
   //print it
-  event->print (event);
-  event->free (event);
+  print();
 }
 
-void new_pajeCreateContainer (container_t container)
+CreateContainerEvent::CreateContainerEvent (container_t container)
 {
-  paje_event_t event                            = xbt_new0(s_paje_event_t, 1);
-  event->event_type                             = PAJE_CreateContainer;
-  event->timestamp                              = SIMIX_get_clock();
-  event->print                                  = active_writer.print_CreateContainer;
-  event->free                                   = &free_paje_event;
-  event->data                                   = xbt_new0(s_createContainer_t, 1);
-  ((createContainer_t)(event->data))->container = container;
+  this->event_type                             = PAJE_CreateContainer;
+  this->timestamp                              = SIMIX_get_clock();
+  this->container = container;
 
-  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
+  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
 
   //print it
-  event->print (event);
-  event->free (event);
+  print();
 }
 
-void new_pajeDestroyContainer (container_t container)
+DestroyContainerEvent::DestroyContainerEvent (container_t container)
 {
-  paje_event_t event                             = xbt_new0(s_paje_event_t, 1);
-  event->event_type                              = PAJE_DestroyContainer;
-  event->timestamp                               = SIMIX_get_clock();
-  event->print                                   = active_writer.print_DestroyContainer;
-  event->free                                    = &free_paje_event;
-  event->data                                    = xbt_new0(s_destroyContainer_t, 1);
-  ((destroyContainer_t)(event->data))->container = container;
+  this->event_type                              = PAJE_DestroyContainer;
+  this->timestamp                               = SIMIX_get_clock();
+  this->container = container;
 
-  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
+  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
 
-  //print it
-  event->print (event);
-  event->free (event);
+  print();
 }
 
-void new_pajeSetVariable (double timestamp, container_t container, type_t type, double value)
+SetVariableEvent::SetVariableEvent (double timestamp, container_t container, type_t type, double value)
 {
-  paje_event_t event                        = xbt_new0(s_paje_event_t, 1);
-  event->event_type                         = PAJE_SetVariable;
-  event->timestamp                          = timestamp;
-  event->print                              = active_writer.print_SetVariable;
-  event->free                               = &free_paje_event;
-  event->data                               = xbt_new0(s_setVariable_t, 1);
-  ((setVariable_t)(event->data))->type      = type;
-  ((setVariable_t)(event->data))->container = container;
-  ((setVariable_t)(event->data))->value     = value;
-
-  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
-
-  insert_into_buffer (event);
-}
+  this->event_type                         = PAJE_SetVariable;
+  this->timestamp                          = timestamp;
+  this->type      = type;
+  this->container = container;
+  this->value     = value;
+
+  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
 
+  insert_into_buffer (this);
+}
 
-void new_pajeAddVariable (double timestamp, container_t container, type_t type, double value)
+AddVariableEvent::AddVariableEvent (double timestamp, container_t container, type_t type, double value)
 {
-  paje_event_t event                        = xbt_new0(s_paje_event_t, 1);
-  event->event_type                         = PAJE_AddVariable;
-  event->timestamp                          = timestamp;
-  event->print                              = active_writer.print_AddVariable;
-  event->free                               = &free_paje_event;
-  event->data                               = xbt_new0(s_addVariable_t, 1);
-  ((addVariable_t)(event->data))->type      = type;
-  ((addVariable_t)(event->data))->container = container;
-  ((addVariable_t)(event->data))->value     = value;
-
-  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
-
-  insert_into_buffer (event);
+  this->event_type                         = PAJE_AddVariable;
+  this->timestamp                          = timestamp;
+  this->type      = type;
+  this->container = container;
+  this->value     = value;
+
+  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
+
+  insert_into_buffer (this);
 }
 
-void new_pajeSubVariable (double timestamp, container_t container, type_t type, double value)
+SubVariableEvent::SubVariableEvent (double timestamp, container_t container, type_t type, double value)
 {
-  paje_event_t event                        = xbt_new0(s_paje_event_t, 1);
-  event->event_type                         = PAJE_SubVariable;
-  event->timestamp                          = timestamp;
-  event->print                              = active_writer.print_SubVariable;
-  event->free                               = &free_paje_event;
-  event->data                               = xbt_new0(s_subVariable_t, 1);
-  ((subVariable_t)(event->data))->type      = type;
-  ((subVariable_t)(event->data))->container = container;
-  ((subVariable_t)(event->data))->value     = value;
-
-  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
-
-  insert_into_buffer (event);
+  this->event_type                         = PAJE_SubVariable;
+  this->timestamp                          = timestamp;
+  this->type      = type;
+  this->container = container;
+  this->value     = value;
+
+  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
+
+  insert_into_buffer (this);
 }
 
-void new_pajeSetState (double timestamp, container_t container, type_t type, val_t value)
+SetStateEvent::SetStateEvent (double timestamp, container_t container, type_t type, val_t value)
 {
-  paje_event_t event                     = xbt_new0(s_paje_event_t, 1);
-  event->event_type                      = PAJE_SetState;
-  event->timestamp                       = timestamp;
-  event->print                           = active_writer.print_SetState;
-  event->free                            = &free_paje_event;
-  event->data                            = xbt_new0(s_setState_t, 1);
-  ((setState_t)(event->data))->type      = type;
-  ((setState_t)(event->data))->container = container;
-  ((setState_t)(event->data))->value     = value;
+  this->event_type                      = PAJE_SetState;
+  this->timestamp                       = timestamp;
+  this->type      = type;
+  this->container = container;
+  this->value     = value;
 
 #if HAVE_SMPI
   if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
     smpi_trace_call_location_t* loc = smpi_trace_get_call_location();
-    ((setState_t)(event->data))->filename   = loc->filename;
-    ((setState_t)(event->data))->linenumber = loc->linenumber;
+    filename   = loc->filename;
+    linenumber = loc->linenumber;
   }
 #endif
 
-  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
+  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
 
-  insert_into_buffer (event);
+  insert_into_buffer (this);
 }
 
 
-void new_pajePushStateWithExtra (double timestamp, container_t container, type_t type, val_t value, void* extra)
+PushStateEvent::PushStateEvent (double timestamp, container_t container, type_t type, val_t value, void* extra)
 {
-  paje_event_t event                 = xbt_new0(s_paje_event_t, 1);
-  event->event_type                  = PAJE_PushState;
-  event->timestamp                   = timestamp;
-  event->print                       = active_writer.print_PushState;
-  event->free                        = &free_paje_event;
-  event->data                        = xbt_new0(s_pushState_t, 1);
-  ((pushState_t)(event->data))->type = type;
-  ((pushState_t)(event->data))->container = container;
-  ((pushState_t)(event->data))->value     = value;
-  ((pushState_t)(event->data))->extra     = extra;
+  this->event_type                  = PAJE_PushState;
+  this->timestamp                   = timestamp;
+  this->type = type;
+  this->container = container;
+  this->value     = value;
+  this->extra     = extra;
 
 #if HAVE_SMPI
   if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
     smpi_trace_call_location_t* loc = smpi_trace_get_call_location();
-    ((pushState_t)(event->data))->filename   = loc->filename;
-    ((pushState_t)(event->data))->linenumber = loc->linenumber;
+    filename   = loc->filename;
+    linenumber = loc->linenumber;
   }
 #endif
 
-  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
+  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
 
-  insert_into_buffer (event);
+  insert_into_buffer (this);
 }
 
 
-void new_pajePushState (double timestamp, container_t container, type_t type, val_t value)
-{
-  new_pajePushStateWithExtra(timestamp, container, type, value, nullptr);
-}
+PushStateEvent::PushStateEvent (double timestamp, container_t container, type_t type, val_t value)
+ : PushStateEvent(timestamp, container, type, value, nullptr)
+{}
 
-void new_pajePopState (double timestamp, container_t container, type_t type)
+PopStateEvent::PopStateEvent (double timestamp, container_t container, type_t type)
 {
-  paje_event_t event                     = xbt_new0(s_paje_event_t, 1);
-  event->event_type                      = PAJE_PopState;
-  event->timestamp                       = timestamp;
-  event->print                           = active_writer.print_PopState;
-  event->free                            = &free_paje_event;
-  event->data                            = xbt_new0(s_popState_t, 1);
-  ((popState_t)(event->data))->type      = type;
-  ((popState_t)(event->data))->container = container;
-
-  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
-
-  insert_into_buffer (event);
-}
+  this->event_type                      = PAJE_PopState;
+  this->timestamp                       = timestamp;
+  this->type      = type;
+  this->container = container;
 
+  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
 
-void new_pajeResetState (double timestamp, container_t container, type_t type)
-{
-  paje_event_t event                       = xbt_new0(s_paje_event_t, 1);
-  event->event_type                        = PAJE_ResetState;
-  event->timestamp                         = timestamp;
-  event->print                             = active_writer.print_ResetState;
-  event->free                              = &free_paje_event;
-  event->data                              = xbt_new0(s_resetState_t, 1);
-  ((resetState_t)(event->data))->type      = type;
-  ((resetState_t)(event->data))->container = container;
-
-  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
-
-  insert_into_buffer (event);
+  insert_into_buffer (this);
 }
 
-void new_pajeStartLink (double timestamp, container_t container, type_t type, container_t sourceContainer,
-                        const char *value, const char *key)
+
+ResetStateEvent::ResetStateEvent (double timestamp, container_t container, type_t type)
 {
-  new_pajeStartLinkWithSize(timestamp, container, type, sourceContainer, value, key, -1);
+  this->event_type                        = PAJE_ResetState;
+  this->timestamp                         = timestamp;
+  this->type      = type;
+  this->container = container;
+
+  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
+
+  insert_into_buffer (this);
 }
 
-void new_pajeStartLinkWithSize (double timestamp, container_t container, type_t type, container_t sourceContainer,
+StartLinkEvent::StartLinkEvent (double timestamp, container_t container,
+    type_t type, container_t sourceContainer, const char *value, const char *key)
+  : StartLinkEvent(timestamp, container, type, sourceContainer, value, key, -1)
+{}
+
+StartLinkEvent::StartLinkEvent (double timestamp, container_t container, type_t type, container_t sourceContainer,
                                 const char *value, const char *key, int size)
 {
-  paje_event_t event                            = xbt_new0(s_paje_event_t, 1);
-  event->event_type                             = PAJE_StartLink;
-  event->timestamp                              = timestamp;
-  event->print                                  = active_writer.print_StartLink;
-  event->free                                   = &free_paje_event;
-  event->data                                   = xbt_new0(s_startLink_t, 1);
-  ((startLink_t)(event->data))->type            = type;
-  ((startLink_t)(event->data))->container       = container;
-  ((startLink_t)(event->data))->sourceContainer = sourceContainer;
-  ((startLink_t)(event->data))->value           = xbt_strdup(value);
-  ((startLink_t)(event->data))->key             = xbt_strdup(key);
-  ((startLink_t)(event->data))->size            = size;
-
-  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
-
-  insert_into_buffer (event);
+  event_type                             = PAJE_StartLink;
+  this->timestamp       = timestamp;
+  this->type            = type;
+  this->container       = container;
+  this->sourceContainer = sourceContainer;
+  this->value           = xbt_strdup(value);
+  this->key             = xbt_strdup(key);
+  this->size            = size;
+
+  XBT_DEBUG("%s: event_type=%d, timestamp=%f, value:%s", __FUNCTION__,
+      (int)event_type, this->timestamp, this->value);
+
+  insert_into_buffer (this);
 }
 
-void new_pajeEndLink (double timestamp, container_t container, type_t type, container_t destContainer,
+EndLinkEvent::EndLinkEvent (double timestamp, container_t container, type_t type, container_t destContainer,
                       const char *value, const char *key)
 {
-  paje_event_t event                        = xbt_new0(s_paje_event_t, 1);
-  event->event_type                         = PAJE_EndLink;
-  event->timestamp                          = timestamp;
-  event->print                              = active_writer.print_EndLink;
-  event->free                               = &free_paje_event;
-  event->data                               = xbt_new0(s_endLink_t, 1);
-  ((endLink_t)(event->data))->type          = type;
-  ((endLink_t)(event->data))->container     = container;
-  ((endLink_t)(event->data))->destContainer = destContainer;
-  ((endLink_t)(event->data))->value         = xbt_strdup(value);
-  ((endLink_t)(event->data))->key           = xbt_strdup(key);
-
-  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
-
-  insert_into_buffer (event);
+  this->event_type                         = PAJE_EndLink;
+  this->timestamp                          = timestamp;
+  this->type          = type;
+  this->container     = container;
+  this->destContainer = destContainer;
+  this->value         = xbt_strdup(value);
+  this->key           = xbt_strdup(key);
+
+  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
+
+  insert_into_buffer (this);
 }
 
-void new_pajeNewEvent (double timestamp, container_t container, type_t type, val_t value)
+NewEvent::NewEvent (double timestamp, container_t container, type_t type, val_t value)
 {
-  paje_event_t event                     = xbt_new0(s_paje_event_t, 1);
-  event->event_type                      = PAJE_NewEvent;
-  event->timestamp                       = timestamp;
-  event->print                           = active_writer.print_NewEvent;
-  event->free                            = &free_paje_event;
-  event->data                            = xbt_new0(s_newEvent_t, 1);
-  ((newEvent_t)(event->data))->type      = type;
-  ((newEvent_t)(event->data))->container = container;
-  ((newEvent_t)(event->data))->value     = value;
-
-  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
-
-  insert_into_buffer (event);
+  this->event_type                      = PAJE_NewEvent;
+  this->timestamp                       = timestamp;
+  this->type      = type;
+  this->container = container;
+  this->value     = value;
+
+  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
+
+  insert_into_buffer (this);
 }
index d200f1e..9d695b5 100644 (file)
@@ -38,7 +38,7 @@ void TRACE_msg_process_change_host(msg_process_t process, msg_host_t old_host, m
     //start link
     container_t msg = PJ_container_get (instr_process_id(process, str, len));
     type_t type = PJ_type_get ("MSG_PROCESS_LINK", PJ_type_get_root());
-    new_pajeStartLink (MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key);
+    new StartLinkEvent (MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key);
 
     //destroy existing container of this process
     TRACE_msg_process_destroy (MSG_process_get_name (process), MSG_process_get_PID (process));
@@ -49,7 +49,7 @@ void TRACE_msg_process_change_host(msg_process_t process, msg_host_t old_host, m
     //end link
     msg = PJ_container_get(instr_process_id(process, str, len));
     type = PJ_type_get ("MSG_PROCESS_LINK", PJ_type_get_root());
-    new_pajeEndLink (MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key);
+    new EndLinkEvent (MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key);
   }
 }
 
@@ -95,7 +95,7 @@ void TRACE_msg_process_suspend(msg_process_t process)
     container_t process_container = PJ_container_get (instr_process_id(process, str, len));
     type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type);
     val_t value = PJ_value_get ("suspend", type);
-    new_pajePushState (MSG_get_clock(), process_container, type, value);
+    new PushStateEvent (MSG_get_clock(), process_container, type, value);
   }
 }
 
@@ -107,7 +107,7 @@ void TRACE_msg_process_resume(msg_process_t process)
 
     container_t process_container = PJ_container_get (instr_process_id(process, str, len));
     type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type);
-    new_pajePopState (MSG_get_clock(), process_container, type);
+    new PopStateEvent (MSG_get_clock(), process_container, type);
   }
 }
 
@@ -120,7 +120,7 @@ void TRACE_msg_process_sleep_in(msg_process_t process)
     container_t process_container = PJ_container_get (instr_process_id(process, str, len));
     type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type);
     val_t value = PJ_value_get ("sleep", type);
-    new_pajePushState (MSG_get_clock(), process_container, type, value);
+    new PushStateEvent (MSG_get_clock(), process_container, type, value);
   }
 }
 
@@ -132,6 +132,6 @@ void TRACE_msg_process_sleep_out(msg_process_t process)
 
     container_t process_container = PJ_container_get (instr_process_id(process, str, len));
     type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type);
-    new_pajePopState (MSG_get_clock(), process_container, type);
+    new PopStateEvent (MSG_get_clock(), process_container, type);
   }
 }
index 65f32a6..65b69cc 100644 (file)
@@ -53,7 +53,7 @@ void TRACE_msg_task_execute_start(msg_task_t task)
     container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len));
     type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type);
     val_t value = PJ_value_get ("task_execute", type);
-    new_pajePushState (MSG_get_clock(), process_container, type, value);
+    new PushStateEvent (MSG_get_clock(), process_container, type, value);
   }
 }
 
@@ -67,7 +67,7 @@ void TRACE_msg_task_execute_end(msg_task_t task)
 
     container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len));
     type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type);
-    new_pajePopState (MSG_get_clock(), process_container, type);
+    new PopStateEvent (MSG_get_clock(), process_container, type);
   }
 }
 
@@ -93,7 +93,7 @@ void TRACE_msg_task_get_start()
     container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len));
     type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type);
     val_t value = PJ_value_get ("receive", type);
-    new_pajePushState (MSG_get_clock(), process_container, type, value);
+    new PushStateEvent (MSG_get_clock(), process_container, type, value);
   }
 }
 
@@ -107,12 +107,12 @@ void TRACE_msg_task_get_end(double start_time, msg_task_t task)
 
     container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len));
     type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type);
-    new_pajePopState (MSG_get_clock(), process_container, type);
+    new PopStateEvent (MSG_get_clock(), process_container, type);
 
     char key[INSTR_DEFAULT_STR_SIZE];
     snprintf (key, INSTR_DEFAULT_STR_SIZE, "p%lld", task->counter);
     type = PJ_type_get ("MSG_PROCESS_TASK_LINK", PJ_type_get_root());
-    new_pajeEndLink(MSG_get_clock(), PJ_container_get_root(), type, process_container, "SR", key);
+    new EndLinkEvent(MSG_get_clock(), PJ_container_get_root(), type, process_container, "SR", key);
   }
 }
 
@@ -128,12 +128,12 @@ int TRACE_msg_task_put_start(msg_task_t task)
     container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len));
     type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type);
     val_t value = PJ_value_get ("send", type);
-    new_pajePushState (MSG_get_clock(), process_container, type, value);
+    new PushStateEvent (MSG_get_clock(), process_container, type, value);
 
     char key[INSTR_DEFAULT_STR_SIZE];
     snprintf (key, INSTR_DEFAULT_STR_SIZE, "p%lld", task->counter);
     type = PJ_type_get ("MSG_PROCESS_TASK_LINK", PJ_type_get_root());
-    new_pajeStartLink(MSG_get_clock(), PJ_container_get_root(), type, process_container, "SR", key);
+    new StartLinkEvent(MSG_get_clock(), PJ_container_get_root(), type, process_container, "SR", key);
   }
 
   return 1;
@@ -149,6 +149,6 @@ void TRACE_msg_task_put_end()
 
     container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len));
     type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type);
-    new_pajePopState (MSG_get_clock(), process_container, type);
+    new PopStateEvent (MSG_get_clock(), process_container, type);
   }
 }
index 837268e..c166b5f 100644 (file)
@@ -208,7 +208,7 @@ void MSG_vm_start(msg_vm_t vm)
     container_t vm_container = PJ_container_get(vm->cname());
     type_t type              = PJ_type_get("MSG_VM_STATE", vm_container->type);
     val_t value              = PJ_value_get_or_new("start", "0 0 1", type); // start is blue
-    new_pajePushState(MSG_get_clock(), vm_container, type, value);
+    new PushStateEvent(MSG_get_clock(), vm_container, type, value);
   }
 }
 
@@ -320,7 +320,7 @@ static int migration_rx_fun(int argc, char *argv[])
     // start link
     container_t msg = PJ_container_get(vm->cname());
     type_t type     = PJ_type_get("MSG_VM_LINK", PJ_type_get_root());
-    new_pajeStartLink(MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key);
+    new StartLinkEvent(MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key);
 
     // destroy existing container of this vm
     container_t existing_container = PJ_container_get(vm->cname());
@@ -333,7 +333,7 @@ static int migration_rx_fun(int argc, char *argv[])
     // end link
     msg  = PJ_container_get(vm->cname());
     type = PJ_type_get("MSG_VM_LINK", PJ_type_get_root());
-    new_pajeEndLink(MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key);
+    new EndLinkEvent(MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key);
   }
 
   // Inform the SRC that the migration has been correctly performed
@@ -824,7 +824,7 @@ void MSG_vm_suspend(msg_vm_t vm)
     container_t vm_container = PJ_container_get(vm->cname());
     type_t type              = PJ_type_get("MSG_VM_STATE", vm_container->type);
     val_t value              = PJ_value_get_or_new("suspend", "1 0 0", type); // suspend is red
-    new_pajePushState(MSG_get_clock(), vm_container, type, value);
+    new PushStateEvent(MSG_get_clock(), vm_container, type, value);
   }
 }
 
@@ -840,7 +840,7 @@ void MSG_vm_resume(msg_vm_t vm)
   if (TRACE_msg_vm_is_enabled()) {
     container_t vm_container = PJ_container_get(vm->cname());
     type_t type              = PJ_type_get("MSG_VM_STATE", vm_container->type);
-    new_pajePopState(MSG_get_clock(), vm_container, type);
+    new PopStateEvent(MSG_get_clock(), vm_container, type);
   }
 }
 
index f1ac9eb..aece1eb 100644 (file)
@@ -20,7 +20,7 @@
          char cont_name[25];\
          snprintf(cont_name,25, "rank-%d", smpi_process()->index());\
          val_t value = PJ_value_get_or_new(Colls::mpi_coll_##cat##_description[i].name,"1.0 1.0 1.0", type);\
-         new_pajeNewEvent (SIMIX_get_clock(), PJ_container_get(cont_name), type, value);\
+         new NewEvent (SIMIX_get_clock(), PJ_container_get(cont_name), type, value);\
       }
 
 #define AUTOMATIC_COLL_BENCH(cat, ret, args, args2)\
index 900d1a1..921bab8 100644 (file)
@@ -246,7 +246,7 @@ void TRACE_smpi_collective_in(int rank, int root, const char *operation, instr_e
   type_t type = PJ_type_get ("MPI_STATE", container->type);
   const char *color = instr_find_color (operation);
   val_t value = PJ_value_get_or_new (operation, color, type);
-   new_pajePushStateWithExtra (SIMIX_get_clock(), container, type, value, static_cast<void*>(extra));
+  new PushStateEvent (SIMIX_get_clock(), container, type, value, static_cast<void*>(extra));
 }
 
 void TRACE_smpi_collective_out(int rank, int root, const char *operation)
@@ -259,7 +259,7 @@ void TRACE_smpi_collective_out(int rank, int root, const char *operation)
   container_t container = PJ_container_get (str);
   type_t type = PJ_type_get ("MPI_STATE", container->type);
 
-  new_pajePopState (SIMIX_get_clock(), container, type);
+  new PopStateEvent (SIMIX_get_clock(), container, type);
 }
 
 void TRACE_smpi_computing_init(int rank)
@@ -274,7 +274,7 @@ void TRACE_smpi_computing_init(int rank)
   type_t type = PJ_type_get ("MPI_STATE", container->type);
   const char *color = instr_find_color ("computing");
   val_t value = PJ_value_get_or_new ("computing", color, type);
-  new_pajePushState (SIMIX_get_clock(), container, type, value);
+  new PushStateEvent (SIMIX_get_clock(), container, type, value);
 }
 
 void TRACE_smpi_computing_in(int rank, instr_extra_data extra)
@@ -290,7 +290,7 @@ void TRACE_smpi_computing_in(int rank, instr_extra_data extra)
   container_t container = PJ_container_get (str);
   type_t type = PJ_type_get ("MPI_STATE", container->type);
   val_t value = PJ_value_get_or_new ("computing", nullptr, type);
-  new_pajePushStateWithExtra  (SIMIX_get_clock(), container, type, value, static_cast<void*>(extra));
+  new PushStateEvent  (SIMIX_get_clock(), container, type, value, static_cast<void*>(extra));
 }
 
 void TRACE_smpi_computing_out(int rank)
@@ -301,7 +301,7 @@ void TRACE_smpi_computing_out(int rank)
   smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
   container_t container = PJ_container_get (str);
   type_t type = PJ_type_get ("MPI_STATE", container->type);
-  new_pajePopState (SIMIX_get_clock(), container, type);
+  new PopStateEvent (SIMIX_get_clock(), container, type);
 }
 
 void TRACE_smpi_sleeping_init(int rank)
@@ -316,7 +316,7 @@ void TRACE_smpi_sleeping_init(int rank)
   type_t type = PJ_type_get ("MPI_STATE", container->type);
   const char *color = instr_find_color ("sleeping");
   val_t value = PJ_value_get_or_new ("sleeping", color, type);
-  new_pajePushState (SIMIX_get_clock(), container, type, value);
+  new PushStateEvent (SIMIX_get_clock(), container, type, value);
 }
 
 void TRACE_smpi_sleeping_in(int rank, instr_extra_data extra)
@@ -332,7 +332,7 @@ void TRACE_smpi_sleeping_in(int rank, instr_extra_data extra)
   container_t container = PJ_container_get (str);
   type_t type = PJ_type_get ("MPI_STATE", container->type);
   val_t value = PJ_value_get_or_new ("sleeping", nullptr, type);
-  new_pajePushStateWithExtra  (SIMIX_get_clock(), container, type, value, static_cast<void*>(extra));
+  new PushStateEvent  (SIMIX_get_clock(), container, type, value, static_cast<void*>(extra));
 }
 
 void TRACE_smpi_sleeping_out(int rank)
@@ -343,7 +343,7 @@ void TRACE_smpi_sleeping_out(int rank)
   smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
   container_t container = PJ_container_get (str);
   type_t type = PJ_type_get ("MPI_STATE", container->type);
-  new_pajePopState (SIMIX_get_clock(), container, type);
+  new PopStateEvent (SIMIX_get_clock(), container, type);
 }
 
 void TRACE_smpi_testing_in(int rank, instr_extra_data extra)
@@ -359,7 +359,7 @@ void TRACE_smpi_testing_in(int rank, instr_extra_data extra)
   container_t container = PJ_container_get (str);
   type_t type = PJ_type_get ("MPI_STATE", container->type);
   val_t value = PJ_value_get_or_new ("test", nullptr, type);
-  new_pajePushStateWithExtra  (SIMIX_get_clock(), container, type, value, static_cast<void*>(extra));
+  new PushStateEvent  (SIMIX_get_clock(), container, type, value, static_cast<void*>(extra));
 }
 
 void TRACE_smpi_testing_out(int rank)
@@ -370,7 +370,7 @@ void TRACE_smpi_testing_out(int rank)
   smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
   container_t container = PJ_container_get (str);
   type_t type = PJ_type_get ("MPI_STATE", container->type);
-  new_pajePopState (SIMIX_get_clock(), container, type);
+  new PopStateEvent (SIMIX_get_clock(), container, type);
 }
 
 void TRACE_smpi_ptp_in(int rank, int src, int dst, const char *operation, instr_extra_data extra)
@@ -386,7 +386,7 @@ void TRACE_smpi_ptp_in(int rank, int src, int dst, const char *operation, instr_
   type_t type = PJ_type_get ("MPI_STATE", container->type);
   const char *color = instr_find_color (operation);
   val_t value = PJ_value_get_or_new (operation, color, type);
-  new_pajePushStateWithExtra (SIMIX_get_clock(), container, type, value, static_cast<void*>(extra));
+  new PushStateEvent (SIMIX_get_clock(), container, type, value, static_cast<void*>(extra));
 }
 
 void TRACE_smpi_ptp_out(int rank, int src, int dst, const char *operation)
@@ -399,7 +399,7 @@ void TRACE_smpi_ptp_out(int rank, int src, int dst, const char *operation)
   container_t container = PJ_container_get (str);
   type_t type = PJ_type_get ("MPI_STATE", container->type);
 
-  new_pajePopState (SIMIX_get_clock(), container, type);
+  new PopStateEvent (SIMIX_get_clock(), container, type);
 }
 
 void TRACE_smpi_send(int rank, int src, int dst, int tag, int size)
@@ -415,7 +415,7 @@ void TRACE_smpi_send(int rank, int src, int dst, int tag, int size)
   container_t container = PJ_container_get (str);
   type_t type = PJ_type_get ("MPI_LINK", PJ_type_get_root());
   XBT_DEBUG("Send tracing from %d to %d, tag %d, with key %s", src, dst, tag, key);
-  new_pajeStartLinkWithSize (SIMIX_get_clock(), PJ_container_get_root(), type, container, "PTP", key, size);
+  new StartLinkEvent (SIMIX_get_clock(), PJ_container_get_root(), type, container, "PTP", key, size);
 }
 
 void TRACE_smpi_recv(int rank, int src, int dst, int tag)
@@ -431,5 +431,5 @@ void TRACE_smpi_recv(int rank, int src, int dst, int tag)
   container_t container = PJ_container_get (str);
   type_t type = PJ_type_get ("MPI_LINK", PJ_type_get_root());
   XBT_DEBUG("Recv tracing from %d to %d, tag %d, with key %s", src, dst, tag, key);
-  new_pajeEndLink (SIMIX_get_clock(), PJ_container_get_root(), type, container, "PTP", key);
+  new EndLinkEvent (SIMIX_get_clock(), PJ_container_get_root(), type, container, "PTP", key);
 }
index 6c4a484..0cac861 100644 (file)
@@ -119,8 +119,8 @@ static void linkContainers (container_t src, container_t dst, xbt_dict_t filter)
   snprintf (key, INSTR_DEFAULT_STR_SIZE, "%lld", counter);
   counter++;
 
-  new_pajeStartLink(SIMIX_get_clock(), father, link_type, src, "topology", key);
-  new_pajeEndLink(SIMIX_get_clock(), father, link_type, dst, "topology", key);
+  new StartLinkEvent(SIMIX_get_clock(), father, link_type, src, "topology", key);
+  new EndLinkEvent(SIMIX_get_clock(), father, link_type, dst, "topology", key);
 
   XBT_DEBUG ("  linkContainers %s <-> %s", src->name, dst->name);
 }
@@ -222,8 +222,8 @@ static void instr_routing_parse_start_link(simgrid::s4u::Link& link)
     if (latency == nullptr) {
       latency = PJ_type_variable_new("latency", nullptr, container->type);
     }
-    new_pajeSetVariable(0, container, bandwidth, bandwidth_value);
-    new_pajeSetVariable(0, container, latency, latency_value);
+    new SetVariableEvent(0, container, bandwidth, bandwidth_value);
+    new SetVariableEvent(0, container, latency, latency_value);
   }
   if (TRACE_uncategorized()) {
     type_t bandwidth_used = PJ_type_get_or_null("bandwidth_used", container->type);
@@ -245,7 +245,7 @@ void sg_instr_new_host(simgrid::s4u::Host& host)
     }
 
     double current_speed_state = host.speed();
-    new_pajeSetVariable (0, container, speed, current_speed_state);
+    new SetVariableEvent (0, container, speed, current_speed_state);
   }
   if (TRACE_uncategorized()){
     type_t speed_used = PJ_type_get_or_null ("power_used", container->type);
index a21da8a..801036a 100644 (file)
@@ -24,7 +24,7 @@ void TRACE_surf_host_set_speed(double date, const char *resource, double speed)
   if (TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) {
     container_t container = PJ_container_get(resource);
     type_t type = PJ_type_get ("power", container->type);
-    new_pajeSetVariable(date, container, type, speed);
+    new SetVariableEvent(date, container, type, speed);
   }
 }
 
@@ -33,7 +33,7 @@ void TRACE_surf_link_set_bandwidth(double date, const char *resource, double ban
   if (TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) {
     container_t container = PJ_container_get(resource);
     type_t type = PJ_type_get ("bandwidth", container->type);
-    new_pajeSetVariable(date, container, type, bandwidth);
+    new SetVariableEvent(date, container, type, bandwidth);
   }
 }