X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Flttv%2Fiattribute.c;h=0271dddb65d3836e10932c31539e1bc5a6a398b6;hb=14c7af39fb81f679d7d666951af9816d0e4e5903;hp=ba17e3a23fd1167f9da632fc0c7a6361a802e367;hpb=d8f124de0295aea546b6debf5945bfeea2bbeb2a;p=lttv.git diff --git a/ltt/branches/poly/lttv/lttv/iattribute.c b/ltt/branches/poly/lttv/lttv/iattribute.c index ba17e3a2..0271dddb 100644 --- a/ltt/branches/poly/lttv/lttv/iattribute.c +++ b/ltt/branches/poly/lttv/lttv/iattribute.c @@ -16,6 +16,9 @@ * MA 02111-1307, USA. */ +#ifdef HAVE_CONFIG_H +#include +#endif #include @@ -66,9 +69,9 @@ gboolean lttv_iattribute_named(LttvIAttribute *self, gboolean *homogeneous) LttvAttributeType lttv_iattribute_get(LttvIAttribute *self, unsigned i, - LttvAttributeName *name, LttvAttributeValue *v) + LttvAttributeName *name, LttvAttributeValue *v, gboolean *is_named) { - return LTTV_IATTRIBUTE_GET_CLASS (self)->get (self, i, name, v); + return LTTV_IATTRIBUTE_GET_CLASS (self)->get (self, i, name, v, is_named); } @@ -85,6 +88,11 @@ LttvAttributeValue lttv_iattribute_add(LttvIAttribute *self, return LTTV_IATTRIBUTE_GET_CLASS (self)->add (self, name, t); } +LttvAttributeValue lttv_iattribute_add_unnamed(LttvIAttribute *self, + LttvAttributeName name, LttvAttributeType t) +{ + return LTTV_IATTRIBUTE_GET_CLASS (self)->add_unnamed (self, name, t); +} void lttv_iattribute_remove(LttvIAttribute *self, unsigned i) { @@ -104,6 +112,13 @@ LttvIAttribute* lttv_iattribute_find_subdir(LttvIAttribute *self, return LTTV_IATTRIBUTE_GET_CLASS (self)->find_subdir (self, name); } +LttvIAttribute* lttv_iattribute_find_subdir_unnamed(LttvIAttribute *self, + LttvAttributeName name) +{ + return LTTV_IATTRIBUTE_GET_CLASS (self)->find_subdir_unnamed (self, name); +} + + /* Find the named attribute in the table, which must be of the specified type. If it does not exist, it is created with a default value of 0 (NULL for @@ -174,6 +189,7 @@ gboolean lttv_iattribute_find_by_path(LttvIAttribute *self, char *path, } } + /* Shallow and deep copies */ LttvIAttribute *lttv_iattribute_shallow_copy(LttvIAttribute *self) @@ -186,17 +202,23 @@ LttvIAttribute *lttv_iattribute_shallow_copy(LttvIAttribute *self) LttvAttributeName name; + gboolean is_named; + int i; 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); + t = lttv_iattribute_get(self, i, &name, &v, &is_named); + if(is_named) + v_copy = lttv_iattribute_add(copy, name, t); + else + v_copy = lttv_iattribute_add_unnamed(copy, name, t); lttv_iattribute_copy_value(t, v_copy, v); } + return copy; } LttvIAttribute *lttv_iattribute_deep_copy(LttvIAttribute *self) @@ -209,21 +231,27 @@ LttvIAttribute *lttv_iattribute_deep_copy(LttvIAttribute *self) LttvAttributeName name; + gboolean is_named; + int i; 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); + t = lttv_iattribute_get(self, i, &name, &v, &is_named); + if(is_named) + v_copy = lttv_iattribute_add(copy, name, t); + else + v_copy = lttv_iattribute_add_unnamed(copy, name, t); if(t == LTTV_GOBJECT && LTTV_IS_IATTRIBUTE(*(v.v_gobject))) { child = LTTV_IATTRIBUTE(*(v.v_gobject)); *(v_copy.v_gobject) = G_OBJECT(lttv_iattribute_deep_copy(child)); } else lttv_iattribute_copy_value(t, v_copy, v); } + return copy; } void lttv_iattribute_copy_value(LttvAttributeType t, LttvAttributeValue dest, @@ -267,7 +295,8 @@ void lttv_iattribute_copy_value(LttvAttributeType t, LttvAttributeValue dest, break; case LTTV_GOBJECT: - *(dest.v_gobject) = *(src.v_gobject); + *(dest.v_gobject) = *(src.v_gobject); + if(*(dest.v_gobject) != NULL) g_object_ref(*(dest.v_gobject)); break; case LTTV_NONE: