lib: metadata: add missing non-const borrowing accessors
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 15 Mar 2019 22:03:01 +0000 (18:03 -0400)
committerFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 2 May 2019 20:50:15 +0000 (20:50 +0000)
Add a few missing non-const borrowing accessors in the metadata part of
trace IR. They are not strictly needed for anything written in C
(because since you own the non-const object, you typically don't need to
read a property that you set yourself), but they will help make some
binding wrapper APIs symmetrical.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
include/babeltrace/trace-ir/event-class.h
include/babeltrace/trace-ir/field-class.h
include/babeltrace/trace-ir/stream-class.h
lib/trace-ir/event-class.c
lib/trace-ir/field-class.c
lib/trace-ir/stream-class.c

index 7067b582ed5c0d1bef0e4a6e5af0a0e1132c4b50..50cefeff661d84d54e93e429b1b4d62121b544c4 100644 (file)
@@ -61,10 +61,16 @@ extern bt_event_class_status
 bt_event_class_set_specific_context_field_class(bt_event_class *event_class,
                bt_field_class *field_class);
 
+extern bt_field_class *
+bt_event_class_borrow_specific_context_field_class(bt_event_class *event_class);
+
 extern bt_event_class_status bt_event_class_set_payload_field_class(
                bt_event_class *event_class,
                bt_field_class *field_class);
 
+extern bt_field_class *bt_event_class_borrow_payload_field_class(
+               bt_event_class *event_class);
+
 #ifdef __cplusplus
 }
 #endif
index df5f87d9cc2ea3c73caf5b0951439dde9718cf03..a23deb58dbbaacca15faa44a56b1b52977373653 100644 (file)
@@ -86,6 +86,14 @@ extern bt_field_class_status bt_field_class_structure_append_member(
                bt_field_class *struct_field_class,
                const char *name, bt_field_class *field_class);
 
+extern void bt_field_class_structure_borrow_member_by_index(
+               bt_field_class *struct_field_class, uint64_t index,
+               const char **name, bt_field_class **field_class);
+
+extern
+bt_field_class *bt_field_class_structure_borrow_member_field_class_by_name(
+               bt_field_class *field_class, const char *name);
+
 extern bt_field_class *bt_field_class_static_array_create(
                bt_trace_class *trace_class,
                bt_field_class *elem_field_class, uint64_t length);
@@ -94,6 +102,9 @@ extern bt_field_class *bt_field_class_dynamic_array_create(
                bt_trace_class *trace_class,
                bt_field_class *elem_field_class);
 
+extern bt_field_class *bt_field_class_array_borrow_element_field_class(
+               bt_field_class *field_class);
+
 extern bt_field_class_status
 bt_field_class_dynamic_array_set_length_field_class(
                bt_field_class *field_class,
@@ -110,6 +121,14 @@ extern bt_field_class_status bt_field_class_variant_append_option(
                bt_field_class *var_field_class,
                const char *name, bt_field_class *field_class);
 
+extern void bt_field_class_variant_borrow_option_by_index(
+               bt_field_class *variant_field_class, uint64_t index,
+               const char **name, bt_field_class **field_class);
+
+extern
+bt_field_class *bt_field_class_variant_borrow_option_field_class_by_name(
+               bt_field_class *field_class, const char *name);
+
 #ifdef __cplusplus
 }
 #endif
index 836979df6dfefcf4b9d7000e763fbaf3dd99e144..863f293691e51b31e8a7b5a6ade81ebe59e5fe76 100644 (file)
@@ -65,11 +65,19 @@ bt_stream_class_set_packet_context_field_class(
                bt_stream_class *stream_class,
                bt_field_class *field_class);
 
+extern bt_field_class *
+bt_stream_class_borrow_packet_context_field_class(
+               bt_stream_class *stream_class);
+
 extern bt_stream_class_status
 bt_stream_class_set_event_common_context_field_class(
                bt_stream_class *stream_class,
                bt_field_class *field_class);
 
+extern bt_field_class *
+bt_stream_class_borrow_event_common_context_field_class(
+               bt_stream_class *stream_class);
+
 extern bt_event_class *
 bt_stream_class_borrow_event_class_by_index(
                bt_stream_class *stream_class, uint64_t index);
