561f5852 |
1 | /*! \file gtkTraceSet.h |
2 | * \brief API used by the graphical viewers to interact with their top window. |
3 | * |
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 |
6 | * events sent by gtk. |
7 | * This header file should be included in each graphic module. |
8 | * This library is used by graphical modules to interact with the |
9 | * tracesetWindow. |
10 | * |
11 | */ |
12 | |
d0cf1bcd |
13 | #include <lttv/common.h> |
561f5852 |
14 | #include <ltt/ltt.h> |
15 | #include <lttv/lttv.h> |
16 | #include <lttv/mainWindow.h> |
17 | #include <lttv/gtkTraceSet.h> |
18 | #include <lttv/processTrace.h> |
c4c15b5e |
19 | #include <lttv/toolbar.h> |
20 | #include <lttv/menu.h> |
6b1d3120 |
21 | #include <lttv/state.h> |
22 | #include <lttv/stats.h> |
23 | |
561f5852 |
24 | |
25 | /** |
26 | * Internal function parts |
27 | */ |
28 | |
29 | /** |
30 | * Function to remove toolbar from the GUI |
31 | * @param view_constructor constructor of the viewer. |
32 | */ |
33 | |
c4c15b5e |
34 | void RemoveToolbar(lttv_constructor view_constructor) |
561f5852 |
35 | { |
36 | g_printf("Toolbar for the viewer will be removed\n"); |
37 | } |
38 | |
39 | /** |
40 | * Function to remove menu entry from the GUI |
41 | * @param view_constructor constructor of the viewer. |
42 | */ |
43 | |
c4c15b5e |
44 | void RemoveMenu(lttv_constructor view_constructor) |
561f5852 |
45 | { |
46 | g_printf("Menu entry for the viewer will be removed\n"); |
47 | } |
48 | |
49 | |
50 | /** |
51 | * Function to set/update traceset for the viewers |
52 | * @param main_win main window |
53 | * @param traceset traceset of the main window. |
54 | */ |
55 | |
56 | void SetTraceset(mainWindow * main_win, gpointer traceset) |
57 | { |
58 | LttvHooks * tmp; |
59 | LttvAttributeValue value; |
60 | |
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); |
66 | } |
67 | |
68 | |
69 | /** |
70 | * Function to set/update filter for the viewers |
71 | * @param main_win main window |
72 | * @param filter filter of the main window. |
73 | */ |
74 | |
75 | void SetFilter(mainWindow * main_win, gpointer filter) |
76 | { |
77 | LttvHooks * tmp; |
78 | LttvAttributeValue value; |
79 | |
80 | g_assert(lttv_iattribute_find_by_path(main_win->Attributes, |
81 | "hooks/updatefilter", LTTV_POINTER, &value)); |
82 | tmp = (LttvHooks*)*(value.v_pointer); |
83 | |
84 | if(tmp == NULL)return; |
85 | lttv_hooks_call(tmp,filter); |
86 | } |
87 | |
88 | |
89 | |
90 | /** |
91 | * API parts |
92 | */ |
93 | |
94 | /** |
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. |
101 | */ |
102 | |
c4c15b5e |
103 | void ToolbarItemReg(char ** pixmap, char *tooltip, lttv_constructor view_constructor) |
561f5852 |
104 | { |
105 | LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes()); |
106 | LttvToolbars * toolbar; |
107 | LttvAttributeValue value; |
108 | |
109 | g_assert(lttv_iattribute_find_by_path(attributes_global, |
110 | "viewers/toolbar", LTTV_POINTER, &value)); |
111 | toolbar = (LttvToolbars*)*(value.v_pointer); |
112 | |
113 | if(toolbar == NULL){ |
114 | toolbar = lttv_toolbars_new(); |
115 | *(value.v_pointer) = toolbar; |
116 | } |
117 | lttv_toolbars_add(toolbar, view_constructor, tooltip, pixmap); |
118 | } |
119 | |
120 | |
121 | /** |
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. |
127 | */ |
128 | |
c4c15b5e |
129 | void ToolbarItemUnreg(lttv_constructor view_constructor) |
561f5852 |
130 | { |
131 | LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes()); |
132 | LttvToolbars * toolbar; |
133 | LttvAttributeValue value; |
134 | |
135 | g_assert(lttv_iattribute_find_by_path(attributes_global, |
136 | "viewers/toolbar", LTTV_POINTER, &value)); |
137 | toolbar = (LttvToolbars*)*(value.v_pointer); |
138 | |
139 | if(lttv_toolbars_remove(toolbar, view_constructor)) |
140 | RemoveToolbar(view_constructor); |
141 | } |
142 | |
143 | |
144 | /** |
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. |
151 | */ |
152 | |
c4c15b5e |
153 | void MenuItemReg(char *menu_path, char *menu_text, lttv_constructor view_constructor) |
561f5852 |
154 | { |
155 | LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes()); |
156 | LttvMenus * menu; |
157 | LttvAttributeValue value; |
158 | |
159 | g_assert(lttv_iattribute_find_by_path(attributes_global, |
160 | "viewers/menu", LTTV_POINTER, &value)); |
161 | menu = (LttvMenus*)*(value.v_pointer); |
162 | |
163 | if(menu == NULL){ |
164 | menu = lttv_menus_new(); |
165 | *(value.v_pointer) = menu; |
166 | } |
167 | lttv_menus_add(menu, view_constructor, menu_path, menu_text); |
168 | } |
169 | |
170 | /** |
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. |
176 | */ |
177 | |
c4c15b5e |
178 | void MenuItemUnreg(lttv_constructor view_constructor) |
561f5852 |
179 | { |
180 | LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes()); |
181 | LttvMenus * menu; |
182 | LttvAttributeValue value; |
183 | |
184 | g_assert(lttv_iattribute_find_by_path(attributes_global, |
c4c15b5e |
185 | "viewers/menu", LTTV_POINTER, &value)); |
561f5852 |
186 | menu = (LttvMenus*)*(value.v_pointer); |
187 | |
188 | if(lttv_menus_remove(menu, view_constructor)) |
189 | RemoveMenu(view_constructor); |
190 | } |
191 | |
192 | |
193 | /** |
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. |
197 | */ |
198 | |
199 | void UpdateStatus(mainWindow *main_win, char *info) |
200 | { |
201 | } |
202 | |
203 | |
204 | /** |
205 | * Function to get the current time interval of the current tab. |
206 | * It will be called by a viewer's hook function to update the |
207 | * time interval of the viewer and also be called by the constructor |
208 | * of the viewer. |
209 | * @param main_win the main window the viewer belongs to. |
210 | * @param time_interval a pointer where time interval will be stored. |
211 | */ |
212 | |
213 | void GetTimeInterval(mainWindow *main_win, TimeInterval *time_interval) |
214 | { |
215 | time_interval->startTime = main_win->CurrentTab->startTime; |
216 | time_interval->endTime = main_win->CurrentTab->endTime; |
217 | } |
218 | |
219 | |
220 | /** |
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. |
226 | */ |
227 | |
228 | void SetTimeInterval(mainWindow *main_win, TimeInterval *time_interval) |
229 | { |
230 | LttvAttributeValue value; |
231 | LttvHooks * tmp; |
232 | main_win->CurrentTab->startTime = time_interval->startTime; |
233 | main_win->CurrentTab->endTime = time_interval->endTime; |
234 | g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes, |
235 | "hooks/updatetimeinterval", LTTV_POINTER, &value)); |
236 | tmp = (LttvHooks*)*(value.v_pointer); |
237 | if(tmp == NULL)return; |
238 | lttv_hooks_call(tmp, time_interval); |
239 | } |
240 | |
241 | |
242 | /** |
243 | * Function to get the current time/event of the current tab. |
244 | * It will be called by a viewer's hook function to update the |
245 | * current time/event of the viewer. |
246 | * @param main_win the main window the viewer belongs to. |
247 | * @param time a pointer where time will be stored. |
248 | */ |
249 | |
250 | void GetCurrentTime(mainWindow *main_win, LttTime *time) |
251 | { |
252 | time = &main_win->CurrentTab->currentTime; |
253 | } |
254 | |
255 | |
256 | /** |
257 | * Function to set the current time/event of the current tab. |
258 | * It will be called by a viewer's signal handle associated with |
259 | * the button-release-event signal |
260 | * @param main_win the main window the viewer belongs to. |
261 | * @param time a pointer where time is stored. |
262 | */ |
263 | |
264 | void SetCurrentTime(mainWindow *main_win, LttTime *time) |
265 | { |
266 | LttvAttributeValue value; |
267 | LttvHooks * tmp; |
268 | main_win->CurrentTab->currentTime = *time; |
269 | g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes, |
270 | "hooks/updatecurrenttime", LTTV_POINTER, &value)); |
271 | tmp = (LttvHooks*)*(value.v_pointer); |
272 | |
273 | if(tmp == NULL)return; |
274 | lttv_hooks_call(tmp, time); |
275 | } |
276 | |
277 | |
278 | /** |
279 | * Function to get the traceset from the current tab. |
280 | * It will be called by the constructor of the viewer and also be |
281 | * called by a hook funtion of the viewer to update its traceset. |
282 | * @param main_win the main window the viewer belongs to. |
283 | * @param traceset a pointer to a traceset. |
284 | */ |
285 | /* |
286 | void GetTraceset(mainWindow *main_win, Traceset *traceset) |
287 | { |
288 | } |
289 | */ |
290 | |
291 | /** |
292 | * Function to get the filter of the current tab. |
293 | * It will be called by the constructor of the viewer and also be |
294 | * called by a hook funtion of the viewer to update its filter. |
295 | * @param main_win, the main window the viewer belongs to. |
296 | * @param filter, a pointer to a filter. |
297 | */ |
298 | /* |
299 | void GetFilter(mainWindow *main_win, Filter *filter) |
300 | { |
301 | } |
302 | */ |
303 | |
304 | /** |
305 | * Function to register a hook function for a viewer to set/update its |
306 | * time interval. |
307 | * It will be called by the constructor of the viewer. |
308 | * @param hook hook function of the viewer. |
309 | * @param hook_data hook data associated with the hook function. |
310 | * @param main_win the main window the viewer belongs to. |
311 | */ |
312 | |
313 | void RegUpdateTimeInterval(LttvHook hook, gpointer hook_data, |
314 | mainWindow * main_win) |
315 | { |
316 | LttvAttributeValue value; |
317 | LttvHooks * tmp; |
318 | g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes, |
319 | "hooks/updatetimeinterval", LTTV_POINTER, &value)); |
320 | tmp = (LttvHooks*)*(value.v_pointer); |
321 | if(tmp == NULL){ |
322 | tmp = lttv_hooks_new(); |
323 | *(value.v_pointer) = tmp; |
324 | } |
325 | lttv_hooks_add(tmp, hook,hook_data); |
326 | } |
327 | |
328 | |
329 | /** |
330 | * Function to unregister a viewer's hook function which is used to |
331 | * set/update the time interval of the viewer. |
332 | * It will be called by the destructor of the viewer. |
333 | * @param hook hook function of the viewer. |
334 | * @param hook_data hook data associated with the hook function. |
335 | * @param main_win the main window the viewer belongs to. |
336 | */ |
337 | |
338 | void UnregUpdateTimeInterval(LttvHook hook, gpointer hook_data, |
339 | mainWindow * main_win) |
340 | { |
341 | LttvAttributeValue value; |
342 | LttvHooks * tmp; |
343 | g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes, |
344 | "hooks/updatetimeinterval", LTTV_POINTER, &value)); |
345 | tmp = (LttvHooks*)*(value.v_pointer); |
346 | if(tmp == NULL) return; |
347 | lttv_hooks_remove_data(tmp, hook, hook_data); |
348 | } |
349 | |
350 | |
351 | /** |
352 | * Function to register a hook function for a viewer to set/update its |
353 | * traceset. |
354 | * It will be called by the constructor of the viewer. |
355 | * @param hook hook function of the viewer. |
356 | * @param hook_data hook data associated with the hook function. |
357 | * @param main_win the main window the viewer belongs to. |
358 | */ |
359 | |
360 | void RegUpdateTraceset(LttvHook hook, gpointer hook_data, |
361 | mainWindow * main_win) |
362 | { |
363 | LttvAttributeValue value; |
364 | LttvHooks * tmp; |
365 | g_assert(lttv_iattribute_find_by_path(main_win->Attributes, |
366 | "hooks/updatetraceset", LTTV_POINTER, &value)); |
367 | tmp = (LttvHooks*)*(value.v_pointer); |
368 | if(tmp == NULL){ |
369 | tmp = lttv_hooks_new(); |
370 | *(value.v_pointer) = tmp; |
371 | } |
372 | lttv_hooks_add(tmp, hook, hook_data); |
373 | } |
374 | |
375 | |
376 | /** |
377 | * Function to unregister a viewer's hook function which is used to |
378 | * set/update the traceset of the viewer. |
379 | * It will be called by the destructor of the viewer. |
380 | * @param hook hook function of the viewer. |
381 | * @param hook_data hook data associated with the hook function. |
382 | * @param main_win the main window the viewer belongs to. |
383 | */ |
384 | |
385 | void UnregUpdateTraceset(LttvHook hook, gpointer hook_data, |
386 | mainWindow * main_win) |
387 | { |
388 | LttvAttributeValue value; |
389 | LttvHooks * tmp; |
390 | g_assert(lttv_iattribute_find_by_path(main_win->Attributes, |
391 | "hooks/updatetraceset", LTTV_POINTER, &value)); |
392 | tmp = (LttvHooks*)*(value.v_pointer); |
393 | if(tmp == NULL) return; |
394 | lttv_hooks_remove_data(tmp, hook, hook_data); |
395 | } |
396 | |
397 | |
398 | /** |
399 | * Function to register a hook function for a viewer to set/update its |
400 | * filter. |
401 | * It will be called by the constructor of the viewer. |
402 | * @param hook hook function of the viewer. |
403 | * @param hook_data hook data associated with the hook function. |
404 | * @param main_win the main window the viewer belongs to. |
405 | */ |
406 | |
407 | void RegUpdateFilter(LttvHook hook, gpointer hook_data, |
408 | mainWindow *main_win) |
409 | { |
410 | LttvAttributeValue value; |
411 | LttvHooks * tmp; |
412 | g_assert(lttv_iattribute_find_by_path(main_win->Attributes, |
413 | "hooks/updatefilter", LTTV_POINTER, &value)); |
414 | tmp = (LttvHooks*)*(value.v_pointer); |
415 | if(tmp == NULL){ |
416 | tmp = lttv_hooks_new(); |
417 | *(value.v_pointer) = tmp; |
418 | } |
419 | lttv_hooks_add(tmp, hook, hook_data); |
420 | } |
421 | |
422 | |
423 | /** |
424 | * Function to unregister a viewer's hook function which is used to |
425 | * set/update the filter of the viewer. |
426 | * It will be called by the destructor of the viewer. |
427 | * @param hook hook function of the viewer. |
428 | * @param hook_data hook data associated with the hook function. |
429 | * @param main_win the main window the viewer belongs to. |
430 | */ |
431 | |
432 | void UnregUpdateFilter(LttvHook hook, gpointer hook_data, |
433 | mainWindow * main_win) |
434 | { |
435 | LttvAttributeValue value; |
436 | LttvHooks * tmp; |
437 | g_assert(lttv_iattribute_find_by_path(main_win->Attributes, |
438 | "hooks/updatefilter", LTTV_POINTER, &value)); |
439 | tmp = (LttvHooks*)*(value.v_pointer); |
440 | if(tmp == NULL) return; |
441 | lttv_hooks_remove_data(tmp, hook, hook_data); |
442 | } |
443 | |
444 | |
445 | /** |
446 | * Function to register a hook function for a viewer to set/update its |
447 | * current time. |
448 | * It will be called by the constructor of the viewer. |
449 | * @param hook hook function of the viewer. |
450 | * @param hook_data hook data associated with the hook function. |
451 | * @param main_win the main window the viewer belongs to. |
452 | */ |
453 | |
454 | void RegUpdateCurrentTime(LttvHook hook, gpointer hook_data, |
455 | mainWindow *main_win) |
456 | { |
457 | LttvAttributeValue value; |
458 | LttvHooks * tmp; |
459 | g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes, |
460 | "hooks/updatecurrenttime", LTTV_POINTER, &value)); |
461 | tmp = (LttvHooks*)*(value.v_pointer); |
462 | if(tmp == NULL){ |
463 | tmp = lttv_hooks_new(); |
464 | *(value.v_pointer) = tmp; |
465 | } |
466 | lttv_hooks_add(tmp, hook, hook_data); |
467 | } |
468 | |
469 | |
470 | /** |
471 | * Function to unregister a viewer's hook function which is used to |
472 | * set/update the current time of the viewer. |
473 | * It will be called by the destructor of the viewer. |
474 | * @param hook hook function of the viewer. |
475 | * @param hook_data hook data associated with the hook function. |
476 | * @param main_win the main window the viewer belongs to. |
477 | */ |
478 | |
479 | void UnregUpdateCurrentTime(LttvHook hook, gpointer hook_data, |
480 | mainWindow * main_win) |
481 | { |
482 | LttvAttributeValue value; |
483 | LttvHooks * tmp; |
484 | g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes, |
485 | "hooks/updatecurrenttime", LTTV_POINTER, &value)); |
486 | tmp = (LttvHooks*)*(value.v_pointer); |
487 | if(tmp == NULL) return; |
488 | lttv_hooks_remove_data(tmp, hook, hook_data); |
489 | } |
490 | |
491 | |
492 | /** |
493 | * Function to set the focused pane (viewer). |
494 | * It will be called by a viewer's signal handle associated with |
495 | * the grab_focus signal |
496 | * @param main_win the main window the viewer belongs to. |
497 | * @param paned a pointer to a pane where the viewer is contained. |
498 | */ |
499 | |
500 | void SetFocusedPane(mainWindow *main_win, gpointer paned) |
501 | { |
502 | gtk_custom_set_focus((GtkWidget*)main_win->CurrentTab->custom,paned); |
503 | } |
504 | |
505 | |
506 | /** |
507 | * Function to register a hook function for a viewer to set/update the |
508 | * dividor of the hpane. |
509 | * It will be called by the constructor of the viewer. |
510 | * @param hook hook function of the viewer. |
511 | * @param hook_data hook data associated with the hook function. |
512 | * @param main_win the main window the viewer belongs to. |
513 | */ |
514 | |
515 | void RegUpdateDividor(LttvHook hook, gpointer hook_data, |
516 | mainWindow *main_win) |
517 | { |
518 | LttvAttributeValue value; |
519 | LttvHooks * tmp; |
520 | g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes, |
521 | "hooks/hpanedividor", LTTV_POINTER, &value)); |
522 | tmp = (LttvHooks*)*(value.v_pointer); |
523 | if(tmp == NULL){ |
524 | tmp = lttv_hooks_new(); |
525 | *(value.v_pointer) = tmp; |
526 | } |
527 | lttv_hooks_add(tmp, hook, hook_data); |
528 | } |
529 | |
530 | |
531 | /** |
532 | * Function to unregister a viewer's hook function which is used to |
533 | * set/update hpane's dividor of the viewer. |
534 | * It will be called by the destructor of the viewer. |
535 | * @param hook hook function of the viewer. |
536 | * @param hook_data hook data associated with the hook function. |
537 | * @param main_win the main window the viewer belongs to. |
538 | */ |
539 | |
540 | void UnregUpdateDividor(LttvHook hook, gpointer hook_data, |
541 | mainWindow *main_win) |
542 | { |
543 | LttvAttributeValue value; |
544 | LttvHooks * tmp; |
545 | g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes, |
546 | "hooks/hpanedividor", LTTV_POINTER, &value)); |
547 | tmp = (LttvHooks*)*(value.v_pointer); |
548 | if(tmp == NULL) return; |
549 | lttv_hooks_remove_data(tmp, hook, hook_data); |
550 | } |
551 | |
552 | |
553 | /** |
554 | * Function to set the position of the hpane's dividor (viewer). |
555 | * It will be called by a viewer's signal handle associated with |
556 | * the motion_notify_event event/signal |
557 | * @param main_win the main window the viewer belongs to. |
558 | * @param position position of the hpane's dividor. |
559 | */ |
560 | |
561 | void SetHPaneDividor(mainWindow *main_win, gint position) |
562 | { |
563 | LttvAttributeValue value; |
564 | LttvHooks * tmp; |
565 | g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes, |
566 | "hooks/hpanedividor", LTTV_POINTER, &value)); |
567 | tmp = (LttvHooks*)*(value.v_pointer); |
568 | if(tmp == NULL) return; |
569 | lttv_hooks_call(tmp, &position); |
570 | } |
571 | |
572 | |
573 | /** |
574 | * Function to process traceset. It will call lttv_process_trace, |
575 | * each view will call this api to get events. |
576 | * @param main_win the main window the viewer belongs to. |
577 | * @param start the start time of the first event to be processed. |
578 | * @param end the end time of the last event to be processed. |
579 | */ |
580 | |
f227416e |
581 | void processTraceset(mainWindow *main_win, LttTime start, |
582 | LttTime end, unsigned maxNumEvents) |
561f5852 |
583 | { |
f227416e |
584 | lttv_process_trace(start, end, main_win->traceset, |
585 | main_win->traceset_context, maxNumEvents); |
561f5852 |
586 | } |
587 | |
588 | /** |
589 | * Function to add hooks into the context of a traceset, |
590 | * before reading events from traceset, viewer will call this api to |
591 | * register hooks |
592 | * @param main_win the main window the viewer belongs to. |
593 | * @param LttvHooks hooks to be registered. |
594 | */ |
595 | |
596 | void contextAddHooks(mainWindow *main_win , |
597 | LttvHooks *before_traceset, |
598 | LttvHooks *after_traceset, |
599 | LttvHooks *check_trace, |
600 | LttvHooks *before_trace, |
601 | LttvHooks *after_trace, |
602 | LttvHooks *check_tracefile, |
603 | LttvHooks *before_tracefile, |
604 | LttvHooks *after_tracefile, |
605 | LttvHooks *check_event, |
606 | LttvHooks *before_event, |
607 | LttvHooks *after_event) |
608 | { |
609 | LttvTracesetContext * tsc = main_win->traceset_context; |
610 | lttv_traceset_context_add_hooks(tsc,before_traceset,after_traceset, |
611 | check_trace,before_trace,after_trace, |
612 | check_tracefile,before_tracefile,after_tracefile, |
613 | check_event,before_event, after_event); |
614 | } |
615 | |
616 | |
617 | /** |
618 | * Function to remove hooks from the context of a traceset, |
619 | * before reading events from traceset, viewer will call this api to |
620 | * unregister hooks |
621 | * @param main_win the main window the viewer belongs to. |
622 | * @param LttvHooks hooks to be registered. |
623 | */ |
624 | |
625 | void contextRemoveHooks(mainWindow *main_win , |
626 | LttvHooks *before_traceset, |
627 | LttvHooks *after_traceset, |
628 | LttvHooks *check_trace, |
629 | LttvHooks *before_trace, |
630 | LttvHooks *after_trace, |
631 | LttvHooks *check_tracefile, |
632 | LttvHooks *before_tracefile, |
633 | LttvHooks *after_tracefile, |
634 | LttvHooks *check_event, |
635 | LttvHooks *before_event, |
636 | LttvHooks *after_event) |
637 | { |
638 | LttvTracesetContext * tsc = main_win->traceset_context; |
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); |
643 | } |
f735c59a |
644 | |
645 | |
646 | /** |
647 | * Function to get the life span of the traceset |
648 | * @param main_win the main window the viewer belongs to. |
649 | * @param start start time of the traceset. |
650 | * @param end end time of the traceset. |
651 | */ |
652 | |
653 | void getTracesetTimeSpan(mainWindow *main_win, LttTime * start, LttTime* end) |
654 | { |
655 | LttvTraceset * traceset = main_win->traceset; |
656 | int numTraces = lttv_traceset_number(traceset); |
657 | int i; |
658 | LttTime s, e; |
659 | LttvTraceContext *tc; |
660 | LttTrace * trace; |
661 | |
662 | for(i=0; i<numTraces;i++){ |
663 | tc = main_win->traceset_context->traces[i]; |
664 | trace = tc->t; |
665 | |
666 | ltt_trace_time_span_get(trace, &s, &e); |
667 | |
668 | if(i==0){ |
669 | *start = s; |
670 | *end = e; |
671 | }else{ |
672 | if(s.tv_sec < start->tv_sec || |
673 | (s.tv_sec == start->tv_sec && s.tv_nsec < start->tv_nsec)) |
674 | *start = s; |
675 | if(e.tv_sec > end->tv_sec || |
676 | (e.tv_sec == end->tv_sec && e.tv_nsec > end->tv_nsec)) |
677 | *end = e; |
678 | } |
679 | } |
680 | } |
6b1d3120 |
681 | |
682 | |
683 | /** |
684 | * Function to add/remove event hooks for state |
685 | * @param main_win the main window the viewer belongs to. |
686 | */ |
687 | |
688 | void stateAddEventHooks(mainWindow *main_win ) |
689 | { |
690 | lttv_state_add_event_hooks((LttvTracesetState*)main_win->traceset_context); |
691 | } |
692 | |
693 | void stateRemoveEventHooks(mainWindow *main_win ) |
694 | { |
695 | lttv_state_remove_event_hooks((LttvTracesetState*)main_win->traceset_context); |
696 | } |
697 | |
698 | |
699 | /** |
700 | * Function to add/remove event hooks for stats |
701 | * @param main_win the main window the viewer belongs to. |
702 | */ |
703 | |
704 | void statsAddEventHooks(mainWindow *main_win ) |
705 | { |
706 | lttv_stats_add_event_hooks((LttvTracesetStats*)main_win->traceset_context); |
707 | } |
708 | |
709 | void statsRemoveEventHooks(mainWindow *main_win ) |
710 | { |
711 | lttv_stats_remove_event_hooks((LttvTracesetStats*)main_win->traceset_context); |
712 | } |
713 | |
714 | /** |
715 | * Function to get the stats of the traceset |
716 | * @param main_win the main window the viewer belongs to. |
717 | */ |
718 | |
719 | LttvTracesetStats* getTracesetStats(mainWindow *main_win) |
720 | { |
721 | return (LttvTracesetStats*)main_win->traceset_context; |
722 | } |