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 toolbar_item_reg(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 toolbar_item_unreg(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 menu_item_reg(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 menu_item_unreg(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 update_status(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 get_time_window(MainWindow
*main_win
, TimeWindow
*time_window
)
196 //time_window->start_time = main_win->current_tab->time_window.start_time;
197 //time_window->time_width = main_win->current_tab->time_window.time_width;
198 *time_window
= main_win
->current_tab
->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 get_traceset_time_span(MainWindow
*main_win
, TimeInterval
*time_interval
)
212 //time_window->start_time = main_win->current_tab->time_window.start_time;
213 //time_window->time_width = main_win->current_tab->time_window.time_width;
214 *time_interval
= *(LTTV_TRACESET_CONTEXT(main_win
->current_tab
->traceset_info
->
215 traceset_context
)->Time_Span
);
221 * Function to set the time interval of the current tab.
222 * It will be called by a viewer's signal handle associated with
223 * the move_slider signal
224 * @param main_win the main window the viewer belongs to.
225 * @param time_interval a pointer where time interval is stored.
228 void set_time_window(MainWindow
*main_win
, TimeWindow
*time_window
)
230 LttvAttributeValue value
;
232 main_win
->current_tab
->time_window
= *time_window
;
233 g_assert(lttv_iattribute_find_by_path(main_win
->current_tab
->attributes
,
234 "hooks/updatetimewindow", LTTV_POINTER
, &value
));
235 tmp
= (LttvHooks
*)*(value
.v_pointer
);
236 if(tmp
== NULL
) return;
237 lttv_hooks_call(tmp
, time_window
);
242 * Function to get the current time/event of the current tab.
243 * It will be called by a viewer's hook function to update the
244 * current time/event of the viewer.
245 * @param main_win the main window the viewer belongs to.
246 * @param time a pointer where time will be stored.
249 void get_current_time(MainWindow
*main_win
, LttTime
*time
)
251 time
= &main_win
->current_tab
->current_time
;
256 * Function to set the current time/event of the current tab.
257 * It will be called by a viewer's signal handle associated with
258 * the button-release-event signal
259 * @param main_win the main window the viewer belongs to.
260 * @param time a pointer where time is stored.
263 void set_current_time(MainWindow
*main_win
, LttTime
*time
)
265 LttvAttributeValue value
;
267 main_win
->current_tab
->current_time
= *time
;
268 g_assert(lttv_iattribute_find_by_path(main_win
->current_tab
->attributes
,
269 "hooks/updatecurrenttime", LTTV_POINTER
, &value
));
270 tmp
= (LttvHooks
*)*(value
.v_pointer
);
272 if(tmp
== NULL
)return;
273 lttv_hooks_call(tmp
, time
);
278 * Function to get the traceset from the current tab.
279 * It will be called by the constructor of the viewer and also be
280 * called by a hook funtion of the viewer to update its traceset.
281 * @param main_win the main window the viewer belongs to.
282 * @param traceset a pointer to a traceset.
285 void get_traceset(MainWindow *main_win, Traceset *traceset)
291 * Function to get the filter of the current tab.
292 * It will be called by the constructor of the viewer and also be
293 * called by a hook funtion of the viewer to update its filter.
294 * @param main_win, the main window the viewer belongs to.
295 * @param filter, a pointer to a filter.
298 void get_filter(MainWindow *main_win, Filter *filter)
304 * Function to register a hook function for a viewer to set/update its
306 * It will be called by the constructor of the viewer.
307 * @param hook hook function of the viewer.
308 * @param hook_data hook data associated with the hook function.
309 * @param main_win the main window the viewer belongs to.
312 void reg_update_time_window(LttvHook hook
, gpointer hook_data
,
313 MainWindow
* main_win
)
315 LttvAttributeValue value
;
317 g_assert(lttv_iattribute_find_by_path(main_win
->current_tab
->attributes
,
318 "hooks/updatetimewindow", LTTV_POINTER
, &value
));
319 tmp
= (LttvHooks
*)*(value
.v_pointer
);
321 tmp
= lttv_hooks_new();
322 *(value
.v_pointer
) = tmp
;
324 lttv_hooks_add(tmp
, hook
,hook_data
);
329 * Function to unregister a viewer's hook function which is used to
330 * set/update the time interval of the viewer.
331 * It will be called by the destructor of the viewer.
332 * @param hook hook function of the viewer.
333 * @param hook_data hook data associated with the hook function.
334 * @param main_win the main window the viewer belongs to.
337 void unreg_update_time_window(LttvHook hook
, gpointer hook_data
,
338 MainWindow
* main_win
)
340 LttvAttributeValue value
;
342 g_assert(lttv_iattribute_find_by_path(main_win
->current_tab
->attributes
,
343 "hooks/updatetimewindow", LTTV_POINTER
, &value
));
344 tmp
= (LttvHooks
*)*(value
.v_pointer
);
345 if(tmp
== NULL
) return;
346 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
351 * Function to register a hook function for a viewer to set/update its
353 * It will be called by the constructor of the viewer.
354 * @param hook hook function of the viewer.
355 * @param hook_data hook data associated with the hook function.
356 * @param main_win the main window the viewer belongs to.
359 void reg_update_traceset(LttvHook hook
, gpointer hook_data
,
360 MainWindow
* main_win
)
362 LttvAttributeValue value
;
364 g_assert(lttv_iattribute_find_by_path(main_win
->attributes
,
365 "hooks/updatetraceset", LTTV_POINTER
, &value
));
366 tmp
= (LttvHooks
*)*(value
.v_pointer
);
368 tmp
= lttv_hooks_new();
369 *(value
.v_pointer
) = tmp
;
371 lttv_hooks_add(tmp
, hook
, hook_data
);
376 * Function to unregister a viewer's hook function which is used to
377 * set/update the traceset of the viewer.
378 * It will be called by the destructor of the viewer.
379 * @param hook hook function of the viewer.
380 * @param hook_data hook data associated with the hook function.
381 * @param main_win the main window the viewer belongs to.
384 void unreg_update_traceset(LttvHook hook
, gpointer hook_data
,
385 MainWindow
* main_win
)
387 LttvAttributeValue value
;
389 g_assert(lttv_iattribute_find_by_path(main_win
->attributes
,
390 "hooks/updatetraceset", LTTV_POINTER
, &value
));
391 tmp
= (LttvHooks
*)*(value
.v_pointer
);
392 if(tmp
== NULL
) return;
393 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
398 * Function to register a hook function for a viewer to set/update its
400 * It will be called by the constructor of the viewer.
401 * @param hook hook function of the viewer.
402 * @param hook_data hook data associated with the hook function.
403 * @param main_win the main window the viewer belongs to.
406 void reg_update_filter(LttvHook hook
, gpointer hook_data
,
407 MainWindow
*main_win
)
409 LttvAttributeValue value
;
411 g_assert(lttv_iattribute_find_by_path(main_win
->attributes
,
412 "hooks/updatefilter", LTTV_POINTER
, &value
));
413 tmp
= (LttvHooks
*)*(value
.v_pointer
);
415 tmp
= lttv_hooks_new();
416 *(value
.v_pointer
) = tmp
;
418 lttv_hooks_add(tmp
, hook
, hook_data
);
423 * Function to unregister a viewer's hook function which is used to
424 * set/update the filter of the viewer.
425 * It will be called by the destructor of the viewer.
426 * @param hook hook function of the viewer.
427 * @param hook_data hook data associated with the hook function.
428 * @param main_win the main window the viewer belongs to.
431 void unreg_update_filter(LttvHook hook
, gpointer hook_data
,
432 MainWindow
* main_win
)
434 LttvAttributeValue value
;
436 g_assert(lttv_iattribute_find_by_path(main_win
->attributes
,
437 "hooks/updatefilter", LTTV_POINTER
, &value
));
438 tmp
= (LttvHooks
*)*(value
.v_pointer
);
439 if(tmp
== NULL
) return;
440 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
445 * Function to register a hook function for a viewer to set/update its
447 * It will be called by the constructor of the viewer.
448 * @param hook hook function of the viewer.
449 * @param hook_data hook data associated with the hook function.
450 * @param main_win the main window the viewer belongs to.
453 void reg_update_current_time(LttvHook hook
, gpointer hook_data
,
454 MainWindow
*main_win
)
456 LttvAttributeValue value
;
458 g_assert(lttv_iattribute_find_by_path(main_win
->current_tab
->attributes
,
459 "hooks/updatecurrenttime", LTTV_POINTER
, &value
));
460 tmp
= (LttvHooks
*)*(value
.v_pointer
);
462 tmp
= lttv_hooks_new();
463 *(value
.v_pointer
) = tmp
;
465 lttv_hooks_add(tmp
, hook
, hook_data
);
470 * Function to unregister a viewer's hook function which is used to
471 * set/update the current time of the viewer.
472 * It will be called by the destructor of the viewer.
473 * @param hook hook function of the viewer.
474 * @param hook_data hook data associated with the hook function.
475 * @param main_win the main window the viewer belongs to.
478 void unreg_update_current_time(LttvHook hook
, gpointer hook_data
,
479 MainWindow
* main_win
)
481 LttvAttributeValue value
;
483 g_assert(lttv_iattribute_find_by_path(main_win
->current_tab
->attributes
,
484 "hooks/updatecurrenttime", LTTV_POINTER
, &value
));
485 tmp
= (LttvHooks
*)*(value
.v_pointer
);
486 if(tmp
== NULL
) return;
487 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
492 * Function to register a hook function for a viewer to show
493 *the content of the viewer.
494 * It will be called by the constructor of the viewer.
495 * @param hook hook function of the viewer.
496 * @param hook_data hook data associated with the hook function.
497 * @param main_win the main window the viewer belongs to.
500 void reg_show_viewer(LttvHook hook
, gpointer hook_data
,
501 MainWindow
*main_win
)
503 LttvAttributeValue value
;
505 g_assert(lttv_iattribute_find_by_path(main_win
->current_tab
->attributes
,
506 "hooks/showviewer", LTTV_POINTER
, &value
));
507 tmp
= (LttvHooks
*)*(value
.v_pointer
);
509 tmp
= lttv_hooks_new();
510 *(value
.v_pointer
) = tmp
;
512 lttv_hooks_add(tmp
, hook
, hook_data
);
517 * Function to unregister a viewer's hook function which is used to
518 * show the content of the viewer..
519 * It will be called by the destructor of the viewer.
520 * @param hook hook function of the viewer.
521 * @param hook_data hook data associated with the hook function.
522 * @param main_win the main window the viewer belongs to.
525 void unreg_show_viewer(LttvHook hook
, gpointer hook_data
,
526 MainWindow
* main_win
)
528 LttvAttributeValue value
;
530 g_assert(lttv_iattribute_find_by_path(main_win
->current_tab
->attributes
,
531 "hooks/showviewer", LTTV_POINTER
, &value
));
532 tmp
= (LttvHooks
*)*(value
.v_pointer
);
533 if(tmp
== NULL
) return;
534 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
539 * Function to show each viewer in the current tab.
540 * It will be called by main window after it called process_traceset
541 * @param main_win the main window the viewer belongs to.
544 void show_viewer(MainWindow
*main_win
)
546 LttvAttributeValue value
;
548 g_assert(lttv_iattribute_find_by_path(main_win
->current_tab
->attributes
,
549 "hooks/showviewer", LTTV_POINTER
, &value
));
550 tmp
= (LttvHooks
*)*(value
.v_pointer
);
551 if(tmp
== NULL
) return;
552 lttv_hooks_call(tmp
, NULL
);
557 * Function to set the focused pane (viewer).
558 * It will be called by a viewer's signal handle associated with
559 * the grab_focus signal
560 * @param main_win the main window the viewer belongs to.
561 * @param paned a pointer to a pane where the viewer is contained.
564 void set_focused_pane(MainWindow
*main_win
, gpointer paned
)
566 gtk_multi_vpaned_set_focus((GtkWidget
*)main_win
->current_tab
->multi_vpaned
,paned
);
571 * Function to register a hook function for a viewer to set/update the
572 * dividor of the hpane.
573 * It will be called by the constructor of the viewer.
574 * @param hook hook function of the viewer.
575 * @param hook_data hook data associated with the hook function.
576 * @param main_win the main window the viewer belongs to.
579 void reg_update_dividor(LttvHook hook
, gpointer hook_data
,
580 MainWindow
*main_win
)
582 LttvAttributeValue value
;
584 g_assert(lttv_iattribute_find_by_path(main_win
->current_tab
->attributes
,
585 "hooks/hpanedividor", LTTV_POINTER
, &value
));
586 tmp
= (LttvHooks
*)*(value
.v_pointer
);
588 tmp
= lttv_hooks_new();
589 *(value
.v_pointer
) = tmp
;
591 lttv_hooks_add(tmp
, hook
, hook_data
);
596 * Function to unregister a viewer's hook function which is used to
597 * set/update hpane's dividor of the viewer.
598 * It will be called by the destructor of the viewer.
599 * @param hook hook function of the viewer.
600 * @param hook_data hook data associated with the hook function.
601 * @param main_win the main window the viewer belongs to.
604 void unreg_update_dividor(LttvHook hook
, gpointer hook_data
,
605 MainWindow
*main_win
)
607 LttvAttributeValue value
;
609 g_assert(lttv_iattribute_find_by_path(main_win
->current_tab
->attributes
,
610 "hooks/hpanedividor", LTTV_POINTER
, &value
));
611 tmp
= (LttvHooks
*)*(value
.v_pointer
);
612 if(tmp
== NULL
) return;
613 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
618 * Function to set the position of the hpane's dividor (viewer).
619 * It will be called by a viewer's signal handle associated with
620 * the motion_notify_event event/signal
621 * @param main_win the main window the viewer belongs to.
622 * @param position position of the hpane's dividor.
625 void set_hpane_dividor(MainWindow
*main_win
, gint position
)
627 LttvAttributeValue value
;
629 g_assert(lttv_iattribute_find_by_path(main_win
->current_tab
->attributes
,
630 "hooks/hpanedividor", LTTV_POINTER
, &value
));
631 tmp
= (LttvHooks
*)*(value
.v_pointer
);
632 if(tmp
== NULL
) return;
633 lttv_hooks_call(tmp
, &position
);
638 * Function to process traceset. It will call lttv_process_trace,
639 * each view will call this api to get events.
640 * @param main_win the main window the viewer belongs to.
641 * @param start the start time of the first event to be processed.
642 * @param end the end time of the last event to be processed.
645 void process_traceset_api(MainWindow
*main_win
, LttTime start
,
646 LttTime end
, unsigned maxNumEvents
)
648 lttv_process_traceset_seek_time(main_win
->current_tab
->traceset_info
->
649 traceset_context
, start
);
650 lttv_process_traceset(main_win
->current_tab
->traceset_info
->
651 traceset_context
, end
, maxNumEvents
);
655 * Function to add hooks into the context of a traceset,
656 * before reading events from traceset, viewer will call this api to
658 * @param main_win the main window the viewer belongs to.
659 * @param LttvHooks hooks to be registered.
662 void context_add_hooks_api(MainWindow
*main_win
,
663 LttvHooks
*before_traceset
,
664 LttvHooks
*after_traceset
,
665 LttvHooks
*check_trace
,
666 LttvHooks
*before_trace
,
667 LttvHooks
*after_trace
,
668 LttvHooks
*check_tracefile
,
669 LttvHooks
*before_tracefile
,
670 LttvHooks
*after_tracefile
,
671 LttvHooks
*check_event
,
672 LttvHooks
*before_event
,
673 LttvHooks
*after_event
)
675 LttvTracesetContext
* tsc
=
676 LTTV_TRACESET_CONTEXT(main_win
->current_tab
->traceset_info
->
678 lttv_traceset_context_add_hooks(tsc
,before_traceset
,after_traceset
,
679 check_trace
,before_trace
,after_trace
,
680 check_tracefile
,before_tracefile
,after_tracefile
,
681 check_event
,before_event
, after_event
);
686 * Function to remove hooks from the context of a traceset,
687 * before reading events from traceset, viewer will call this api to
689 * @param main_win the main window the viewer belongs to.
690 * @param LttvHooks hooks to be registered.
693 void context_remove_hooks_api(MainWindow
*main_win
,
694 LttvHooks
*before_traceset
,
695 LttvHooks
*after_traceset
,
696 LttvHooks
*check_trace
,
697 LttvHooks
*before_trace
,
698 LttvHooks
*after_trace
,
699 LttvHooks
*check_tracefile
,
700 LttvHooks
*before_tracefile
,
701 LttvHooks
*after_tracefile
,
702 LttvHooks
*check_event
,
703 LttvHooks
*before_event
,
704 LttvHooks
*after_event
)
706 LttvTracesetContext
* tsc
=
707 LTTV_TRACESET_CONTEXT(main_win
->current_tab
->traceset_info
->traceset_context
);
708 lttv_traceset_context_remove_hooks(tsc
,before_traceset
,after_traceset
,
709 check_trace
,before_trace
,after_trace
,
710 check_tracefile
,before_tracefile
,after_tracefile
,
711 check_event
,before_event
, after_event
);
716 * Function to add/remove event hooks for state
717 * @param main_win the main window the viewer belongs to.
720 void state_add_event_hooks_api(MainWindow
*main_win
)
722 lttv_state_add_event_hooks(
723 (LttvTracesetState
*)main_win
->current_tab
->traceset_info
->traceset_context
);
726 void state_remove_event_hooks_api(MainWindow
*main_win
)
728 lttv_state_remove_event_hooks(
729 (LttvTracesetState
*)main_win
->current_tab
->traceset_info
->traceset_context
);
734 * Function to add/remove event hooks for stats
735 * @param main_win the main window the viewer belongs to.
738 void stats_add_event_hooks_api(MainWindow
*main_win
)
740 lttv_stats_add_event_hooks(
741 (LttvTracesetStats
*)main_win
->current_tab
->traceset_info
->traceset_context
);
744 void stats_remove_event_hooks_api(MainWindow
*main_win
)
746 lttv_stats_remove_event_hooks(
747 (LttvTracesetStats
*)main_win
->current_tab
->traceset_info
->traceset_context
);
751 * Function to get the stats of the traceset
752 * @param main_win the main window the viewer belongs to.
755 LttvTracesetStats
* get_traceset_stats_api(MainWindow
*main_win
)
757 return main_win
->current_tab
->traceset_info
->traceset_context
;