index 6ed174bb3dccad109b587a02a5eab18c06a8977f..0dc3f6724da1a1773aff9f127682827eae6deabb 100644 (file)
@@ -273,6 +273,14 @@ bt_event_class_borrow_specific_context_field_class_const(
        return event_class->specific_context_fc;
 }
 
+struct bt_field_class *
+bt_event_class_borrow_specific_context_field_class(
+               struct bt_event_class *event_class)
+{
+       BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
+       return event_class->specific_context_fc;
+}
+
 enum bt_event_class_status bt_event_class_set_specific_context_field_class(
                struct bt_event_class *event_class,
                struct bt_field_class *field_class)
@@ -329,6 +337,13 @@ const struct bt_field_class *bt_event_class_borrow_payload_field_class_const(
        return event_class->payload_fc;
 }
 
+struct bt_field_class *bt_event_class_borrow_payload_field_class(
+               struct bt_event_class *event_class)
+{
+       BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
+       return event_class->payload_fc;
+}
+
 enum bt_event_class_status bt_event_class_set_payload_field_class(
                struct bt_event_class *event_class,
                struct bt_field_class *field_class)
index 02a59d94301105f079917f0930f77f036b4a946e..59a2c1f50ecf0d2c160662b65aff78f9aec0dd1a 100644 (file)
@@ -787,7 +787,8 @@ enum bt_field_class_status bt_field_class_structure_append_member(
 {
 
        BT_ASSERT_PRE_NON_NULL(fc, "Field class");
-       BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_STRUCTURE, "Field class");
+       BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_STRUCTURE,
+               "Field class");
        return append_named_field_class_to_container_field_class((void *) fc,
                name, member_fc);
 }
@@ -798,17 +799,18 @@ uint64_t bt_field_class_structure_get_member_count(
        struct bt_field_class_structure *struct_fc = (void *) fc;
 
        BT_ASSERT_PRE_NON_NULL(fc, "Field class");
-       BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_STRUCTURE, "Field class");
+       BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_STRUCTURE,
+               "Field class");
        return (uint64_t) struct_fc->common.named_fcs->len;
 }
 
 static
-void borrow_named_field_class_from_container_field_class_at_index_const(
-               const struct bt_field_class_named_field_class_container *fc,
+void borrow_named_field_class_from_container_field_class_at_index(
+               struct bt_field_class_named_field_class_container *fc,
                uint64_t index, const char **name,
-               const struct bt_field_class **out_fc)
+               struct bt_field_class **out_fc)
 {
-       const struct bt_named_field_class *named_fc;
+       struct bt_named_field_class *named_fc;
 
        BT_ASSERT(fc);
        BT_ASSERT_PRE_NON_NULL(name, "Name");
@@ -824,19 +826,31 @@ void bt_field_class_structure_borrow_member_by_index_const(
                const char **name, const struct bt_field_class **out_fc)
 {
        BT_ASSERT_PRE_NON_NULL(fc, "Field class");
-       BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_STRUCTURE, "Field class");
-       borrow_named_field_class_from_container_field_class_at_index_const(
+       BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_STRUCTURE,
+               "Field class");
+       borrow_named_field_class_from_container_field_class_at_index(
+               (void *) fc, index, name, (void *) out_fc);
+}
+
+void bt_field_class_structure_borrow_member_by_index(
+               struct bt_field_class *fc, uint64_t index,
+               const char **name, struct bt_field_class **out_fc)
+{
+       BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+       BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_STRUCTURE,
+               "Field class");
+       borrow_named_field_class_from_container_field_class_at_index(
                (void *) fc, index, name, out_fc);
 }
 
 static
