mega modif by Mathieu Desnoyers. Independant main windows, multiple tracesets, contro...
[lttv.git] / ltt / branches / poly / lttv / traceset.c
1
2 #include <lttv/traceset.h>
3 #include <stdio.h>
4
5 /* A trace is a sequence of events gathered in the same tracing session. The
6 events may be stored in several tracefiles in the same directory.
7 A trace set is defined when several traces are to be analyzed together,
8 possibly to study the interactions between events in the different traces.
9 */
10
11 struct _LttvTraceset {
12 char * filename;
13 GPtrArray *traces;
14 GPtrArray *attributes;
15 LttvAttribute *a;
16 };
17
18
19 LttvTraceset *lttv_traceset_new()
20 {
21 LttvTraceset *s;
22
23 s = g_new(LttvTraceset, 1);
24 s->filename = NULL;
25 s->traces = g_ptr_array_new();
26 s->attributes = g_ptr_array_new();
27 s->a = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL);
28 return s;
29 }
30
31 LttvTraceset *lttv_traceset_copy(LttvTraceset *s_orig)
32 {
33 int i;
34 LttvTraceset *s;
35
36 s = g_new(LttvTraceset, 1);
37 s->filename = NULL;
38 s->traces = g_ptr_array_new();
39 for(i=0;i<s_orig->traces->len;i++)
40 {
41 g_ptr_array_add(
42 s->traces,
43 ltt_trace_copy(g_ptr_array_index(s_orig->traces, i)));
44 }
45 s->attributes = g_ptr_array_new();
46 for(i=0;i<s_orig->attributes->len;i++)
47 {
48 g_ptr_array_add(
49 s->attributes,
50 lttv_iattribute_deep_copy(g_ptr_array_index(s_orig->attributes, i)));
51 }
52
53 s->a = LTTV_ATTRIBUTE(lttv_iattribute_deep_copy(LTTV_IATTRIBUTE(s_orig->a)));
54 return s;
55 }
56
57
58 LttvTraceset *lttv_traceset_load(const gchar *filename)
59 {
60 LttvTraceset *s = g_new(LttvTraceset,1);
61 FILE *tf;
62
63 s->filename = g_strdup(filename);
64 tf = fopen(filename,"r");
65
66 g_critical("NOT IMPLEMENTED : load traceset data from a XML file");
67
68 fclose(tf);
69 return s;
70 }
71
72 gint lttv_traceset_save(LttvTraceset *s)
73 {
74 FILE *tf;
75
76 tf = fopen(s->filename, "w");
77
78 g_critical("NOT IMPLEMENTED : save traceset data in a XML file");
79
80 fclose(tf);
81 return 0;
82 }
83 void lttv_traceset_destroy(LttvTraceset *s)
84 {
85 int i, nb;
86
87 for(i = 0 ; i < s->attributes->len ; i++) {
88 g_object_unref((LttvAttribute *)s->attributes->pdata[i]);
89 }
90 g_ptr_array_free(s->attributes, TRUE);
91 g_ptr_array_free(s->traces, TRUE);
92 g_object_unref(s->a);
93 g_free(s);
94 }
95
96 void lttv_traceset_add(LttvTraceset *s, LttTrace *t)
97 {
98 g_ptr_array_add(s->traces, t);
99 g_ptr_array_add(s->attributes, g_object_new(LTTV_ATTRIBUTE_TYPE, NULL));
100 }
101
102
103 unsigned lttv_traceset_number(LttvTraceset *s)
104 {
105 return s->traces->len;
106 }
107
108
109 LttTrace *lttv_traceset_get(LttvTraceset *s, unsigned i)
110 {
111 g_assert(s->traces->len > i);
112 return ((LttTrace *)s->traces->pdata[i]);
113 }
114
115
116 void lttv_traceset_remove(LttvTraceset *s, unsigned i)
117 {
118 g_ptr_array_remove_index(s->traces, i);
119 g_object_unref(s->attributes->pdata[i]);
120 g_ptr_array_remove_index(s->attributes,i);
121 }
122
123
124 /* A set of attributes is attached to each trace set, trace and tracefile
125 to store user defined data as needed. */
126
127 LttvAttribute *lttv_traceset_attribute(LttvTraceset *s)
128 {
129 return s->a;
130 }
131
132
133 LttvAttribute *lttv_traceset_trace_attribute(LttvTraceset *s, unsigned i)
134 {
135 return (LttvAttribute *)s->attributes->pdata[i];
136 }
This page took 0.046935 seconds and 4 git commands to generate.