fscanf(fp,"</ATTRS>");
}
+static LttvAttribute *
+new_attribute (LttvAttribute *self)
+{
+ return g_object_new(LTTV_ATTRIBUTE_TYPE, NULL);
+}
+
static void
attribute_interface_init (gpointer g_iface, gpointer iface_data)
{
LttvIAttributeClass *klass = (LttvIAttributeClass *)g_iface;
+ klass->new_attribute = (LttvIAttribute* (*) (LttvIAttribute *self))
+ new_attribute;
+
klass->get_number = (unsigned int (*) (LttvIAttribute *self))
lttv_attribute_get_number;
attribute_class_init (LttvAttributeClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
-
+
gobject_class->finalize = (void (*)(GObject *self))attribute_finalize;
}
}
}
+
/* Shallow and deep copies */
LttvIAttribute *lttv_iattribute_shallow_copy(LttvIAttribute *self)
int nb_attributes = lttv_iattribute_get_number(self);
- copy = LTTV_IATTRIBUTE(g_object_new(G_OBJECT_TYPE(self),NULL));
+ copy = LTTV_IATTRIBUTE_GET_CLASS(self)->new_attribute(NULL);
for(i = 0 ; i < nb_attributes ; i++) {
t = lttv_iattribute_get(self, i, &name, &v);
v_copy = lttv_iattribute_add(copy, name, t);
lttv_iattribute_copy_value(t, v_copy, v);
}
+ return copy;
}
LttvIAttribute *lttv_iattribute_deep_copy(LttvIAttribute *self)
int nb_attributes = lttv_iattribute_get_number(self);
- copy = LTTV_IATTRIBUTE(g_object_new(G_OBJECT_TYPE(self), NULL));
+ copy = LTTV_IATTRIBUTE_GET_CLASS(self)->new_attribute(NULL);
for(i = 0 ; i < nb_attributes ; i++) {
t = lttv_iattribute_get(self, i, &name, &v);
}
else lttv_iattribute_copy_value(t, v_copy, v);
}
+ return copy;
}
void lttv_iattribute_copy_value(LttvAttributeType t, LttvAttributeValue dest,
struct _LttvIAttributeClass {
GTypeInterface parent;
+ LttvIAttribute* (*new_attribute) (LttvIAttribute *self);
+
unsigned int (*get_number) (LttvIAttribute *self);
gboolean (*named) (LttvIAttribute *self, gboolean *homogeneous);
#include <lttv/traceset.h>
+#include <lttv/iattribute.h>
#include <stdio.h>
/* A trace is a sequence of events gathered in the same tracing session. The
s->traces,
g_ptr_array_index(s_orig->traces, i));
}
- s->a = LTTV_ATTRIBUTE(lttv_iattribute_deep_copy(LTTV_IATTRIBUTE(s_orig->a)));
+ s->a = LTTV_ATTRIBUTE(lttv_iattribute_deep_copy((LttvIAttribute*)s_orig->a));
return s;
}