X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=lib%2Ftrace-ir%2Ffield-path.c;h=23b65a75c7573455fedd751dcb5fb8b2845c1392;hb=68b66a256a54d32992dfefeaad11eea88b7df234;hp=3303134b08ba3e248024642ac18ff90dd12877eb;hpb=c5b9b4417bedfbec9b5dd23b8395ccdd4eeffc44;p=babeltrace.git diff --git a/lib/trace-ir/field-path.c b/lib/trace-ir/field-path.c index 3303134b..23b65a75 100644 --- a/lib/trace-ir/field-path.c +++ b/lib/trace-ir/field-path.c @@ -22,17 +22,17 @@ */ #define BT_LOG_TAG "FIELD-PATH" -#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include -#include +#include #include static @@ -42,8 +42,8 @@ void destroy_field_path(struct bt_object *obj) BT_ASSERT(field_path); BT_LIB_LOGD("Destroying field path: %!+P", field_path); - g_array_free(field_path->indexes, TRUE); - field_path->indexes = NULL; + g_array_free(field_path->items, TRUE); + field_path->items = NULL; g_free(field_path); } @@ -61,8 +61,9 @@ struct bt_field_path *bt_field_path_create(void) } bt_object_init_shared(&field_path->base, destroy_field_path); - field_path->indexes = g_array_new(FALSE, FALSE, sizeof(uint64_t)); - if (!field_path->indexes) { + field_path->items = g_array_new(FALSE, FALSE, + sizeof(struct bt_field_path_item)); + if (!field_path->items) { BT_LOGE_STR("Failed to allocate a GArray."); goto error; } @@ -84,18 +85,36 @@ enum bt_scope bt_field_path_get_root_scope( return field_path->root; } -uint64_t bt_field_path_get_index_count(const struct bt_field_path *field_path) +uint64_t bt_field_path_get_item_count(const struct bt_field_path *field_path) { BT_ASSERT_PRE_NON_NULL(field_path, "Field path"); - return (uint64_t) field_path->indexes->len; + return (uint64_t) field_path->items->len; } -uint64_t bt_field_path_get_index_by_index( +const struct bt_field_path_item *bt_field_path_borrow_item_by_index_const( const struct bt_field_path *field_path, uint64_t index) { BT_ASSERT_PRE_NON_NULL(field_path, "Field path"); - BT_ASSERT_PRE_VALID_INDEX(index, field_path->indexes->len); - return bt_field_path_get_index_by_index_inline(field_path, index); + BT_ASSERT_PRE_VALID_INDEX(index, field_path->items->len); + return bt_field_path_borrow_item_by_index_inline(field_path, index); +} + +enum bt_field_path_item_type bt_field_path_item_get_type( + const struct bt_field_path_item *field_path_item) +{ + BT_ASSERT_PRE_NON_NULL(field_path_item, "Field path item"); + return field_path_item->type; +} + +uint64_t bt_field_path_item_index_get_index( + const struct bt_field_path_item *field_path_item) +{ + BT_ASSERT_PRE_NON_NULL(field_path_item, "Field path item"); + BT_ASSERT_PRE(field_path_item->type == BT_FIELD_PATH_ITEM_TYPE_INDEX, + "Field path item is not an index field path item: " + "addr=%p, type=%s", field_path_item, + bt_field_path_item_type_string(field_path_item->type)); + return field_path_item->index; } void bt_field_path_get_ref(const struct bt_field_path *field_path)