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,
20 #include <lttv/traceset.h>
21 #include <lttv/iattribute.h>
24 /* A trace is a sequence of events gathered in the same tracing session. The
25 events may be stored in several tracefiles in the same directory.
26 A trace set is defined when several traces are to be analyzed together,
27 possibly to study the interactions between events in the different traces.
30 struct _LttvTraceset
{
44 LttvTraceset
*lttv_traceset_new()
48 s
= g_new(LttvTraceset
, 1);
50 s
->traces
= g_ptr_array_new();
51 s
->a
= g_object_new(LTTV_ATTRIBUTE_TYPE
, NULL
);
55 char * lttv_traceset_name(LttvTraceset
* s
)
60 LttvTrace
*lttv_trace_new(LttTrace
*t
)
64 new_trace
= g_new(LttvTrace
, 1);
65 new_trace
->a
= g_object_new(LTTV_ATTRIBUTE_TYPE
, NULL
);
67 new_trace
->ref_count
= 0;
72 LttvTraceset
*lttv_traceset_copy(LttvTraceset
*s_orig
)
78 s
= g_new(LttvTraceset
, 1);
80 s
->traces
= g_ptr_array_new();
81 for(i
=0;i
<s_orig
->traces
->len
;i
++)
83 trace
= g_ptr_array_index(s_orig
->traces
, i
);
86 g_ptr_array_add(s
->traces
,
89 s
->a
= LTTV_ATTRIBUTE(lttv_iattribute_deep_copy(LTTV_IATTRIBUTE(s_orig
->a
)));
94 LttvTraceset
*lttv_traceset_load(const gchar
*filename
)
96 LttvTraceset
*s
= g_new(LttvTraceset
,1);
99 s
->filename
= g_strdup(filename
);
100 tf
= fopen(filename
,"r");
102 g_critical("NOT IMPLEMENTED : load traceset data from a XML file");
108 gint
lttv_traceset_save(LttvTraceset
*s
)
112 tf
= fopen(s
->filename
, "w");
114 g_critical("NOT IMPLEMENTED : save traceset data in a XML file");
120 void lttv_traceset_destroy(LttvTraceset
*s
)
124 for(i
=0;i
<s
->traces
->len
;i
++) {
125 LttvTrace
*trace
= g_ptr_array_index(s
->traces
, i
);
126 lttv_trace_unref(trace
);
127 if(lttv_trace_get_ref_number(trace
) == 0)
128 lttv_trace_destroy(trace
);
130 g_ptr_array_free(s
->traces
, TRUE
);
131 g_object_unref(s
->a
);
135 void lttv_trace_destroy(LttvTrace
*t
)
137 g_object_unref(t
->a
);
142 void lttv_traceset_add(LttvTraceset
*s
, LttvTrace
*t
)
145 g_ptr_array_add(s
->traces
, t
);
149 unsigned lttv_traceset_number(LttvTraceset
*s
)
151 return s
->traces
->len
;
155 LttvTrace
*lttv_traceset_get(LttvTraceset
*s
, unsigned i
)
157 g_assert(s
->traces
->len
> i
);
158 return ((LttvTrace
*)s
->traces
->pdata
[i
]);
162 void lttv_traceset_remove(LttvTraceset
*s
, unsigned i
)
165 g_assert(s
->traces
->len
> i
);
166 t
= (LttvTrace
*)s
->traces
->pdata
[i
];
168 g_ptr_array_remove_index(s
->traces
, i
);
172 /* A set of attributes is attached to each trace set, trace and tracefile
173 to store user defined data as needed. */
175 LttvAttribute
*lttv_traceset_attribute(LttvTraceset
*s
)
181 LttvAttribute
*lttv_trace_attribute(LttvTrace
*t
)
187 LttTrace
*lttv_trace(LttvTrace
*t
)
192 guint
lttv_trace_get_ref_number(LttvTrace
* t
)
197 guint
lttv_trace_ref(LttvTrace
* t
)
204 guint
lttv_trace_unref(LttvTrace
* t
)
This page took 0.054344 seconds and 4 git commands to generate.