git-svn-id: http://ltt.polymtl.ca/svn@224 04897980-b3bd-0310-b5e0-8ef037075253
authoryangxx <yangxx@04897980-b3bd-0310-b5e0-8ef037075253>
Tue, 9 Sep 2003 12:57:12 +0000 (12:57 +0000)
committeryangxx <yangxx@04897980-b3bd-0310-b5e0-8ef037075253>
Tue, 9 Sep 2003 12:57:12 +0000 (12:57 +0000)
ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.c
ltt/branches/poly/lttv/modules/gui/mainWin/src/init_module.c

index 65ef18b7bee81a932a1a868d193489c0a6c3c4e6..53a2770fe43f2fbca4a0b8c3174bb297adda6329 100644 (file)
 #include <lttv/toolbar.h>
 
 extern systemView * gSysView;
+extern LttvTracesetContext * gTracesetContext;
+
+/** Array containing instanced objects. */
+extern GSList * Main_Window_List;
 
 mainWindow * get_window_data_struct(GtkWidget * widget);
 
@@ -186,6 +190,10 @@ void createNewWindow(GtkWidget* widget, gpointer user_data, gboolean clone)
   }  
     
   newMWindow = g_new(mainWindow, 1);
+
+  /* Add the object's information to the module's array */
+  Main_Window_List = g_slist_append(Main_Window_List, mw);
+
   newWindow  = create_MWindow();
   gtk_widget_show (newWindow);
   
@@ -204,7 +212,10 @@ void createNewWindow(GtkWidget* widget, gpointer user_data, gboolean clone)
   newMWindow->Tab = NULL;
   newMWindow->CurrentTab = NULL;
   newMWindow->SystemView = newSv;
