95 percent of viewer.h documentation done
[lttv.git] / ltt / branches / poly / lttv / modules / gui / lttvwindow / lttvwindow / viewer.h
CommitLineData
3bc00fde 1/* This file is part of the Linux Trace Toolkit viewer
5a5b35c5 2 * Copyright (C) 2003-2004 Xiangxiu Yang, Mathieu Desnoyers
3bc00fde 3 *
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;
7 *
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.
12 *
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,
16 * MA 02111-1307, USA.
17 */
18
f95bc830 19/*
911b7a3c 20This file is what every viewer plugin writer should refer to.
21
5a5b35c5 22
23Module Related API
911b7a3c 24
25A viewer plugin is, before anything, a plugin. It thus has an init and
26a destroy function called whenever it is loaded/initialized and
27unloaded/destroyed. A viewer depends on lttvwindow and thus uses its init and
5a5b35c5 28destroy functions to register module related hooks defined in this file.
29
30
31Viewer Instance Related API
911b7a3c 32
33The lifetime of a viewer is as follows. The viewer constructor function is
34called each time an instance view is created (one subwindow of this viewer
5a5b35c5 35type is created by the user either by clicking on the menu item or the button
36corresponding to the viewer). Thereafter, the viewer gets hooks called for
911b7a3c 37different purposes by the window containing it. These hooks are detailed
5a5b35c5 38below. It also has to deal with GTK Events. Finally, it can be destructed by
39having its top level widget unreferenced by the main window or by any
40GTK Event causing a "destroy-event" signal on the its top widget. Another
41possible way for it do be destroyed is if the module gets unloaded. The module
42unload function will have to emit a "destroy" signal on each top level widget
43of all instances of its viewers.
44
45
46Notices from Main Window :
47
48time_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.
52
53traceset : 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.
911b7a3c 56
5a5b35c5 57filter : FIXME : describe..
911b7a3c 58
5a5b35c5 59current_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.
65
66dividor : 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, ...
69
70
71FIXME : Add background computation explanation here
911b7a3c 72background_init: prepare for background computation (comes after show_end).
73process_trace for background: done in small chunks in gtk_idle, hooks called.
74background_end: remove the hooks and perhaps update the window.
75
5a5b35c5 76
77Reporting Changes to the Main Window
78
79In most cases, the enclosing window knows about updates such as described in the
80Notification section higher. There are a few cases, however, where updates are
81caused by actions known by a view instance. For example, clicking in a view may
82update the current time; all viewers within the same window must be told about
83the new current time to change the currently highlighted time point. A viewer
84reports such events by calling lttvwindow_report_current_time on its lttvwindow.
85The lttvwindow will thereafter call update for each of its contained viewers.
86
87
88Available report methods are :
89
90lttvwindow_report_status : reports the text of the status bar.
91lttvwindow_report_time_window : reports the new time window.
92lttvwindow_report_current_time : reports the new current time.
93lttvwindow_report_dividor : reports the new horizontal dividor's position.
94lttvwindow_report_focus : One on the widgets in the viewer has the keyboard's
95 focus from GTK.
96
97Requiring Time Interval
98
99FIXME : explain
100
101
102
103GTK Events
104
105FIXME: explain GTK Events distribution and signals propagation in details
106(useful!)
107
108The "expose_event"
109
110Provides the exposed region in the GdkEventExpose structure.
111
112There are two ways of dealing with exposures. The first one is to directly draw
113on the screen and the second one is to draw in a pixmap buffer, and then to
114update the screen when necessary.
115
116In the first case, the expose event will be responsible for registering hooks to
117process_traceset and require time intervals to the main window. So, in this
118scenario, if a part of the screen is damaged, the trace has to be read to
119redraw the screen.
120
121In the second case, with a pixmap buffer, the expose handler is only responsible
122of showing the pixmap buffer on the screen. If the pixmap buffer has never
123been filled with a drawing, the expose handler may ask for it to be filled.
124
125It can add dotted lines and such visual effects to enhance the user's
126experience.
127
128
129FIXME : explain other important events
130
f95bc830 131*/
132
133
134
135
36b40c74 136/*! \file viewer.h
3bc00fde 137 * \brief API used by the graphical viewers to interact with their top window.
138 *
5a5b35c5 139 * Main window (lttvwindow module) is the place to contain and display viewers.
140 * Viewers (lttv plugins) interact with main window through this API.
3bc00fde 141 * This header file should be included in each graphic module.
3bc00fde 142 *
143 */
144
145#include <gtk/gtk.h>
146#include <ltt/ltt.h>
147#include <lttv/hook.h>
13f86ce2 148#include <lttvwindow/common.h>
3bc00fde 149#include <lttv/stats.h>
224446ce 150//FIXME (not ready yet) #include <lttv/filter.h>
3bc00fde 151
5a5b35c5 152
153/* Module Related API */
154
155
156/* constructor a the viewer */
157//FIXME explain LttvTracesetSelector and key
158typedef GtkWidget * (*lttvwindow_viewer_constructor)
159 (MainWindow * main_window, LttvTracesetSelector * s, char *key);
160
161
3bc00fde 162/**
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.
5a5b35c5 165 *
166 * It should be called by init function of the module.
167 *
168 * @param pixmap Image shown on the toolbar item.
3bc00fde 169 * @param tooltip tooltip of the toolbar item.
170 * @param view_constructor constructor of the viewer.
171 */
172
5a5b35c5 173void lttvwindow_register_toolbar
174 (char ** pixmap,
175 char * tooltip,
176 lttvwindow_viewer_constructor view_constructor);
3bc00fde 177
178
179/**
180 * Function to unregister the viewer's constructor, release the space
181 * occupied by pixmap, tooltip and constructor of the viewer.
5a5b35c5 182 *
3bc00fde 183 * It will be called when a module is unloaded.
5a5b35c5 184 *
185 * @param view_constructor constructor of the viewer.
3bc00fde 186 */
187
5a5b35c5 188void lttvwindow_unregister_toolbar
189 (lttvwindow_viewer_constructor view_constructor);
3bc00fde 190
191
192/**
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.
5a5b35c5 195 *
3bc00fde 196 * It will be called by init function of the module.
5a5b35c5 197 *
3bc00fde 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.
201 */
202
5a5b35c5 203void lttvwindow_register_menu(char *menu_path,
204 char *menu_text,
205 lttvwindow_viewer_constructor view_constructor);
3bc00fde 206
207
208/**
209 * Function to unregister the viewer's constructor, release the space
210 * occupied by menu_path, menu_text and constructor of the viewer.
5a5b35c5 211 *
3bc00fde 212 * It will be called when a module is unloaded.
5a5b35c5 213 *
214 * @param view_constructor constructor of the viewer.
3bc00fde 215 */
216
224446ce 217void lttvwindow_unregister_menu(lttvwindow_viewer_constructor view_constructor);
3bc00fde 218
219
5a5b35c5 220
221/* Viewer Instance Related API */
222
3bc00fde 223/**
5a5b35c5 224 * Structure used as hook_data for the time_window_notify hook.
3bc00fde 225 */
224446ce 226typedef struct _TimeWindowNotifyData {
227 TimeWindow *new_time_window;
228 TimeWindow *old_time_window;
229} TimeWindowNotifyData;
230
5a5b35c5 231
232/**
233 * Function to register a hook function that will be called by the main window
234 * when the time interval needs to be updated.
235 *
236 * This register function is typically called by the constructor of the viewer.
237 *
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.
244 */
245
246void lttvwindow_register_time_window_notify(MainWindow *main_win,
247 LttvHook hook,
248 gpointer hook_data);
3bc00fde 249
250
251/**
5a5b35c5 252 * Function to unregister the time_window notification hook.
253 *
48f6f981 254 * This unregister function is typically called by the destructor of the viewer.
5a5b35c5 255 *
3bc00fde 256 * @param main_win the main window the viewer belongs to.
5a5b35c5 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.
3bc00fde 262 */
263
5a5b35c5 264void lttvwindow_unregister_time_window_notify(MainWindow *main_win,
265 LttvHook hook,
266 gpointer hook_data);
3bc00fde 267
268
269/**
5a5b35c5 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
48f6f981 273 * traceset.
5a5b35c5 274 *
48f6f981 275 * This register function is typically called by the constructor of the viewer.
5a5b35c5 276 *
3bc00fde 277 * @param main_win the main window the viewer belongs to.
5a5b35c5 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.
3bc00fde 282 */
283
5a5b35c5 284void lttvwindow_register_traceset_notify(MainWindow *main_win,
285 LttvHook hook,
286 gpointer hook_data);
3bc00fde 287
288
289/**
5a5b35c5 290 * Function to unregister the traceset_notify hook.
291 *
3bc00fde 292 * @param main_win the main window the viewer belongs to.
5a5b35c5 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.
3bc00fde 297 */
298
5a5b35c5 299void lttvwindow_unregister_traceset_notify(MainWindow *main_win,
300 LttvHook hook,
301 gpointer hook_data);
3bc00fde 302
303
304/**
48f6f981 305 * Function to register a hook function for a viewer to set/update its
5a5b35c5 306 * filter.
307 *
308 * FIXME : Add information about what a filter is as seen from a viewer and how
309 * to use it.
310 *
48f6f981 311 * This register function is typically called by the constructor of the viewer.
5a5b35c5 312 *
3bc00fde 313 * @param main_win the main window the viewer belongs to.
5a5b35c5 314 * @param hook hook function called by the main window when a filter change
315 * occurs.
316 * @param hook_data hook data associated with the hook function. It will
317 * be typically a pointer to the viewer's data structure.
3bc00fde 318 */
319
224446ce 320void lttvwindow_register_filter_notify(MainWindow *main_win,
5a5b35c5 321 LttvHook hook,
322 gpointer hook_data);
3bc00fde 323
324
325/**
48f6f981 326 * Function to unregister a viewer's hook function which is used to
327 * set/update the filter of the viewer.
5a5b35c5 328 *
48f6f981 329 * This unregistration is called by the destructor of the viewer.
5a5b35c5 330 *
48f6f981 331 * @param main_win the main window the viewer belongs to.
5a5b35c5 332 * @param hook hook function called by the main window when a filter change
333 * occurs.
334 * @param hook_data hook data associated with the hook function. It will
335 * be typically a pointer to the viewer's data structure.
3bc00fde 336 */
337
5a5b35c5 338void lttvwindow_unregister_filter_notify(MainWindow * main_win,
339 LttvHook hook,
340 gpointer hook_data);
3bc00fde 341
342
343/**
48f6f981 344 * Function to register a hook function for a viewer to set/update its
345 * current time.
5a5b35c5 346 *
3bc00fde 347 * @param main_win the main window the viewer belongs to.
5a5b35c5 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.
3bc00fde 352 */
353
224446ce 354void lttvwindow_register_current_time_notify(MainWindow *main_win,
5a5b35c5 355 LttvHook hook,
356 gpointer hook_data);
3bc00fde 357
358
359/**
360 * Function to unregister a viewer's hook function which is used to
48f6f981 361 * set/update the current time of the viewer.
3bc00fde 362 * @param main_win the main window the viewer belongs to.
5a5b35c5 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.
3bc00fde 367 */
368
5a5b35c5 369void lttvwindow_unregister_current_time_notify(MainWindow *main_win,
370 LttvHook hook,
371 gpointer hook_data);
3bc00fde 372
373
224446ce 374/**
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.
5a5b35c5 378 *
224446ce 379 * @param main_win the main window the viewer belongs to.
5a5b35c5 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
383 * hpane dividor.
384 * @param hook_data hook data associated with the hook function. It will
385 * be typically a pointer to the viewer's data structure.
224446ce 386 */
3bc00fde 387
224446ce 388void lttvwindow_register_dividor(MainWindow *main_win,
5a5b35c5 389 LttvHook hook,
390 gpointer hook_data);
3bc00fde 391
392
224446ce 393/**
394 * Function to unregister a viewer's hook function which is used to
395 * set/update hpane's dividor of the viewer.
5a5b35c5 396 *
224446ce 397 * @param main_win the main window the viewer belongs to.
5a5b35c5 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
401 * hpane dividor.
402 * @param hook_data hook data associated with the hook function. It will
403 * be typically a pointer to the viewer's data structure.
224446ce 404 */
405
406void lttvwindow_unregister_dividor(MainWindow *main_win,
5a5b35c5 407 LttvHook hook,
408 gpointer hook_data);
3bc00fde 409
3bc00fde 410
411
412/**
5a5b35c5 413 * This method reports the information to show on the status bar in the
414 * main window.
415 *
3bc00fde 416 * @param main_win the main window the viewer belongs to.
48f6f981 417 * @param info the message which will be shown in the status bar.
3bc00fde 418 */
419
5a5b35c5 420void lttvwindow_report_status(MainWindow *main_win, const char *info);
3bc00fde 421
422
423/**
5a5b35c5 424 * Function to set the time interval of the current tab.a
425 *
3bc00fde 426 * @param main_win the main window the viewer belongs to.
5a5b35c5 427 * @param time_interval pointer to the time interval value.
3bc00fde 428 */
429
5a5b35c5 430void lttvwindow_report_time_window(MainWindow *main_win,
431 const TimeWindow *time_window);
3bc00fde 432
433/**
48f6f981 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
3bc00fde 437 * @param main_win the main window the viewer belongs to.
48f6f981 438 * @param time a pointer where time is stored.
3bc00fde 439 */
440
5a5b35c5 441void lttvwindow_report_current_time(MainWindow *main_win,
442 const LttTime *time);
3bc00fde 443
444
445/**
48f6f981 446 * Function to set the position of the hpane's dividor (viewer).
5a5b35c5 447 * It will typically be called by a viewer's signal handle associated
448 * with the motion_notify_event event/signal.
449 *
3bc00fde 450 * @param main_win the main window the viewer belongs to.
48f6f981 451 * @param position position of the hpane's dividor.
3bc00fde 452 */
453
224446ce 454void lttvwindow_report_dividor(MainWindow *main_win, gint position);
3bc00fde 455
456/**
5a5b35c5 457 * Function to set the focused viewer of the tab.
3bc00fde 458 * It will be called by a viewer's signal handle associated with
5a5b35c5 459 * the grab_focus signal of all widgets in the viewer.
460 *
3bc00fde 461 * @param main_win the main window the viewer belongs to.
5a5b35c5 462 * @param top_widget the top widget containing all the other widgets of the
463 * viewer.
3bc00fde 464 */
5a5b35c5 465void lttvwindow_report_focus(MainWindow *main_win,
466 GtkWidget *top_widget);
3bc00fde 467
a43d67ba 468
5a5b35c5 469
470/* Structure sent to the time request hook */
471typedef struct _TimeRequest {
472 TimeWindow time_window;
473 guint num_events;
474 LttvHook after_hook;
475 gpointer after_hook_data;
476} TimeRequest;
477
a43d67ba 478/**
5a5b35c5 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
481 * called.
482 *
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.
486 *
a43d67ba 487 * @param main_win the main window the viewer belongs to.
5a5b35c5 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
497 * freed.
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.
a43d67ba 501 */
502
503void lttvwindow_time_interval_request(MainWindow *main_win,
5a5b35c5 504 TimeWindow time_requested,
505 guint num_events,
506 LttvHook after_process_traceset,
507 gpointer after_process_traceset_data);
a43d67ba 508
3bc00fde 509/**
48f6f981 510 * Function to get the life span of the traceset
5a5b35c5 511 *
3bc00fde 512 * @param main_win the main window the viewer belongs to.
5a5b35c5 513 * @return pointer to a time interval : the life span of the traceset.
3bc00fde 514 */
515
224446ce 516const TimeInterval *lttvwindow_get_time_span(MainWindow *main_win);
48f6f981 517
518/**
519 * Function to get the current time window of the current tab.
5a5b35c5 520 *
48f6f981 521 * @param main_win the main window the viewer belongs to.
5a5b35c5 522 * @return a pointer to the current tab's time interval.
48f6f981 523 */
524
224446ce 525const TimeWindow *lttvwindow_get_time_window(MainWindow *main_win);
3bc00fde 526
527
3bc00fde 528/**
5a5b35c5 529 * Function to get the current time of the current tab.
530 *
3bc00fde 531 * @param main_win the main window the viewer belongs to.
5a5b35c5 532 * @return a pointer to the current tab's current time.
48f6f981 533 */
534
224446ce 535const LttTime *lttvwindow_get_current_time(MainWindow *main_win);
48f6f981 536
48f6f981 537
538/**
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.
3bc00fde 542 */
543
224446ce 544//FIXME
545typedef void lttv_filter;
546//FIXME
547const lttv_filter *lttvwindow_get_filter(MainWindow *main_win);
3bc00fde 548
549
3bc00fde 550/**
551 * Function to get the stats of the traceset
5a5b35c5 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.
224446ce 554 * @param main_win the main window the viewer belongs to.
5a5b35c5 555 * @return A pointer to Traceset statistics.
224446ce 556 */
557
558LttvTracesetStats* lttvwindow_get_traceset_stats(MainWindow *main_win);
559
560/**
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.
3bc00fde 563 * @param main_win the main window the viewer belongs to.
5a5b35c5 564 * @return Context of the current tab.
3bc00fde 565 */
566
48f6f981 567
224446ce 568LttvTracesetContext* lttvwindow_get_traceset_context(MainWindow *main_win);
48f6f981 569
3bc00fde 570
This page took 0.049488 seconds and 4 git commands to generate.