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 remove toolbar from the GUI
31 * @param view_constructor constructor of the viewer.
34 void RemoveToolbar(lttv_constructor view_constructor
)
36 g_printf("Toolbar for the viewer will be removed\n");
40 * Function to remove menu entry from the GUI
41 * @param view_constructor constructor of the viewer.
44 void RemoveMenu(lttv_constructor view_constructor
)
46 g_printf("Menu entry for the viewer will be removed\n");
51 * Function to set/update traceset for the viewers
52 * @param main_win main window
53 * @param traceset traceset of the main window.
56 void SetTraceset(mainWindow
* main_win
, gpointer traceset
)
59 LttvAttributeValue value
;
61 g_assert(lttv_iattribute_find_by_path(main_win
->Attributes
,
62 "hooks/updatetraceset", LTTV_POINTER
, &value
));
63 tmp
= (LttvHooks
*)*(value
.v_pointer
);
64 if(tmp
== NULL
)return;
65 lttv_hooks_call(tmp
,traceset
);
70 * Function to set/update filter for the viewers
71 * @param main_win main window
72 * @param filter filter of the main window.
75 void SetFilter(mainWindow
* main_win
, gpointer filter
)
78 LttvAttributeValue value
;
80 g_assert(lttv_iattribute_find_by_path(main_win
->Attributes
,
81 "hooks/updatefilter", LTTV_POINTER
, &value
));
82 tmp
= (LttvHooks
*)*(value
.v_pointer
);
84 if(tmp
== NULL
)return;
85 lttv_hooks_call(tmp
,filter
);
95 * Function to register a view constructor so that main window can generate
96 * a toolbar item for the viewer in order to generate a new instance easily.
97 * It will be called by init function of the module.
98 * @param ButtonPixmap image shown on the toolbar item.
99 * @param tooltip tooltip of the toolbar item.
100 * @param view_constructor constructor of the viewer.
103 void ToolbarItemReg(char ** pixmap
, char *tooltip
, lttv_constructor view_constructor
)
105 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
106 LttvToolbars
* toolbar
;
107 LttvAttributeValue value
;
109 g_assert(lttv_iattribute_find_by_path(attributes_global
,
110 "viewers/toolbar", LTTV_POINTER
, &value
));
111 toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
114 toolbar
= lttv_toolbars_new();
115 *(value
.v_pointer
) = toolbar
;
117 lttv_toolbars_add(toolbar
, view_constructor
, tooltip
, pixmap
);
122 * Function to unregister the viewer's constructor, release the space
123 * occupied by pixmap, tooltip and constructor of the viewer.
124 * It will be called when a module is unloaded.
125 * @param view_constructor constructor of the viewer which is used as
126 * a reference to find out where the pixmap and tooltip are.
129 void ToolbarItemUnreg(lttv_constructor view_constructor
)
131 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
132 LttvToolbars
* toolbar
;
133 LttvAttributeValue value
;
135 g_assert(lttv_iattribute_find_by_path(attributes_global
,
136 "viewers/toolbar", LTTV_POINTER
, &value
));
137 toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
139 if(lttv_toolbars_remove(toolbar
, view_constructor
))
140 RemoveToolbar(view_constructor
);
145 * Function to register a view constructor so that main window can generate
146 * a menu item for the viewer in order to generate a new instance easily.
147 * It will be called by init function of the module.
148 * @param menu_path path of the menu item.
149 * @param menu_text text of the menu item.
150 * @param view_constructor constructor of the viewer.
153 void MenuItemReg(char *menu_path
, char *menu_text
, lttv_constructor view_constructor
)
155 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
157 LttvAttributeValue value
;
159 g_assert(lttv_iattribute_find_by_path(attributes_global
,
160 "viewers/menu", LTTV_POINTER
, &value
));
161 menu
= (LttvMenus
*)*(value
.v_pointer
);
164 menu
= lttv_menus_new();
165 *(value
.v_pointer
) = menu
;
167 lttv_menus_add(menu
, view_constructor
, menu_path
, menu_text
);
171 * Function to unregister the viewer's constructor, release the space
172 * occupied by menu_path, menu_text and constructor of the viewer.
173 * It will be called when a module is unloaded.
174 * @param view_constructor constructor of the viewer which is used as
175 * a reference to find out where the menu_path and menu_text are.
178 void MenuItemUnreg(lttv_constructor view_constructor
)
180 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
182 LttvAttributeValue value
;
184 g_assert(lttv_iattribute_find_by_path(attributes_global
,
185 "viewers/menu", LTTV_POINTER
, &value
));
186 menu
= (LttvMenus
*)*(value
.v_pointer
);
188 if(lttv_menus_remove(menu
, view_constructor
))
189 RemoveMenu(view_constructor
);
194 * Update the status bar whenever something changed in the viewer.
195 * @param main_win the main window the viewer belongs to.
196 * @param info the message which will be shown in the status bar.
199 void UpdateStatus(mainWindow
*main_win
, char *info
)
205 * Function to get the current time interval shown on the current tab.
206 * It will be called by a viewer's hook function to update the
207 * shown time interval of the viewer and also be called by the constructor
209 * @param main_win the main window the viewer belongs to.
210 * @param time_interval a pointer where time interval will be stored.
213 void GetTimeWindow(mainWindow
*main_win
, TimeWindow
*Time_Window
)
215 //Time_Window->startTime = main_win->CurrentTab->Time_Window.startTime;
216 //Time_Window->Time_Width = main_win->CurrentTab->Time_Window.Time_Width;
217 *Time_Window
= main_win
->CurrentTab
->Time_Window
;
221 * Function to get the current time interval of the current traceset.
222 * It will be called by a viewer's hook function to update the
223 * time interval of the viewer and also be called by the constructor
225 * @param main_win the main window the viewer belongs to.
226 * @param time_interval a pointer where time interval will be stored.
229 void getTracesetTimeSpan(mainWindow
*main_win
, TimeInterval
*Time_Interval
)
231 //Time_Window->startTime = main_win->CurrentTab->Time_Window.startTime;
232 //Time_Window->Time_Width = main_win->CurrentTab->Time_Window.Time_Width;
233 *Time_Interval
= *(LTTV_TRACESET_CONTEXT(main_win
->Traceset_Info
->TracesetContext
)->Time_Span
);
239 * Function to set the time interval of the current tab.
240 * It will be called by a viewer's signal handle associated with
241 * the move_slider signal
242 * @param main_win the main window the viewer belongs to.
243 * @param time_interval a pointer where time interval is stored.
246 void SetTimeWindow(mainWindow
*main_win
, TimeWindow
*Time_Window
)
248 LttvAttributeValue value
;
250 main_win
->CurrentTab
->Time_Window
= *Time_Window
;
251 g_assert(lttv_iattribute_find_by_path(main_win
->CurrentTab
->Attributes
,
252 "hooks/updatetimewindow", LTTV_POINTER
, &value
));
253 tmp
= (LttvHooks
*)*(value
.v_pointer
);
254 if(tmp
== NULL
) return;
255 lttv_hooks_call(tmp
, Time_Window
);
260 * Function to get the current time/event of the current tab.
261 * It will be called by a viewer's hook function to update the
262 * current time/event of the viewer.
263 * @param main_win the main window the viewer belongs to.
264 * @param time a pointer where time will be stored.
267 void GetCurrentTime(mainWindow
*main_win
, LttTime
*time
)
269 time
= &main_win
->CurrentTab
->currentTime
;
274 * Function to set the current time/event of the current tab.
275 * It will be called by a viewer's signal handle associated with
276 * the button-release-event signal
277 * @param main_win the main window the viewer belongs to.
278 * @param time a pointer where time is stored.
281 void SetCurrentTime(mainWindow
*main_win
, LttTime
*time
)
283 LttvAttributeValue value
;
285 main_win
->CurrentTab
->currentTime
= *time
;
286 g_assert(lttv_iattribute_find_by_path(main_win
->CurrentTab
->Attributes
,
287 "hooks/updatecurrenttime", LTTV_POINTER
, &value
));
288 tmp
= (LttvHooks
*)*(value
.v_pointer
);
290 if(tmp
== NULL
)return;
291 lttv_hooks_call(tmp
, time
);
296 * Function to get the traceset from the current tab.
297 * It will be called by the constructor of the viewer and also be
298 * called by a hook funtion of the viewer to update its traceset.
299 * @param main_win the main window the viewer belongs to.
300 * @param traceset a pointer to a traceset.
303 void GetTraceset(mainWindow *main_win, Traceset *traceset)
309 * Function to get the filter of the current tab.
310 * It will be called by the constructor of the viewer and also be
311 * called by a hook funtion of the viewer to update its filter.
312 * @param main_win, the main window the viewer belongs to.
313 * @param filter, a pointer to a filter.
316 void GetFilter(mainWindow *main_win, Filter *filter)
322 * Function to register a hook function for a viewer to set/update its
324 * It will be called by the constructor of the viewer.
325 * @param hook hook function of the viewer.
326 * @param hook_data hook data associated with the hook function.
327 * @param main_win the main window the viewer belongs to.
330 void RegUpdateTimeWindow(LttvHook hook
, gpointer hook_data
,
331 mainWindow
* main_win
)
333 LttvAttributeValue value
;
335 g_assert(lttv_iattribute_find_by_path(main_win
->CurrentTab
->Attributes
,
336 "hooks/updatetimewindow", LTTV_POINTER
, &value
));
337 tmp
= (LttvHooks
*)*(value
.v_pointer
);
339 tmp
= lttv_hooks_new();
340 *(value
.v_pointer
) = tmp
;
342 lttv_hooks_add(tmp
, hook
,hook_data
);
347 * Function to unregister a viewer's hook function which is used to
348 * set/update the time interval of the viewer.
349 * It will be called by the destructor of the viewer.
350 * @param hook hook function of the viewer.
351 * @param hook_data hook data associated with the hook function.
352 * @param main_win the main window the viewer belongs to.
355 void UnregUpdateTimeWindow(LttvHook hook
, gpointer hook_data
,
356 mainWindow
* main_win
)
358 LttvAttributeValue value
;
360 g_assert(lttv_iattribute_find_by_path(main_win
->CurrentTab
->Attributes
,
361 "hooks/updatetimewindow", LTTV_POINTER
, &value
));
362 tmp
= (LttvHooks
*)*(value
.v_pointer
);
363 if(tmp
== NULL
) return;
364 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
369 * Function to register a hook function for a viewer to set/update its
371 * It will be called by the constructor of the viewer.
372 * @param hook hook function of the viewer.
373 * @param hook_data hook data associated with the hook function.
374 * @param main_win the main window the viewer belongs to.
377 void RegUpdateTraceset(LttvHook hook
, gpointer hook_data
,
378 mainWindow
* main_win
)
380 LttvAttributeValue value
;
382 g_assert(lttv_iattribute_find_by_path(main_win
->Attributes
,
383 "hooks/updatetraceset", LTTV_POINTER
, &value
));
384 tmp
= (LttvHooks
*)*(value
.v_pointer
);
386 tmp
= lttv_hooks_new();
387 *(value
.v_pointer
) = tmp
;
389 lttv_hooks_add(tmp
, hook
, hook_data
);
394 * Function to unregister a viewer's hook function which is used to
395 * set/update the traceset of the viewer.
396 * It will be called by the destructor of the viewer.
397 * @param hook hook function of the viewer.
398 * @param hook_data hook data associated with the hook function.
399 * @param main_win the main window the viewer belongs to.
402 void UnregUpdateTraceset(LttvHook hook
, gpointer hook_data
,
403 mainWindow
* main_win
)
405 LttvAttributeValue value
;
407 g_assert(lttv_iattribute_find_by_path(main_win
->Attributes
,
408 "hooks/updatetraceset", LTTV_POINTER
, &value
));
409 tmp
= (LttvHooks
*)*(value
.v_pointer
);
410 if(tmp
== NULL
) return;
411 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
416 * Function to register a hook function for a viewer to set/update its
418 * It will be called by the constructor of the viewer.
419 * @param hook hook function of the viewer.
420 * @param hook_data hook data associated with the hook function.
421 * @param main_win the main window the viewer belongs to.
424 void RegUpdateFilter(LttvHook hook
, gpointer hook_data
,
425 mainWindow
*main_win
)
427 LttvAttributeValue value
;
429 g_assert(lttv_iattribute_find_by_path(main_win
->Attributes
,
430 "hooks/updatefilter", LTTV_POINTER
, &value
));
431 tmp
= (LttvHooks
*)*(value
.v_pointer
);
433 tmp
= lttv_hooks_new();
434 *(value
.v_pointer
) = tmp
;
436 lttv_hooks_add(tmp
, hook
, hook_data
);
441 * Function to unregister a viewer's hook function which is used to
442 * set/update the filter of the viewer.
443 * It will be called by the destructor of the viewer.
444 * @param hook hook function of the viewer.
445 * @param hook_data hook data associated with the hook function.
446 * @param main_win the main window the viewer belongs to.
449 void UnregUpdateFilter(LttvHook hook
, gpointer hook_data
,
450 mainWindow
* main_win
)
452 LttvAttributeValue value
;
454 g_assert(lttv_iattribute_find_by_path(main_win
->Attributes
,
455 "hooks/updatefilter", LTTV_POINTER
, &value
));
456 tmp
= (LttvHooks
*)*(value
.v_pointer
);
457 if(tmp
== NULL
) return;
458 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
463 * Function to register a hook function for a viewer to set/update its
465 * It will be called by the constructor of the viewer.
466 * @param hook hook function of the viewer.
467 * @param hook_data hook data associated with the hook function.
468 * @param main_win the main window the viewer belongs to.
471 void RegUpdateCurrentTime(LttvHook hook
, gpointer hook_data
,
472 mainWindow
*main_win
)
474 LttvAttributeValue value
;
476 g_assert(lttv_iattribute_find_by_path(main_win
->CurrentTab
->Attributes
,
477 "hooks/updatecurrenttime", LTTV_POINTER
, &value
));
478 tmp
= (LttvHooks
*)*(value
.v_pointer
);
480 tmp
= lttv_hooks_new();
481 *(value
.v_pointer
) = tmp
;
483 lttv_hooks_add(tmp
, hook
, hook_data
);
488 * Function to unregister a viewer's hook function which is used to
489 * set/update the current time of the viewer.
490 * It will be called by the destructor of the viewer.
491 * @param hook hook function of the viewer.
492 * @param hook_data hook data associated with the hook function.
493 * @param main_win the main window the viewer belongs to.
496 void UnregUpdateCurrentTime(LttvHook hook
, gpointer hook_data
,
497 mainWindow
* main_win
)
499 LttvAttributeValue value
;
501 g_assert(lttv_iattribute_find_by_path(main_win
->CurrentTab
->Attributes
,
502 "hooks/updatecurrenttime", LTTV_POINTER
, &value
));
503 tmp
= (LttvHooks
*)*(value
.v_pointer
);
504 if(tmp
== NULL
) return;
505 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
510 * Function to set the focused pane (viewer).
511 * It will be called by a viewer's signal handle associated with
512 * the grab_focus signal
513 * @param main_win the main window the viewer belongs to.
514 * @param paned a pointer to a pane where the viewer is contained.
517 void SetFocusedPane(mainWindow
*main_win
, gpointer paned
)
519 gtk_custom_set_focus((GtkWidget
*)main_win
->CurrentTab
->custom
,paned
);
524 * Function to register a hook function for a viewer to set/update the
525 * dividor of the hpane.
526 * It will be called by the constructor of the viewer.
527 * @param hook hook function of the viewer.
528 * @param hook_data hook data associated with the hook function.
529 * @param main_win the main window the viewer belongs to.
532 void RegUpdateDividor(LttvHook hook
, gpointer hook_data
,
533 mainWindow
*main_win
)
535 LttvAttributeValue value
;
537 g_assert(lttv_iattribute_find_by_path(main_win
->CurrentTab
->Attributes
,
538 "hooks/hpanedividor", LTTV_POINTER
, &value
));
539 tmp
= (LttvHooks
*)*(value
.v_pointer
);
541 tmp
= lttv_hooks_new();
542 *(value
.v_pointer
) = tmp
;
544 lttv_hooks_add(tmp
, hook
, hook_data
);
549 * Function to unregister a viewer's hook function which is used to
550 * set/update hpane's dividor of the viewer.
551 * It will be called by the destructor of the viewer.
552 * @param hook hook function of the viewer.
553 * @param hook_data hook data associated with the hook function.
554 * @param main_win the main window the viewer belongs to.
557 void UnregUpdateDividor(LttvHook hook
, gpointer hook_data
,
558 mainWindow
*main_win
)
560 LttvAttributeValue value
;
562 g_assert(lttv_iattribute_find_by_path(main_win
->CurrentTab
->Attributes
,
563 "hooks/hpanedividor", LTTV_POINTER
, &value
));
564 tmp
= (LttvHooks
*)*(value
.v_pointer
);
565 if(tmp
== NULL
) return;
566 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
571 * Function to set the position of the hpane's dividor (viewer).
572 * It will be called by a viewer's signal handle associated with
573 * the motion_notify_event event/signal
574 * @param main_win the main window the viewer belongs to.
575 * @param position position of the hpane's dividor.
578 void SetHPaneDividor(mainWindow
*main_win
, gint position
)
580 LttvAttributeValue value
;
582 g_assert(lttv_iattribute_find_by_path(main_win
->CurrentTab
->Attributes
,
583 "hooks/hpanedividor", LTTV_POINTER
, &value
));
584 tmp
= (LttvHooks
*)*(value
.v_pointer
);
585 if(tmp
== NULL
) return;
586 lttv_hooks_call(tmp
, &position
);
591 * Function to process traceset. It will call lttv_process_trace,
592 * each view will call this api to get events.
593 * @param main_win the main window the viewer belongs to.
594 * @param start the start time of the first event to be processed.
595 * @param end the end time of the last event to be processed.
598 void processTraceset(mainWindow
*main_win
, LttTime start
,
599 LttTime end
, unsigned maxNumEvents
)
601 lttv_process_traceset_seek_time(main_win
->Traceset_Info
->TracesetContext
, start
);
602 lttv_process_traceset(main_win
->Traceset_Info
->TracesetContext
, end
, maxNumEvents
);
606 * Function to add hooks into the context of a traceset,
607 * before reading events from traceset, viewer will call this api to
609 * @param main_win the main window the viewer belongs to.
610 * @param LttvHooks hooks to be registered.
613 void contextAddHooks(mainWindow
*main_win
,
614 LttvHooks
*before_traceset
,
615 LttvHooks
*after_traceset
,
616 LttvHooks
*check_trace
,
617 LttvHooks
*before_trace
,
618 LttvHooks
*after_trace
,
619 LttvHooks
*check_tracefile
,
620 LttvHooks
*before_tracefile
,
621 LttvHooks
*after_tracefile
,
622 LttvHooks
*check_event
,
623 LttvHooks
*before_event
,
624 LttvHooks
*after_event
)
626 LttvTracesetContext
* tsc
=
627 LTTV_TRACESET_CONTEXT(main_win
->Traceset_Info
->TracesetContext
);
628 lttv_traceset_context_add_hooks(tsc
,before_traceset
,after_traceset
,
629 check_trace
,before_trace
,after_trace
,
630 check_tracefile
,before_tracefile
,after_tracefile
,
631 check_event
,before_event
, after_event
);
636 * Function to remove hooks from the context of a traceset,
637 * before reading events from traceset, viewer will call this api to
639 * @param main_win the main window the viewer belongs to.
640 * @param LttvHooks hooks to be registered.
643 void contextRemoveHooks(mainWindow
*main_win
,
644 LttvHooks
*before_traceset
,
645 LttvHooks
*after_traceset
,
646 LttvHooks
*check_trace
,
647 LttvHooks
*before_trace
,
648 LttvHooks
*after_trace
,
649 LttvHooks
*check_tracefile
,
650 LttvHooks
*before_tracefile
,
651 LttvHooks
*after_tracefile
,
652 LttvHooks
*check_event
,
653 LttvHooks
*before_event
,
654 LttvHooks
*after_event
)
656 LttvTracesetContext
* tsc
=
657 LTTV_TRACESET_CONTEXT(main_win
->Traceset_Info
->TracesetContext
);
658 lttv_traceset_context_remove_hooks(tsc
,before_traceset
,after_traceset
,
659 check_trace
,before_trace
,after_trace
,
660 check_tracefile
,before_tracefile
,after_tracefile
,
661 check_event
,before_event
, after_event
);
666 * Function to add/remove event hooks for state
667 * @param main_win the main window the viewer belongs to.
670 void stateAddEventHooks(mainWindow
*main_win
)
672 lttv_state_add_event_hooks(
673 (LttvTracesetState
*)main_win
->Traceset_Info
->TracesetContext
);
676 void stateRemoveEventHooks(mainWindow
*main_win
)
678 lttv_state_remove_event_hooks(
679 (LttvTracesetState
*)main_win
->Traceset_Info
->TracesetContext
);
684 * Function to add/remove event hooks for stats
685 * @param main_win the main window the viewer belongs to.
688 void statsAddEventHooks(mainWindow
*main_win
)
690 lttv_stats_add_event_hooks(
691 (LttvTracesetStats
*)main_win
->Traceset_Info
->TracesetContext
);
694 void statsRemoveEventHooks(mainWindow
*main_win
)
696 lttv_stats_remove_event_hooks(
697 (LttvTracesetStats
*)main_win
->Traceset_Info
->TracesetContext
);
701 * Function to get the stats of the traceset
702 * @param main_win the main window the viewer belongs to.
705 LttvTracesetStats
* getTracesetStats(mainWindow
*main_win
)
707 return main_win
->Traceset_Info
->TracesetContext
;