-  //  newMWindow->Attributes = LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE, NULL));
+  newMWindow->Attributes = LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE, NULL));
+  newMWindow->traceset_context = LTTV_TRACESET_CONTEXT(gTracesetContext);
+  newMWindow->traceset = (LTTV_TRACESET_CONTEXT(gTracesetContext))->ts;
+  g_object_ref(gTracesetContext);
 
   //test yxx
   g_assert(lttv_iattribute_find_by_path(attributes,
@@ -370,12 +381,31 @@ on_tab_activate                        (GtkMenuItem     *menuitem,
   tmpTab = mwData->Tab;
   while(tmpTab && tmpTab->Next) tmpTab = tmpTab->Next;
   if(!tmpTab){
+    mwData->CurrentTab = NULL;
     tmpTab = g_new(tab,1);
-    mwData->Tab = tmpTab;
+    tmpTab->traceStartTime.tv_sec  = 0;
+    tmpTab->traceStartTime.tv_nsec = 0;
+    tmpTab->traceEndTime.tv_sec    = G_MAXULONG;
+    tmpTab->traceEndTime.tv_nsec   = G_MAXULONG;
+    tmpTab->startTime.tv_sec       = 0;
+    tmpTab->startTime.tv_nsec      = 0;
+    tmpTab->endTime.tv_sec         = G_MAXULONG;
+    tmpTab->endTime.tv_nsec        = G_MAXULONG;
+    tmpTab->currentTime.tv_sec     = 0;
+    tmpTab->currentTime.tv_nsec    = 0;
+    mwData->Tab = tmpTab;    
   }else{
     tmpTab->Next = g_new(tab,1);
     tmpTab = tmpTab->Next;
   }
+  if(mwData->CurrentTab){
+    tmpTab->traceStartTime = mwData->CurrentTab->traceStartTime;
+    tmpTab->traceEndTime   = mwData->CurrentTab->traceEndTime;
+    tmpTab->startTime      = mwData->CurrentTab->startTime;
+    tmpTab->endTime        = mwData->CurrentTab->endTime;
+    tmpTab->currentTime    = mwData->CurrentTab->currentTime;
+  }
+  tmpTab->Attributes = LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE, NULL));
   //  mwData->CurrentTab = tmpTab;
   tmpTab->custom = (GtkCustom*)gtk_custom_new();
   gtk_widget_show((GtkWidget*)tmpTab->custom);
index 8ab4f5a30f56bae05ec00314188bbd7f16e8ccbf..d72ac56cacc464ef8250c1fcfb380ee54ab314ed 100644 (file)
@@ -14,6 +14,8 @@
 #include <lttv/hook.h>
 #include <lttv/option.h>
 #include <lttv/module.h>
+#include <lttv/processTrace.h>
+#include <lttv/state.h>
 #include <lttv/menu.h>
 #include <lttv/toolbar.h>
 
 /* global variable */
 systemView * gSysView;
 
-static LttvHooks
-       *main_hooks;
+LttvTracesetState * gTracesetContext = NULL;
+static LttvTraceset * traceset;
 
+/** Array containing instanced objects. */
+GSList * Main_Window_List = NULL ;
+
+static LttvHooks 
+  *before_traceset,
+  *after_traceset,
+  *before_trace,
+  *after_trace,
+  *before_tracefile,
+  *after_tracefile,
+  *before_event,
+  *after_event,
+  *main_hooks;
+
+static char *a_trace;
+
+void lttv_trace_option(void *hook_data)
+{ 
+  LttTrace *trace;
+
+  trace = ltt_trace_open(a_trace);
+  if(trace == NULL) g_critical("cannot open trace %s", a_trace);
+  lttv_traceset_add(traceset, trace);
+}
 
 /*****************************************************************************
  *                 Functions for module loading/unloading                    *
@@ -43,7 +69,6 @@ typedef struct _WindowCreationData {
        char ** argv;
 } WindowCreationData;
 
-
 static gboolean Window_Creation_Hook(void *hook_data, void *call_data)
 {
   int i;
@@ -60,9 +85,12 @@ static gboolean Window_Creation_Hook(void *hook_data, void *call_data)
   GtkWidget *window1;
   mainWindow * mw = g_new(mainWindow, 1);
   gSysView = g_new(systemView, 1);
-       WindowCreationData *Window_Creation_Data = (WindowCreationData*)call_data;
+  WindowCreationData *Window_Creation_Data = (WindowCreationData*)call_data;
+
+  /* Add the object's information to the module's array */
+  Main_Window_List = g_slist_append(Main_Window_List, mw);
 
-       g_critical("GUI init()");
+  g_critical("GUI init()");
 #ifdef ENABLE_NLS
   bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
   bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
@@ -88,7 +116,15 @@ static gboolean Window_Creation_Hook(void *hook_data, void *call_data)
   mw->SystemView = gSysView;
   mw->Tab = NULL;
   mw->CurrentTab = NULL;
-  //  mw->Attributes = lttv_attributes_new();
+  mw->Attributes = LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE, NULL));
+  if(!gTracesetContext){
+    gTracesetContext = g_object_new(LTTV_TRACESET_STATE_TYPE, NULL);
+    //FIXME: lttv_context_fini should be called some where.
+    lttv_context_init(LTTV_TRACESET_CONTEXT(gTracesetContext), traceset);
+  }
+  mw->traceset_context = LTTV_TRACESET_CONTEXT(gTracesetContext);
+  mw->traceset = (LTTV_TRACESET_CONTEXT(gTracesetContext))->ts;
+  g_object_ref(gTracesetContext);
 
   //test
   g_assert(lttv_iattribute_find_by_path(attributes,
@@ -146,7 +182,7 @@ static gboolean Window_Creation_Hook(void *hook_data, void *call_data)
 
   gtk_main ();
 
-       return FALSE;
+  return FALSE;
 }
 
 
@@ -154,21 +190,60 @@ static gboolean Window_Creation_Hook(void *hook_data, void *call_data)
 
 G_MODULE_EXPORT void init(LttvModule *self, int argc, char *argv[]) {
 
-       LttvAttributeValue value;
-       WindowCreationData *Window_Creation_Data = g_new(WindowCreationData, 1);
-       
-       LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes());
-
-       Window_Creation_Data->argc = argc;
-       Window_Creation_Data->argv = argv;
-       
-       g_assert(lttv_iattribute_find_by_path(
-                               attributes,
-                               "hooks/main/before",    LTTV_POINTER, &value));
-       
-       g_assert((main_hooks = *(value.v_pointer)) != NULL);
-
-       lttv_hooks_add(main_hooks, Window_Creation_Hook, Window_Creation_Data);
+  LttvAttributeValue value;
+  WindowCreationData *Window_Creation_Data = g_new(WindowCreationData, 1);
+  
+  LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes());
+  
+  lttv_option_add("trace", 't', 
+      "add a trace to the trace set to analyse", 
+      "pathname of the directory containing the trace", 
+      LTTV_OPT_STRING, &a_trace, lttv_trace_option, NULL);
+
+  traceset = lttv_traceset_new();
+
+  before_traceset = lttv_hooks_new();
+  after_traceset = lttv_hooks_new();
+  before_trace = lttv_hooks_new();
+  after_trace = lttv_hooks_new();
+  before_tracefile = lttv_hooks_new();
+  after_tracefile = lttv_hooks_new();
+  before_event = lttv_hooks_new();
+  after_event = lttv_hooks_new();
+
+  g_assert(lttv_iattribute_find_by_path(attributes, "hooks/traceset/before",
+      LTTV_POINTER, &value));
+  *(value.v_pointer) = before_traceset;
+  g_assert(lttv_iattribute_find_by_path(attributes, "hooks/traceset/after",
+      LTTV_POINTER, &value));
+  *(value.v_pointer) = after_traceset;
+  g_assert(lttv_iattribute_find_by_path(attributes, "hooks/trace/before",
+      LTTV_POINTER, &value));
+  *(value.v_pointer) = before_trace;
+  g_assert(lttv_iattribute_find_by_path(attributes, "hooks/trace/after",
+      LTTV_POINTER, &value));
+  *(value.v_pointer) = after_trace;
+  g_assert(lttv_iattribute_find_by_path(attributes, "hooks/tracefile/before",
+      LTTV_POINTER, &value));
+  *(value.v_pointer) = before_tracefile;
+  g_assert(lttv_iattribute_find_by_path(attributes, "hooks/tracefile/after",
+      LTTV_POINTER, &value));
+  *(value.v_pointer) = after_tracefile;
+  g_assert(lttv_iattribute_find_by_path(attributes, "hooks/event/before",
+      LTTV_POINTER, &value));
+  *(value.v_pointer) = before_event;
+  g_assert(lttv_iattribute_find_by_path(attributes, "hooks/event/after",
+      LTTV_POINTER, &value));
+  *(value.v_pointer) = after_event;
+
+  g_assert(lttv_iattribute_find_by_path(attributes, "hooks/main/before",
+      LTTV_POINTER, &value));
+  g_assert((main_hooks = *(value.v_pointer)) != NULL);
+
+  Window_Creation_Data->argc = argc;
+  Window_Creation_Data->argv = argv;
+  
+  lttv_hooks_add(main_hooks, Window_Creation_Hook, Window_Creation_Data);
 
 }
 
