1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Michel Dagenais
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,
23 #include <lttv/traceset.h>
24 #include <lttv/iattribute.h>
26 #include <babeltrace/context.h>
28 /* A trace is a sequence of events gathered in the same tracing session. The
29 events may be stored in several tracefiles in the same directory.
30 A trace set is defined when several traces are to be analyzed together,
31 possibly to study the interactions between events in the different traces.
34 struct _LttvTraceset
{
37 struct bt_context
*context
;
49 LttvTraceset
*lttv_traceset_new()
53 s
= g_new(LttvTraceset
, 1);
55 s
->traces
= g_ptr_array_new();
56 s
->context
= bt_context_create();
57 s
->a
= g_object_new(LTTV_ATTRIBUTE_TYPE
, NULL
);
61 char * lttv_traceset_name(LttvTraceset
* s
)
66 LttvTrace
*lttv_trace_new(LttTrace
*t
)
70 new_trace
= g_new(LttvTrace
, 1);
71 new_trace
->a
= g_object_new(LTTV_ATTRIBUTE_TYPE
, NULL
);
73 new_trace
->ref_count
= 0;
78 LttvTraceset
*lttv_traceset_copy(LttvTraceset
*s_orig
)
84 s
= g_new(LttvTraceset
, 1);
86 s
->traces
= g_ptr_array_new();
87 for(i
=0;i
<s_orig
->traces
->len
;i
++)
89 trace
= g_ptr_array_index(s_orig
->traces
, i
);
92 g_ptr_array_add(s
->traces
, trace
);
94 s
->context
= s_orig
->context
;
95 bt_context_get(s
->context
);
96 s
->a
= LTTV_ATTRIBUTE(lttv_iattribute_deep_copy(LTTV_IATTRIBUTE(s_orig
->a
)));
101 LttvTraceset
*lttv_traceset_load(const gchar
*filename
)
103 LttvTraceset
*s
= g_new(LttvTraceset
,1);
106 s
->filename
= g_strdup(filename
);
107 tf
= fopen(filename
,"r");
109 g_critical("NOT IMPLEMENTED : load traceset data from a XML file");
115 gint
lttv_traceset_save(LttvTraceset
*s
)
119 tf
= fopen(s
->filename
, "w");
121 g_critical("NOT IMPLEMENTED : save traceset data in a XML file");
127 void lttv_traceset_destroy(LttvTraceset
*s
)
131 for(i
=0;i
<s
->traces
->len
;i
++) {
132 LttvTrace
*trace
= g_ptr_array_index(s
->traces
, i
);
133 lttv_trace_unref(trace
);
134 if(lttv_trace_get_ref_number(trace
) == 0)
135 lttv_trace_destroy(trace
);
137 g_ptr_array_free(s
->traces
, TRUE
);
138 bt_context_put(s
->context
);
139 g_object_unref(s
->a
);
143 struct bt_context
*lttv_traceset_get_context(LttvTraceset
*s
)
148 void lttv_trace_destroy(LttvTrace
*t
)
150 g_object_unref(t
->a
);
155 void lttv_traceset_add(LttvTraceset
*s
, LttvTrace
*t
)
158 g_ptr_array_add(s
->traces
, t
);
162 unsigned lttv_traceset_number(LttvTraceset
*s
)
164 return s
->traces
->len
;
168 LttvTrace
*lttv_traceset_get(LttvTraceset
*s
, unsigned i
)
170 g_assert(s
->traces
->len
> i
);
171 return ((LttvTrace
*)s
->traces
->pdata
[i
]);
175 void lttv_traceset_remove(LttvTraceset
*s
, unsigned i
)
178 g_assert(s
->traces
->len
> i
);
179 t
= (LttvTrace
*)s
->traces
->pdata
[i
];
181 g_ptr_array_remove_index(s
->traces
, i
);
185 /* A set of attributes is attached to each trace set, trace and tracefile
186 to store user defined data as needed. */
188 LttvAttribute
*lttv_traceset_attribute(LttvTraceset
*s
)
194 LttvAttribute
*lttv_trace_attribute(LttvTrace
*t
)
200 LttTrace
*lttv_trace(LttvTrace
*t
)
205 guint
lttv_trace_get_ref_number(LttvTrace
* t
)
210 guint
lttv_trace_ref(LttvTrace
* t
)
217 guint
lttv_trace_unref(LttvTrace
* t
)
219 if(likely(t
->ref_count
> 0))
This page took 0.036417 seconds and 4 git commands to generate.