7126272251f932d9d9400c2e1737f65642b4590a
1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 XangXiu Yang
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 #include <lttv/lttvfilter.h>
22 #include <ltt/trace.h>
25 struct _LttvTracesetSelector
{
31 struct _LttvTraceSelector
{
33 GPtrArray
* tracefiles
;
34 GPtrArray
* eventtypes
;
38 struct _LttvTracefileSelector
{
39 char * tracefile_name
;
40 GPtrArray
* eventtypes
;
44 struct _LttvEventtypeSelector
{
45 char * eventtype_name
;
50 LttvTracesetSelector
*lttv_traceset_selector_new(char * name
)
52 LttvTracesetSelector
*s
;
54 s
= g_new(LttvTracesetSelector
, 1);
56 s
->traceset_name
= g_strdup(name
);
58 s
->traceset_name
= NULL
;
59 s
->traces
= g_ptr_array_new();
63 LttvTraceSelector
*lttv_trace_selector_new(LttTrace
*t
)
65 LttvTraceSelector
* trace
;
67 trace
= g_new(LttvTraceSelector
, 1);
68 trace
->trace_name
= g_strdup(ltt_trace_name(t
));
69 trace
->tracefiles
= g_ptr_array_new();
70 trace
->eventtypes
= g_ptr_array_new();
71 trace
->selected
= TRUE
;
75 LttvTracefileSelector
*lttv_tracefile_selector_new(LttTracefile
*t
)
77 LttvTracefileSelector
* tracefile
;
79 tracefile
= g_new(LttvTracefileSelector
, 1);
80 tracefile
->tracefile_name
= g_strdup(ltt_tracefile_name(t
));
81 tracefile
->eventtypes
= g_ptr_array_new();
82 tracefile
->selected
= TRUE
;
86 LttvEventtypeSelector
*lttv_eventtype_selector_new(LttEventType
* et
)
88 LttvEventtypeSelector
* ev
;
89 ev
= g_new(LttvEventtypeSelector
, 1);
90 ev
->eventtype_name
= g_strdup(ltt_eventtype_name(et
));
95 void lttv_traceset_selector_destroy(LttvTracesetSelector
*s
)
98 LttvTraceSelector
* t
;
100 for(i
=0;i
<s
->traces
->len
;i
++){
101 t
= (LttvTraceSelector
*)s
->traces
->pdata
[i
];
102 lttv_trace_selector_destroy(t
);
104 g_ptr_array_free(s
->traces
, TRUE
);
105 if(s
->traceset_name
) g_free(s
->traceset_name
);
109 void lttv_trace_selector_destroy(LttvTraceSelector
*s
)
112 LttvTracefileSelector
* t
;
113 LttvEventtypeSelector
* e
;
115 for(i
=0;i
<s
->tracefiles
->len
;i
++){
116 t
= (LttvTracefileSelector
*)s
->tracefiles
->pdata
[i
];
117 lttv_tracefile_selector_destroy(t
);
119 for(i
=0;i
<s
->eventtypes
->len
;i
++){
120 e
= (LttvEventtypeSelector
*)s
->eventtypes
->pdata
[i
];
121 lttv_eventtype_selector_destroy(e
);
123 if(s
->trace_name
) g_free(s
->trace_name
);
127 void lttv_tracefile_selector_destroy(LttvTracefileSelector
*t
)
130 LttvEventtypeSelector
* e
;
132 for(i
=0;i
<t
->eventtypes
->len
;i
++){
133 e
= (LttvEventtypeSelector
*)t
->eventtypes
->pdata
[i
];
134 lttv_eventtype_selector_destroy(e
);
137 if(t
->tracefile_name
) g_free(t
->tracefile_name
);
141 void lttv_eventtype_selector_destroy(LttvEventtypeSelector
*e
)
143 if(e
->eventtype_name
) g_free(e
->eventtype_name
);
147 void lttv_traceset_selector_trace_add(LttvTracesetSelector
*s
,
148 LttvTraceSelector
*t
)
150 g_ptr_array_add(s
->traces
, t
);
153 void lttv_trace_selector_tracefile_add(LttvTraceSelector
*s
,
154 LttvTracefileSelector
*t
)
156 g_ptr_array_add(s
->tracefiles
, t
);
159 void lttv_trace_selector_eventtype_add(LttvTraceSelector
*s
,
160 LttvEventtypeSelector
*et
)
162 g_ptr_array_add(s
->eventtypes
, et
);
165 void lttv_tracefile_selector_eventtype_add(LttvTracefileSelector
*s
,
166 LttvEventtypeSelector
*et
)
168 g_ptr_array_add(s
->eventtypes
, et
);
171 unsigned lttv_traceset_selector_trace_number(LttvTracesetSelector
*s
)
173 return s
->traces
->len
;
176 unsigned lttv_trace_selector_tracefile_number(LttvTraceSelector
*s
)
178 return s
->tracefiles
->len
;
181 unsigned lttv_trace_selector_eventtype_number(LttvTraceSelector
*s
)
183 return s
->eventtypes
->len
;
186 unsigned lttv_tracefile_selector_eventtype_number(LttvTracefileSelector
*s
)
188 return s
->eventtypes
->len
;
191 LttvTraceSelector
*lttv_traceset_selector_trace_get(LttvTracesetSelector
*s
,
194 g_assert(s
->traces
->len
> i
);
195 return ((LttvTraceSelector
*)s
->traces
->pdata
[i
]);
198 LttvTracefileSelector
*lttv_trace_selector_tracefile_get(LttvTraceSelector
*s
,
201 g_assert(s
->tracefiles
->len
> i
);
202 return ((LttvTracefileSelector
*)s
->tracefiles
->pdata
[i
]);
205 LttvEventtypeSelector
*lttv_trace_selector_eventtype_get(LttvTraceSelector
*s
,
208 g_assert(s
->eventtypes
->len
> i
);
209 return ((LttvEventtypeSelector
*)s
->eventtypes
->pdata
[i
]);
212 LttvEventtypeSelector
*lttv_tracefile_selector_eventtype_get(LttvTracefileSelector
*s
,
215 g_assert(s
->eventtypes
->len
> i
);
216 return ((LttvEventtypeSelector
*)s
->eventtypes
->pdata
[i
]);
219 void lttv_traceset_selector_trace_remove(LttvTracesetSelector
*s
, unsigned i
)
221 g_assert(s
->traces
->len
> i
);
222 g_ptr_array_remove_index(s
->traces
, i
);
225 void lttv_trace_selector_tracefile_remove(LttvTraceSelector
*s
, unsigned i
)
227 g_assert(s
->tracefiles
->len
> i
);
228 g_ptr_array_remove_index(s
->tracefiles
, i
);
231 void lttv_trace_selector_eventtype_remove(LttvTraceSelector
*s
, unsigned i
)
233 g_assert(s
->eventtypes
->len
> i
);
234 g_ptr_array_remove_index(s
->eventtypes
, i
);
237 void lttv_tracefile_selector_eventtype_remove(LttvTracefileSelector
*s
, unsigned i
)
239 g_assert(s
->eventtypes
->len
> i
);
240 g_ptr_array_remove_index(s
->eventtypes
, i
);
243 void lttv_trace_selector_set_selected(LttvTraceSelector
*s
, gboolean g
)
248 void lttv_tracefile_selector_set_selected(LttvTracefileSelector
*s
, gboolean g
)
253 void lttv_eventtype_selector_set_selected(LttvEventtypeSelector
*s
, gboolean g
)
258 gboolean
lttv_trace_selector_get_selected(LttvTraceSelector
*s
)
263 gboolean
lttv_tracefile_selector_get_selected(LttvTracefileSelector
*s
)
268 gboolean
lttv_eventtype_selector_get_selected(LttvEventtypeSelector
*s
)
273 char * lttv_traceset_selector_get_name(LttvTracesetSelector
*s
)
275 return s
->traceset_name
;
278 char * lttv_trace_selector_get_name(LttvTraceSelector
*s
)
280 return s
->trace_name
;
283 char * lttv_tracefile_selector_get_name(LttvTracefileSelector
*s
)
285 return s
->tracefile_name
;
288 char * lttv_eventtype_selector_get_name(LttvEventtypeSelector
*s
)
290 return s
->eventtype_name
;
293 LttvEventtypeSelector
* lttv_eventtype_selector_clone(LttvEventtypeSelector
* s
)
295 LttvEventtypeSelector
* ev
= g_new(LttvEventtypeSelector
, 1);
296 ev
->eventtype_name
= g_strdup(s
->eventtype_name
);
297 ev
->selected
= s
->selected
;
301 void lttv_eventtype_selector_copy(LttvTraceSelector
* s
, LttvTracefileSelector
* d
)
304 LttvEventtypeSelector
* ev
, *ev1
;
306 len
= s
->eventtypes
->len
;
308 ev
= lttv_trace_selector_eventtype_get(s
,i
);
309 ev1
= lttv_eventtype_selector_clone(ev
);
310 lttv_tracefile_selector_eventtype_add(d
,ev1
);
This page took 0.034448 seconds and 3 git commands to generate.