@@ -187,25 +262,46 @@ void destroy_walk(gpointer data, gpointer user_data)
  */
 G_MODULE_EXPORT void destroy() {
 
-       WindowCreationData *Window_Creation_Data;
-       LttvAttributeValue value;
+  WindowCreationData *Window_Creation_Data;
+  LttvAttributeValue value;
+
+  guint i, nb;
+
+  lttv_option_remove("trace");
+
+  lttv_hooks_destroy(before_traceset);
+  lttv_hooks_destroy(after_traceset);
+  lttv_hooks_destroy(before_trace);
+  lttv_hooks_destroy(after_trace);
+  lttv_hooks_destroy(before_tracefile);
+  lttv_hooks_destroy(after_tracefile);
+  lttv_hooks_destroy(before_event);
+  lttv_hooks_destroy(after_event);
+  lttv_hooks_remove_data(main_hooks, Window_Creation_Hook, NULL);
+
+  nb = lttv_traceset_number(traceset);
+  for(i = 0 ; i < nb ; i++) {
+    ltt_trace_close(lttv_traceset_get(traceset, i));
+  }
+
+  lttv_traceset_destroy(traceset); 
 
-       g_critical("GUI destroy()");
-       //int i;
+  g_critical("GUI destroy()");
 
-       //ControlFlowData *Control_Flow_Data;
-       
 
-       //g_slist_foreach(sControl_Flow_Data_List, destroy_walk, NULL );
 
-       lttv_iattribute_find_by_path(LTTV_IATTRIBUTE(lttv_global_attributes()),
-                       "/hooks/main/before",   LTTV_POINTER, &value);
+  //ControlFlowData *Control_Flow_Data;
+  
 
-       //      Window_Creation_Data = lttv_hooks_remove(*(value.v_pointer),                                                                                                     Window_Creation_Hook);
-      
-       g_free(Window_Creation_Data);
+  g_slist_foreach(Main_Window_List, destroy_walk, NULL );
+  
+  
+  //lttv_hooks_remove_data(main_hooks,Window_Creation_Hook, NULL);
+  //lttv_hooks_remove_data(before_traceset, get_traceset_context, NULL);
 
+  //  g_free(Window_Creation_Data);
 
+  g_object_unref(gTracesetContext);
 }
 
 
This page took 0.032439 seconds and 4 git commands to generate.