-const struct bt_field_class *
-borrow_field_class_from_container_field_class_by_name_const(
-               const struct bt_field_class_named_field_class_container *fc,
+struct bt_field_class *
+borrow_field_class_from_container_field_class_by_name(
+               struct bt_field_class_named_field_class_container *fc,
                const char *name)
 {
-       const struct bt_field_class *ret_fc = NULL;
-       const struct bt_named_field_class *named_fc;
+       struct bt_field_class *ret_fc = NULL;
+       struct bt_named_field_class *named_fc;
        gpointer orig_key;
        gpointer value;
 
@@ -860,8 +874,20 @@ bt_field_class_structure_borrow_member_field_class_by_name_const(
                const struct bt_field_class *fc, const char *name)
 {
        BT_ASSERT_PRE_NON_NULL(fc, "Field class");
-       BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_STRUCTURE, "Field class");
-       return borrow_field_class_from_container_field_class_by_name_const(
+       BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_STRUCTURE,
+               "Field class");
+       return borrow_field_class_from_container_field_class_by_name(
+                       (void *) fc, name);
+}
+
+struct bt_field_class *
+bt_field_class_structure_borrow_member_field_class_by_name(
+               struct bt_field_class *fc, const char *name)
+{
+       BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+       BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_STRUCTURE,
+               "Field class");
+       return borrow_field_class_from_container_field_class_by_name(
                        (void *) fc, name);
 }
 
@@ -944,7 +970,17 @@ bt_field_class_variant_borrow_option_field_class_by_name_const(
 {
        BT_ASSERT_PRE_NON_NULL(fc, "Field class");
        BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_VARIANT, "Field class");
-       return borrow_field_class_from_container_field_class_by_name_const(
+       return borrow_field_class_from_container_field_class_by_name(
+               (void *) fc, name);
+}
+
+struct bt_field_class *
+bt_field_class_variant_borrow_option_field_class_by_name(
+               struct bt_field_class *fc, const char *name)
+{
+       BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+       BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_VARIANT, "Field class");
+       return borrow_field_class_from_container_field_class_by_name(
                (void *) fc, name);
 }
 
@@ -963,7 +999,17 @@ void bt_field_class_variant_borrow_option_by_index_const(
 {
        BT_ASSERT_PRE_NON_NULL(fc, "Field class");
        BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_VARIANT, "Field class");
-       borrow_named_field_class_from_container_field_class_at_index_const(
+       borrow_named_field_class_from_container_field_class_at_index(
+               (void *) fc, index, name, (void *) out_fc);
+}
+
+void bt_field_class_variant_borrow_option_by_index(
+               struct bt_field_class *fc, uint64_t index,
+               const char **name, struct bt_field_class **out_fc)
+{
+       BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+       BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_VARIANT, "Field class");
+       borrow_named_field_class_from_container_field_class_at_index(
                (void *) fc, index, name, out_fc);
 }
 
@@ -1047,6 +1093,16 @@ bt_field_class_array_borrow_element_field_class_const(
        return array_fc->element_fc;
 }
 
+struct bt_field_class *
+bt_field_class_array_borrow_element_field_class(struct bt_field_class *fc)
+{
+       struct bt_field_class_array *array_fc = (void *) fc;
+
+       BT_ASSERT_PRE_NON_NULL(fc, "Field class");
+       BT_ASSERT_PRE_FC_IS_ARRAY(fc, "Field class");
+       return array_fc->element_fc;
+}
+
 uint64_t bt_field_class_static_array_get_length(const struct bt_field_class *fc)
 {
        const struct bt_field_class_static_array *array_fc = (const void *) fc;
index b76580d5b4796af6643e0f9c447ebf9fbb1df095..1271374260a1fc513f9546b8975512706708828e 100644 (file)
@@ -284,6 +284,14 @@ bt_stream_class_borrow_packet_context_field_class_const(
        return stream_class->packet_context_fc;
 }
 
+struct bt_field_class *
+bt_stream_class_borrow_packet_context_field_class(
+               struct bt_stream_class *stream_class)
+{
+       BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
+       return stream_class->packet_context_fc;
+}
+
 enum bt_stream_class_status bt_stream_class_set_packet_context_field_class(
                struct bt_stream_class *stream_class,
                struct bt_field_class *field_class)
@@ -334,6 +342,14 @@ bt_stream_class_borrow_event_common_context_field_class_const(
        return stream_class->event_common_context_fc;
 }
 
+struct bt_field_class *
+bt_stream_class_borrow_event_common_context_field_class(
+               struct bt_stream_class *stream_class)
+{
+       BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
+       return stream_class->event_common_context_fc;
+}
+
 enum bt_stream_class_status
 bt_stream_class_set_event_common_context_field_class(
                struct bt_stream_class *stream_class,
This page took 0.028816 seconds and 4 git commands to generate.