1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Xiangxiu Yang, Mathieu Desnoyers
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20 This file is what every viewer plugin writer should refer to.
25 A viewer plugin is, before anything, a plugin. It thus has an init and
26 a destroy function called whenever it is loaded/initialized and
27 unloaded/destroyed. A viewer depends on lttvwindow and thus uses its init and
28 destroy functions to register module related hooks defined in this file.
31 Viewer Instance Related API
33 The lifetime of a viewer is as follows. The viewer constructor function is
34 called each time an instance view is created (one subwindow of this viewer
35 type is created by the user either by clicking on the menu item or the button
36 corresponding to the viewer). Thereafter, the viewer gets hooks called for
37 different purposes by the window containing it. These hooks are detailed
38 below. It also has to deal with GTK Events. Finally, it can be destructed by
39 having its top level widget unreferenced by the main window or by any
40 GTK Event causing a "destroy-event" signal on the its top widget. Another
41 possible way for it do be destroyed is if the module gets unloaded. The module
42 unload function will have to emit a "destroy" signal on each top level widget
43 of all instances of its viewers.
46 Notices from Main Window :
48 time_window : This is the time interval visible on the viewer's tab. Every
49 viewer that cares about being synchronised by respect to the
50 time with other viewers should register to this notification.
51 They should redraw all or part of their display when this occurs.
53 traceset : This notification is called whenever a trace is added/removed
54 from the traceset. As it affects all the data displayed by the
55 viewer, it sould redraw itself totally.
57 filter : FIXME : describe..
59 current_time: Being able to zoom nearer a specific time or highlight a specific
60 time on every viewer in synchronicity implies that the viewer
61 has to shown a visual sign over the drawing or select an event
62 when it receives this notice. It should also inform the main
63 window with the appropriate report API function when a user
64 selects a specific time as being the current time.
66 dividor : This notice links the positions of the horizontal dividors
67 between the graphic display zone of every viewer and their Y axis,
68 typically showing processes, cpus, ...
71 FIXME : Add background computation explanation here
72 background_init: prepare for background computation (comes after show_end).
73 process_trace for background: done in small chunks in gtk_idle, hooks called.
74 background_end: remove the hooks and perhaps update the window.
77 Reporting Changes to the Main Window
79 In most cases, the enclosing window knows about updates such as described in the
80 Notification section higher. There are a few cases, however, where updates are
81 caused by actions known by a view instance. For example, clicking in a view may
82 update the current time; all viewers within the same window must be told about
83 the new current time to change the currently highlighted time point. A viewer
84 reports such events by calling lttvwindow_report_current_time on its lttvwindow.
85 The lttvwindow will thereafter call update for each of its contained viewers.
88 Available report methods are :
90 lttvwindow_report_status : reports the text of the status bar.
91 lttvwindow_report_time_window : reports the new time window.
92 lttvwindow_report_current_time : reports the new current time.
93 lttvwindow_report_dividor : reports the new horizontal dividor's position.
94 lttvwindow_report_focus : One on the widgets in the viewer has the keyboard's
97 Requiring Time Interval
105 FIXME: explain GTK Events distribution and signals propagation in details
110 Provides the exposed region in the GdkEventExpose structure.
112 There are two ways of dealing with exposures. The first one is to directly draw
113 on the screen and the second one is to draw in a pixmap buffer, and then to
114 update the screen when necessary.
116 In the first case, the expose event will be responsible for registering hooks to
117 process_traceset and require time intervals to the main window. So, in this
118 scenario, if a part of the screen is damaged, the trace has to be read to
121 In the second case, with a pixmap buffer, the expose handler is only responsible
122 of showing the pixmap buffer on the screen. If the pixmap buffer has never
123 been filled with a drawing, the expose handler may ask for it to be filled.
125 It can add dotted lines and such visual effects to enhance the user's
129 FIXME : explain other important events
137 * \brief API used by the graphical viewers to interact with their top window.
139 * Main window (lttvwindow module) is the place to contain and display viewers.
140 * Viewers (lttv plugins) interact with main window through this API.
141 * This header file should be included in each graphic module.
147 #include <lttv/hook.h>
148 #include <lttvwindow/common.h>
149 #include <lttv/stats.h>
150 //FIXME (not ready yet) #include <lttv/filter.h>
153 /* Module Related API */
156 /* constructor a the viewer */
157 //FIXME explain LttvTracesetSelector and key
158 typedef GtkWidget
* (*lttvwindow_viewer_constructor
)
159 (MainWindow
* main_window
, LttvTracesetSelector
* s
, char *key
);
163 * Function to register a view constructor so that main window can generate
164 * a toolbar item for the viewer in order to generate a new instance easily.
166 * It should be called by init function of the module.
168 * @param pixmap Image shown on the toolbar item.
169 * @param tooltip tooltip of the toolbar item.
170 * @param view_constructor constructor of the viewer.
173 void lttvwindow_register_toolbar
176 lttvwindow_viewer_constructor view_constructor
);
180 * Function to unregister the viewer's constructor, release the space
181 * occupied by pixmap, tooltip and constructor of the viewer.
183 * It will be called when a module is unloaded.
185 * @param view_constructor constructor of the viewer.
188 void lttvwindow_unregister_toolbar
189 (lttvwindow_viewer_constructor view_constructor
);
193 * Function to register a view constructor so that main window can generate
194 * a menu item for the viewer in order to generate a new instance easily.
196 * It will be called by init function of the module.
198 * @param menu_path path of the menu item.
199 * @param menu_text text of the menu item.
200 * @param view_constructor constructor of the viewer.
203 void lttvwindow_register_menu(char *menu_path
,
205 lttvwindow_viewer_constructor view_constructor
);
209 * Function to unregister the viewer's constructor, release the space
210 * occupied by menu_path, menu_text and constructor of the viewer.
212 * It will be called when a module is unloaded.
214 * @param view_constructor constructor of the viewer.
217 void lttvwindow_unregister_menu(lttvwindow_viewer_constructor view_constructor
);
221 /* Viewer Instance Related API */
224 * Structure used as hook_data for the time_window_notify hook.
226 typedef struct _TimeWindowNotifyData
{
227 TimeWindow
*new_time_window
;
228 TimeWindow
*old_time_window
;
229 } TimeWindowNotifyData
;
233 * Function to register a hook function that will be called by the main window
234 * when the time interval needs to be updated.
236 * This register function is typically called by the constructor of the viewer.
238 * @param main_win the main window the viewer belongs to.
239 * @param hook hook that sould be called by the main window when the time
240 * interval changes. This hook function takes a
241 * TimeWindowNotifyData* as call_data.
242 * @param hook_data hook data associated with the hook function. It will
243 * be typically a pointer to the viewer's data structure.
246 void lttvwindow_register_time_window_notify(MainWindow
*main_win
,
252 * Function to unregister the time_window notification hook.
254 * This unregister function is typically called by the destructor of the viewer.
256 * @param main_win the main window the viewer belongs to.
257 * @param hook hook that sould be called by the main window when the time
258 * interval changes. This hook function takes a
259 * TimeWindowNotifyData* as call_data.
260 * @param hook_data hook data associated with the hook function. It will
261 * be typically a pointer to the viewer's data structure.
264 void lttvwindow_unregister_time_window_notify(MainWindow
*main_win
,
270 * Function to register a hook function that will be called by the main window
271 * when the traceset is changed. That means that the viewer must redraw
272 * itself completely or check if it's affected by the particular change to the
275 * This register function is typically called by the constructor of the viewer.
277 * @param main_win the main window the viewer belongs to.
278 * @param hook hook that should be called whenever a change to the traceset
279 * occurs. The call_data of this hook is a NULL pointer.
280 * @param hook_data hook data associated with the hook function. It will
281 * be typically a pointer to the viewer's data structure.
284 void lttvwindow_register_traceset_notify(MainWindow
*main_win
,
290 * Function to unregister the traceset_notify hook.
292 * @param main_win the main window the viewer belongs to.
293 * @param hook hook that should be called whenever a change to the traceset
294 * occurs. The call_data of this hook is a NULL pointer.
295 * @param hook_data hook data associated with the hook function. It will
296 * be typically a pointer to the viewer's data structure.
299 void lttvwindow_unregister_traceset_notify(MainWindow
*main_win
,
305 * Function to register a hook function for a viewer to set/update its
308 * FIXME : Add information about what a filter is as seen from a viewer and how
311 * This register function is typically called by the constructor of the viewer.
313 * @param main_win the main window the viewer belongs to.
314 * @param hook hook function called by the main window when a filter change
316 * @param hook_data hook data associated with the hook function. It will
317 * be typically a pointer to the viewer's data structure.
320 void lttvwindow_register_filter_notify(MainWindow
*main_win
,
326 * Function to unregister a viewer's hook function which is used to
327 * set/update the filter of the viewer.
329 * This unregistration is called by the destructor of the viewer.
331 * @param main_win the main window the viewer belongs to.
332 * @param hook hook function called by the main window when a filter change
334 * @param hook_data hook data associated with the hook function. It will
335 * be typically a pointer to the viewer's data structure.
338 void lttvwindow_unregister_filter_notify(MainWindow
* main_win
,
344 * Function to register a hook function for a viewer to set/update its
347 * @param main_win the main window the viewer belongs to.
348 * @param hook hook function of the viewer that updates the current time. The
349 * call_data is a LttTime* representing the new current time.
350 * @param hook_data hook data associated with the hook function. It will
351 * be typically a pointer to the viewer's data structure.
354 void lttvwindow_register_current_time_notify(MainWindow
*main_win
,
360 * Function to unregister a viewer's hook function which is used to
361 * set/update the current time of the viewer.
362 * @param main_win the main window the viewer belongs to.
363 * @param hook hook function of the viewer that updates the current time. The
364 * call_data is a LttTime* representing the new current time.
365 * @param hook_data hook data associated with the hook function. It will
366 * be typically a pointer to the viewer's data structure.
369 void lttvwindow_unregister_current_time_notify(MainWindow
*main_win
,
375 * Function to register a hook function for a viewer to set/update the
376 * dividor of the hpane. It provides a way to make the horizontal
377 * dividors of all the viewers linked together.
379 * @param main_win the main window the viewer belongs to.
380 * @param hook hook function of the viewer that will be called whenever a
381 * dividor changes in another viewer. The call_data of this hook
382 * is a gint*. The value of the integer is the new position of the
384 * @param hook_data hook data associated with the hook function. It will
385 * be typically a pointer to the viewer's data structure.
388 void lttvwindow_register_dividor(MainWindow
*main_win
,
394 * Function to unregister a viewer's hook function which is used to
395 * set/update hpane's dividor of the viewer.
397 * @param main_win the main window the viewer belongs to.
398 * @param hook hook function of the viewer that will be called whenever a
399 * dividor changes in another viewer. The call_data of this hook
400 * is a gint*. The value of the integer is the new position of the
402 * @param hook_data hook data associated with the hook function. It will
403 * be typically a pointer to the viewer's data structure.
406 void lttvwindow_unregister_dividor(MainWindow
*main_win
,
413 * This method reports the information to show on the status bar in the
416 * @param main_win the main window the viewer belongs to.
417 * @param info the message which will be shown in the status bar.
420 void lttvwindow_report_status(MainWindow
*main_win
, const char *info
);
424 * Function to set the time interval of the current tab.a
426 * @param main_win the main window the viewer belongs to.
427 * @param time_interval pointer to the time interval value.
430 void lttvwindow_report_time_window(MainWindow
*main_win
,
431 const TimeWindow
*time_window
);
434 * Function to set the current time/event of the current tab.
435 * It will be called by a viewer's signal handle associated with
436 * the button-release-event signal
437 * @param main_win the main window the viewer belongs to.
438 * @param time a pointer where time is stored.
441 void lttvwindow_report_current_time(MainWindow
*main_win
,
442 const LttTime
*time
);
446 * Function to set the position of the hpane's dividor (viewer).
447 * It will typically be called by a viewer's signal handle associated
448 * with the motion_notify_event event/signal.
450 * @param main_win the main window the viewer belongs to.
451 * @param position position of the hpane's dividor.
454 void lttvwindow_report_dividor(MainWindow
*main_win
, gint position
);
457 * Function to set the focused viewer of the tab.
458 * It will be called by a viewer's signal handle associated with
459 * the grab_focus signal of all widgets in the viewer.
461 * @param main_win the main window the viewer belongs to.
462 * @param top_widget the top widget containing all the other widgets of the
465 void lttvwindow_report_focus(MainWindow
*main_win
,
466 GtkWidget
*top_widget
);
470 /* Structure sent to the time request hook */
471 typedef struct _TimeRequest
{
472 TimeWindow time_window
;
475 gpointer after_hook_data
;
479 * Function to request data in a specific time interval to the main window. The
480 * time request servicing is differed until the glib idle functions are
483 * The viewer has to make sure that it has registered hooks in the main window's
484 * traceset context before the glib idle's function gets called to ensure that
485 * it will be called for the events it has asked for.
487 * @param main_win the main window the viewer belongs to.
488 * @param time_requested the time requested by the viewer.
489 * @param num_events the quantity of events to get (can be a little more if many
490 * events have the same timestamp than the last one)
491 * @param after_process_traceset hook called after the process traceset. It will
492 * typically unregister the hooks in the context.
493 * The call_data of this hook is a
494 * const TimeRequest*, corresponding to the
495 * original time request. It's there for
496 * information purpose only and should not be
498 * @param after_process_traceset_data hook data associated with the hook
499 * function. It will be typically a pointer
500 * to the viewer's data structure.
503 void lttvwindow_time_interval_request(MainWindow
*main_win
,
504 TimeWindow time_requested
,
506 LttvHook after_process_traceset
,
507 gpointer after_process_traceset_data
);
510 * Function to get the life span of the traceset
512 * @param main_win the main window the viewer belongs to.
513 * @return pointer to a time interval : the life span of the traceset.
516 const TimeInterval
*lttvwindow_get_time_span(MainWindow
*main_win
);
519 * Function to get the current time window of the current tab.
521 * @param main_win the main window the viewer belongs to.
522 * @return a pointer to the current tab's time interval.
525 const TimeWindow
*lttvwindow_get_time_window(MainWindow
*main_win
);
529 * Function to get the current time of the current tab.
531 * @param main_win the main window the viewer belongs to.
532 * @return a pointer to the current tab's current time.
535 const LttTime
*lttvwindow_get_current_time(MainWindow
*main_win
);
539 * Function to get the filter of the current tab.
540 * @param main_win, the main window the viewer belongs to.
541 * @param filter, a pointer to a filter.
545 typedef void lttv_filter
;
547 const lttv_filter
*lttvwindow_get_filter(MainWindow
*main_win
);
551 * Function to get the stats of the traceset
552 * It must be non const so the viewer can modify it.
553 * FIXME : a set/get pair of functions would be more appropriate here.
554 * @param main_win the main window the viewer belongs to.
555 * @return A pointer to Traceset statistics.
558 LttvTracesetStats
* lttvwindow_get_traceset_stats(MainWindow
*main_win
);
561 * Function to get the context of the traceset
562 * It must be non const so the viewer can add and remove hooks from it.
563 * @param main_win the main window the viewer belongs to.
564 * @return Context of the current tab.
568 LttvTracesetContext
* lttvwindow_get_traceset_context(MainWindow
*main_win
);