1 /*! \file gtkTraceSet.h
2 * \brief API used by the graphical viewers to interact with their top window.
4 * Main window (gui module) is the place to contain and display viewers.
5 * Viewers (lttv plugins) interacte with main window through this API and
7 * This header file should be included in each graphic module.
8 * This library is used by graphical modules to interact with the
13 #include <lttv/common.h>
15 #include <lttv/lttv.h>
16 #include <lttv/mainWindow.h>
17 #include <lttv/gtkTraceSet.h>
18 #include <lttv/processTrace.h>
19 #include <lttv/toolbar.h>
20 #include <lttv/menu.h>
21 #include <lttv/state.h>
22 #include <lttv/stats.h>
26 * Internal function parts
30 * Function to set/update traceset for the viewers
31 * @param main_win main window
32 * @param traceset traceset of the main window.
35 void SetTraceset(mainWindow
* main_win
, gpointer traceset
)
38 LttvAttributeValue value
;
40 g_assert(lttv_iattribute_find_by_path(main_win
->Attributes
,
41 "hooks/updatetraceset", LTTV_POINTER
, &value
));
42 tmp
= (LttvHooks
*)*(value
.v_pointer
);
43 if(tmp
== NULL
)return;
44 lttv_hooks_call(tmp
,traceset
);
49 * Function to set/update filter for the viewers
50 * @param main_win main window
51 * @param filter filter of the main window.
54 void SetFilter(mainWindow
* main_win
, gpointer filter
)
57 LttvAttributeValue value
;
59 g_assert(lttv_iattribute_find_by_path(main_win
->Attributes
,
60 "hooks/updatefilter", LTTV_POINTER
, &value
));
61 tmp
= (LttvHooks
*)*(value
.v_pointer
);
63 if(tmp
== NULL
)return;
64 lttv_hooks_call(tmp
,filter
);
74 * Function to register a view constructor so that main window can generate
75 * a toolbar item for the viewer in order to generate a new instance easily.
76 * It will be called by init function of the module.
77 * @param ButtonPixmap image shown on the toolbar item.
78 * @param tooltip tooltip of the toolbar item.
79 * @param view_constructor constructor of the viewer.
82 void ToolbarItemReg(char ** pixmap
, char *tooltip
, lttv_constructor view_constructor
)
84 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
85 LttvToolbars
* toolbar
;
86 LttvAttributeValue value
;
88 g_assert(lttv_iattribute_find_by_path(attributes_global
,
89 "viewers/toolbar", LTTV_POINTER
, &value
));
90 toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
93 toolbar
= lttv_toolbars_new();
94 *(value
.v_pointer
) = toolbar
;
96 lttv_toolbars_add(toolbar
, view_constructor
, tooltip
, pixmap
);
101 * Function to unregister the viewer's constructor, release the space
102 * occupied by pixmap, tooltip and constructor of the viewer.
103 * It will be called when a module is unloaded.
104 * @param view_constructor constructor of the viewer which is used as
105 * a reference to find out where the pixmap and tooltip are.
108 void ToolbarItemUnreg(lttv_constructor view_constructor
)
110 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
111 LttvToolbars
* toolbar
;
112 LttvAttributeValue value
;
114 g_assert(lttv_iattribute_find_by_path(attributes_global
,
115 "viewers/toolbar", LTTV_POINTER
, &value
));
116 toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
118 main_window_remove_toolbar_item(view_constructor
);
120 lttv_toolbars_remove(toolbar
, view_constructor
);
125 * Function to register a view constructor so that main window can generate
126 * a menu item for the viewer in order to generate a new instance easily.
127 * It will be called by init function of the module.
128 * @param menu_path path of the menu item.
129 * @param menu_text text of the menu item.
130 * @param view_constructor constructor of the viewer.
133 void MenuItemReg(char *menu_path
, char *menu_text
, lttv_constructor view_constructor
)
135 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
137 LttvAttributeValue value
;
139 g_assert(lttv_iattribute_find_by_path(attributes_global
,
140 "viewers/menu", LTTV_POINTER
, &value
));
141 menu
= (LttvMenus
*)*(value
.v_pointer
);
144 menu
= lttv_menus_new();
145 *(value
.v_pointer
) = menu
;
147 lttv_menus_add(menu
, view_constructor
, menu_path
, menu_text
);
151 * Function to unregister the viewer's constructor, release the space
152 * occupied by menu_path, menu_text and constructor of the viewer.
153 * It will be called when a module is unloaded.
154 * @param view_constructor constructor of the viewer which is used as
155 * a reference to find out where the menu_path and menu_text are.
158 void MenuItemUnreg(lttv_constructor view_constructor
)
160 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
162 LttvAttributeValue value
;
164 g_assert(lttv_iattribute_find_by_path(attributes_global
,
165 "viewers/menu", LTTV_POINTER
, &value
));
166 menu
= (LttvMenus
*)*(value
.v_pointer
);
168 main_window_remove_menu_item(view_constructor
);
170 lttv_menus_remove(menu
, view_constructor
);
175 * Update the status bar whenever something changed in the viewer.
176 * @param main_win the main window the viewer belongs to.
177 * @param info the message which will be shown in the status bar.
180 void UpdateStatus(mainWindow
*main_win
, char *info
)
186 * Function to get the current time interval shown on the current tab.
187 * It will be called by a viewer's hook function to update the
188 * shown time interval of the viewer and also be called by the constructor
190 * @param main_win the main window the viewer belongs to.
191 * @param time_interval a pointer where time interval will be stored.
194 void GetTimeWindow(mainWindow
*main_win
, TimeWindow
*Time_Window
)
196 //Time_Window->startTime = main_win->CurrentTab->Time_Window.startTime;
197 //Time_Window->Time_Width = main_win->CurrentTab->Time_Window.Time_Width;
198 *Time_Window
= main_win
->CurrentTab
->Time_Window
;
202 * Function to get the current time interval of the current traceset.
203 * It will be called by a viewer's hook function to update the
204 * time interval of the viewer and also be called by the constructor
206 * @param main_win the main window the viewer belongs to.
207 * @param time_interval a pointer where time interval will be stored.
210 void getTracesetTimeSpan(mainWindow
*main_win
, TimeInterval
*Time_Interval
)
212 //Time_Window->startTime = main_win->CurrentTab->Time_Window.startTime;
213 //Time_Window->Time_Width = main_win->CurrentTab->Time_Window.Time_Width;
214 *Time_Interval
= *(LTTV_TRACESET_CONTEXT(main_win
->Traceset_Info
->TracesetContext
)->Time_Span
);
220 * Function to set the time interval of the current tab.
221 * It will be called by a viewer's signal handle associated with
222 * the move_slider signal
223 * @param main_win the main window the viewer belongs to.
224 * @param time_interval a pointer where time interval is stored.
227 void SetTimeWindow(mainWindow
*main_win
, TimeWindow
*Time_Window
)
229 LttvAttributeValue value
;
231 main_win
->CurrentTab
->Time_Window
= *Time_Window
;
232 g_assert(lttv_iattribute_find_by_path(main_win
->CurrentTab
->Attributes
,
233 "hooks/updatetimewindow", LTTV_POINTER
, &value
));
234 tmp
= (LttvHooks
*)*(value
.v_pointer
);
235 if(tmp
== NULL
) return;
236 lttv_hooks_call(tmp
, Time_Window
);
241 * Function to get the current time/event of the current tab.
242 * It will be called by a viewer's hook function to update the
243 * current time/event of the viewer.
244 * @param main_win the main window the viewer belongs to.
245 * @param time a pointer where time will be stored.
248 void GetCurrentTime(mainWindow
*main_win
, LttTime
*time
)
250 time
= &main_win
->CurrentTab
->currentTime
;
255 * Function to set the current time/event of the current tab.
256 * It will be called by a viewer's signal handle associated with
257 * the button-release-event signal
258 * @param main_win the main window the viewer belongs to.
259 * @param time a pointer where time is stored.
262 void SetCurrentTime(mainWindow
*main_win
, LttTime
*time
)
264 LttvAttributeValue value
;
266 main_win
->CurrentTab
->currentTime
= *time
;
267 g_assert(lttv_iattribute_find_by_path(main_win
->CurrentTab
->Attributes
,
268 "hooks/updatecurrenttime", LTTV_POINTER
, &value
));
269 tmp
= (LttvHooks
*)*(value
.v_pointer
);
271 if(tmp
== NULL
)return;
272 lttv_hooks_call(tmp
, time
);
277 * Function to get the traceset from the current tab.
278 * It will be called by the constructor of the viewer and also be
279 * called by a hook funtion of the viewer to update its traceset.
280 * @param main_win the main window the viewer belongs to.
281 * @param traceset a pointer to a traceset.
284 void GetTraceset(mainWindow *main_win, Traceset *traceset)
290 * Function to get the filter of the current tab.
291 * It will be called by the constructor of the viewer and also be
292 * called by a hook funtion of the viewer to update its filter.
293 * @param main_win, the main window the viewer belongs to.
294 * @param filter, a pointer to a filter.
297 void GetFilter(mainWindow *main_win, Filter *filter)
303 * Function to register a hook function for a viewer to set/update its
305 * It will be called by the constructor of the viewer.
306 * @param hook hook function of the viewer.
307 * @param hook_data hook data associated with the hook function.
308 * @param main_win the main window the viewer belongs to.
311 void RegUpdateTimeWindow(LttvHook hook
, gpointer hook_data
,
312 mainWindow
* main_win
)
314 LttvAttributeValue value
;
316 g_assert(lttv_iattribute_find_by_path(main_win
->CurrentTab
->Attributes
,
317 "hooks/updatetimewindow", LTTV_POINTER
, &value
));
318 tmp
= (LttvHooks
*)*(value
.v_pointer
);
320 tmp
= lttv_hooks_new();
321 *(value
.v_pointer
) = tmp
;
323 lttv_hooks_add(tmp
, hook
,hook_data
);
328 * Function to unregister a viewer's hook function which is used to
329 * set/update the time interval of the viewer.
330 * It will be called by the destructor of the viewer.
331 * @param hook hook function of the viewer.
332 * @param hook_data hook data associated with the hook function.
333 * @param main_win the main window the viewer belongs to.
336 void UnregUpdateTimeWindow(LttvHook hook
, gpointer hook_data
,
337 mainWindow
* main_win
)
339 LttvAttributeValue value
;
341 g_assert(lttv_iattribute_find_by_path(main_win
->CurrentTab
->Attributes
,
342 "hooks/updatetimewindow", LTTV_POINTER
, &value
));
343 tmp
= (LttvHooks
*)*(value
.v_pointer
);
344 if(tmp
== NULL
) return;
345 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
350 * Function to register a hook function for a viewer to set/update its
352 * It will be called by the constructor of the viewer.
353 * @param hook hook function of the viewer.
354 * @param hook_data hook data associated with the hook function.
355 * @param main_win the main window the viewer belongs to.
358 void RegUpdateTraceset(LttvHook hook
, gpointer hook_data
,
359 mainWindow
* main_win
)
361 LttvAttributeValue value
;
363 g_assert(lttv_iattribute_find_by_path(main_win
->Attributes
,
364 "hooks/updatetraceset", LTTV_POINTER
, &value
));
365 tmp
= (LttvHooks
*)*(value
.v_pointer
);
367 tmp
= lttv_hooks_new();
368 *(value
.v_pointer
) = tmp
;
370 lttv_hooks_add(tmp
, hook
, hook_data
);
375 * Function to unregister a viewer's hook function which is used to
376 * set/update the traceset of the viewer.
377 * It will be called by the destructor of the viewer.
378 * @param hook hook function of the viewer.
379 * @param hook_data hook data associated with the hook function.
380 * @param main_win the main window the viewer belongs to.
383 void UnregUpdateTraceset(LttvHook hook
, gpointer hook_data
,
384 mainWindow
* main_win
)
386 LttvAttributeValue value
;
388 g_assert(lttv_iattribute_find_by_path(main_win
->Attributes
,
389 "hooks/updatetraceset", LTTV_POINTER
, &value
));
390 tmp
= (LttvHooks
*)*(value
.v_pointer
);
391 if(tmp
== NULL
) return;
392 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
397 * Function to register a hook function for a viewer to set/update its
399 * It will be called by the constructor of the viewer.
400 * @param hook hook function of the viewer.
401 * @param hook_data hook data associated with the hook function.
402 * @param main_win the main window the viewer belongs to.
405 void RegUpdateFilter(LttvHook hook
, gpointer hook_data
,
406 mainWindow
*main_win
)
408 LttvAttributeValue value
;
410 g_assert(lttv_iattribute_find_by_path(main_win
->Attributes
,
411 "hooks/updatefilter", LTTV_POINTER
, &value
));
412 tmp
= (LttvHooks
*)*(value
.v_pointer
);
414 tmp
= lttv_hooks_new();
415 *(value
.v_pointer
) = tmp
;
417 lttv_hooks_add(tmp
, hook
, hook_data
);
422 * Function to unregister a viewer's hook function which is used to
423 * set/update the filter of the viewer.
424 * It will be called by the destructor of the viewer.
425 * @param hook hook function of the viewer.
426 * @param hook_data hook data associated with the hook function.
427 * @param main_win the main window the viewer belongs to.
430 void UnregUpdateFilter(LttvHook hook
, gpointer hook_data
,
431 mainWindow
* main_win
)
433 LttvAttributeValue value
;
435 g_assert(lttv_iattribute_find_by_path(main_win
->Attributes
,
436 "hooks/updatefilter", LTTV_POINTER
, &value
));
437 tmp
= (LttvHooks
*)*(value
.v_pointer
);
438 if(tmp
== NULL
) return;
439 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
444 * Function to register a hook function for a viewer to set/update its
446 * It will be called by the constructor of the viewer.
447 * @param hook hook function of the viewer.
448 * @param hook_data hook data associated with the hook function.
449 * @param main_win the main window the viewer belongs to.
452 void RegUpdateCurrentTime(LttvHook hook
, gpointer hook_data
,
453 mainWindow
*main_win
)
455 LttvAttributeValue value
;
457 g_assert(lttv_iattribute_find_by_path(main_win
->CurrentTab
->Attributes
,
458 "hooks/updatecurrenttime", LTTV_POINTER
, &value
));
459 tmp
= (LttvHooks
*)*(value
.v_pointer
);
461 tmp
= lttv_hooks_new();
462 *(value
.v_pointer
) = tmp
;
464 lttv_hooks_add(tmp
, hook
, hook_data
);
469 * Function to unregister a viewer's hook function which is used to
470 * set/update the current time of the viewer.
471 * It will be called by the destructor of the viewer.
472 * @param hook hook function of the viewer.
473 * @param hook_data hook data associated with the hook function.
474 * @param main_win the main window the viewer belongs to.
477 void UnregUpdateCurrentTime(LttvHook hook
, gpointer hook_data
,
478 mainWindow
* main_win
)
480 LttvAttributeValue value
;
482 g_assert(lttv_iattribute_find_by_path(main_win
->CurrentTab
->Attributes
,
483 "hooks/updatecurrenttime", LTTV_POINTER
, &value
));
484 tmp
= (LttvHooks
*)*(value
.v_pointer
);
485 if(tmp
== NULL
) return;
486 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
491 * Function to set the focused pane (viewer).
492 * It will be called by a viewer's signal handle associated with
493 * the grab_focus signal
494 * @param main_win the main window the viewer belongs to.
495 * @param paned a pointer to a pane where the viewer is contained.
498 void SetFocusedPane(mainWindow
*main_win
, gpointer paned
)
500 gtk_custom_set_focus((GtkWidget
*)main_win
->CurrentTab
->custom
,paned
);
505 * Function to register a hook function for a viewer to set/update the
506 * dividor of the hpane.
507 * It will be called by the constructor of the viewer.
508 * @param hook hook function of the viewer.
509 * @param hook_data hook data associated with the hook function.
510 * @param main_win the main window the viewer belongs to.
513 void RegUpdateDividor(LttvHook hook
, gpointer hook_data
,
514 mainWindow
*main_win
)
516 LttvAttributeValue value
;
518 g_assert(lttv_iattribute_find_by_path(main_win
->CurrentTab
->Attributes
,
519 "hooks/hpanedividor", LTTV_POINTER
, &value
));
520 tmp
= (LttvHooks
*)*(value
.v_pointer
);
522 tmp
= lttv_hooks_new();
523 *(value
.v_pointer
) = tmp
;
525 lttv_hooks_add(tmp
, hook
, hook_data
);
530 * Function to unregister a viewer's hook function which is used to
531 * set/update hpane's dividor of the viewer.
532 * It will be called by the destructor of the viewer.
533 * @param hook hook function of the viewer.
534 * @param hook_data hook data associated with the hook function.
535 * @param main_win the main window the viewer belongs to.
538 void UnregUpdateDividor(LttvHook hook
, gpointer hook_data
,
539 mainWindow
*main_win
)
541 LttvAttributeValue value
;
543 g_assert(lttv_iattribute_find_by_path(main_win
->CurrentTab
->Attributes
,
544 "hooks/hpanedividor", LTTV_POINTER
, &value
));
545 tmp
= (LttvHooks
*)*(value
.v_pointer
);
546 if(tmp
== NULL
) return;
547 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
552 * Function to set the position of the hpane's dividor (viewer).
553 * It will be called by a viewer's signal handle associated with
554 * the motion_notify_event event/signal
555 * @param main_win the main window the viewer belongs to.
556 * @param position position of the hpane's dividor.
559 void SetHPaneDividor(mainWindow
*main_win
, gint position
)
561 LttvAttributeValue value
;
563 g_assert(lttv_iattribute_find_by_path(main_win
->CurrentTab
->Attributes
,
564 "hooks/hpanedividor", LTTV_POINTER
, &value
));
565 tmp
= (LttvHooks
*)*(value
.v_pointer
);
566 if(tmp
== NULL
) return;
567 lttv_hooks_call(tmp
, &position
);
572 * Function to process traceset. It will call lttv_process_trace,
573 * each view will call this api to get events.
574 * @param main_win the main window the viewer belongs to.
575 * @param start the start time of the first event to be processed.
576 * @param end the end time of the last event to be processed.
579 void processTraceset(mainWindow
*main_win
, LttTime start
,
580 LttTime end
, unsigned maxNumEvents
)
582 lttv_process_traceset_seek_time(main_win
->Traceset_Info
->TracesetContext
, start
);
583 lttv_process_traceset(main_win
->Traceset_Info
->TracesetContext
, end
, maxNumEvents
);
587 * Function to add hooks into the context of a traceset,
588 * before reading events from traceset, viewer will call this api to
590 * @param main_win the main window the viewer belongs to.
591 * @param LttvHooks hooks to be registered.
594 void contextAddHooks(mainWindow
*main_win
,
595 LttvHooks
*before_traceset
,
596 LttvHooks
*after_traceset
,
597 LttvHooks
*check_trace
,
598 LttvHooks
*before_trace
,
599 LttvHooks
*after_trace
,
600 LttvHooks
*check_tracefile
,
601 LttvHooks
*before_tracefile
,
602 LttvHooks
*after_tracefile
,
603 LttvHooks
*check_event
,
604 LttvHooks
*before_event
,
605 LttvHooks
*after_event
)
607 LttvTracesetContext
* tsc
=
608 LTTV_TRACESET_CONTEXT(main_win
->Traceset_Info
->TracesetContext
);
609 lttv_traceset_context_add_hooks(tsc
,before_traceset
,after_traceset
,
610 check_trace
,before_trace
,after_trace
,
611 check_tracefile
,before_tracefile
,after_tracefile
,
612 check_event
,before_event
, after_event
);
617 * Function to remove hooks from the context of a traceset,
618 * before reading events from traceset, viewer will call this api to
620 * @param main_win the main window the viewer belongs to.
621 * @param LttvHooks hooks to be registered.
624 void contextRemoveHooks(mainWindow
*main_win
,
625 LttvHooks
*before_traceset
,
626 LttvHooks
*after_traceset
,
627 LttvHooks
*check_trace
,
628 LttvHooks
*before_trace
,
629 LttvHooks
*after_trace
,
630 LttvHooks
*check_tracefile
,
631 LttvHooks
*before_tracefile
,
632 LttvHooks
*after_tracefile
,
633 LttvHooks
*check_event
,
634 LttvHooks
*before_event
,
635 LttvHooks
*after_event
)
637 LttvTracesetContext
* tsc
=
638 LTTV_TRACESET_CONTEXT(main_win
->Traceset_Info
->TracesetContext
);
639 lttv_traceset_context_remove_hooks(tsc
,before_traceset
,after_traceset
,
640 check_trace
,before_trace
,after_trace
,
641 check_tracefile
,before_tracefile
,after_tracefile
,
642 check_event
,before_event
, after_event
);
647 * Function to add/remove event hooks for state
648 * @param main_win the main window the viewer belongs to.
651 void stateAddEventHooks(mainWindow
*main_win
)
653 lttv_state_add_event_hooks(
654 (LttvTracesetState
*)main_win
->Traceset_Info
->TracesetContext
);
657 void stateRemoveEventHooks(mainWindow
*main_win
)
659 lttv_state_remove_event_hooks(
660 (LttvTracesetState
*)main_win
->Traceset_Info
->TracesetContext
);
665 * Function to add/remove event hooks for stats
666 * @param main_win the main window the viewer belongs to.
669 void statsAddEventHooks(mainWindow
*main_win
)
671 lttv_stats_add_event_hooks(
672 (LttvTracesetStats
*)main_win
->Traceset_Info
->TracesetContext
);
675 void statsRemoveEventHooks(mainWindow
*main_win
)
677 lttv_stats_remove_event_hooks(
678 (LttvTracesetStats
*)main_win
->Traceset_Info
->TracesetContext
);
682 * Function to get the stats of the traceset
683 * @param main_win the main window the viewer belongs to.
686 LttvTracesetStats
* getTracesetStats(mainWindow
*main_win
)
688 return main_win
->Traceset_Info
->TracesetContext
;