Remove bt_ctf_stream_class_get_event_class_by_name()
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 27 Apr 2017 23:06:09 +0000 (19:06 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 28 May 2017 16:57:41 +0000 (12:57 -0400)
CTF allows two event classes of the same stream class to have the same
name, but all event classes must have a unique ID. Remove
bt_ctf_stream_class_get_event_class_by_name() because this would need to
return a set of event classes, not just one, and this feature is not
strictly needed for the 2.0 target.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/babeltrace/ctf-ir/stream-class.h
lib/ctf-ir/stream-class.c
plugins/ctf/common/metadata/visitor-generate-ir.c
plugins/debug-info/copy.c
plugins/writer/write.c
tests/lib/test_ctf_writer.c

index 6a0e2e135f11fa1df2d961e2a1f0affedb4aa4e9..63d7e7d02dd3b9cda6ecf38aa493de94b21e23d2 100644 (file)
@@ -496,32 +496,10 @@ extern int64_t bt_ctf_stream_class_get_event_class_count(
 
 @sa bt_ctf_stream_class_get_event_class_by_id(): Finds an event class
        by ID.
-@sa bt_ctf_stream_class_get_event_class_by_name(): Finds an event class
-       by name.
 */
 extern struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_index(
                struct bt_ctf_stream_class *stream_class, uint64_t index);
 
-/**
-@brief  Returns the event class named \c name found in the CTF IR stream
-       class \p stream_class.
-
-@param[in] stream_class        Stream class of which to get the event class.
-@param[in] name                Name of the event class to find.
-@returns               Event class named \p name, or \c NULL
-                       on error.
-
-@prenotnull{stream_class}
-@prenotnull{name}
-@postrefcountsame{stream_class}
-@postsuccessrefcountretinc
-
-@sa bt_ctf_stream_class_get_event_class_by_id(): Finds an event class
-       by ID.
-*/
-extern struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_name(
-               struct bt_ctf_stream_class *stream_class, const char *name);
-
 /**
 @brief  Returns the event class with ID \c id found in the CTF IR stream
        class \p stream_class.
@@ -534,9 +512,6 @@ extern struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_name(
 @prenotnull{stream_class}
 @postrefcountsame{stream_class}
 @postsuccessrefcountretinc
-
-@sa bt_ctf_stream_class_get_event_class_by_name(): Finds an event class
-       by name.
 */
 extern struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_id(
                struct bt_ctf_stream_class *stream_class, uint64_t id);
index f9d91aaf651323fbe40611285b90b6896bd9ddc3..97b6e6593ab964b06e381eb1a3e21c03fa34d3e1 100644 (file)
@@ -284,16 +284,6 @@ void event_class_exists(gpointer element, gpointer query)
                goto end;
        }
 
-       /*
-        * Two event classes cannot share the same name in a given
-        * stream class.
-        */
-       if (!strcmp(bt_ctf_event_class_get_name(event_class_a),
-                       bt_ctf_event_class_get_name(event_class_b))) {
-               search_query->found = 1;
-               goto end;
-       }
-
        /*
         * Two event classes cannot share the same ID in a given
         * stream class.
@@ -520,32 +510,6 @@ end:
        return event_class;
 }
 
-struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_name(
-               struct bt_ctf_stream_class *stream_class, const char *name)
-{
-       size_t i;
-       struct bt_ctf_event_class *event_class = NULL;
-
-       if (!stream_class || !name) {
-               goto end;
-       }
-
-       for (i = 0; i < stream_class->event_classes->len; i++) {
-               struct bt_ctf_event_class *cur_event_class =
-                       g_ptr_array_index(stream_class->event_classes, i);
-               const char *cur_event_class_name =
-                       bt_ctf_event_class_get_name(cur_event_class);
-
-               if (!strcmp(name, cur_event_class_name)) {
-                       event_class = cur_event_class;
-                       bt_get(event_class);
-                       goto end;
-               }
-       }
-end:
-       return event_class;
-}
-
 struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_id(
                struct bt_ctf_stream_class *stream_class, uint64_t id)
 {
index cb50a7e767737fdcd622f1012c587cfd413cca8c..1572206c0c257b0a983d593ef256db32db63fe28 100644 (file)
@@ -3506,16 +3506,6 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node)
                goto error;
        }
 
-       eevent_class = bt_ctf_stream_class_get_event_class_by_name(stream_class,
-               event_name);
-       if (eevent_class) {
-               BT_PUT(eevent_class);
-               _PERROR("%s",
-                       "duplicate event with name \"%s\" in same stream");
-               ret = -EEXIST;
-               goto error;
-       }
-
        ret = bt_ctf_stream_class_add_event_class(stream_class, event_class);
        BT_PUT(event_class);
        if (ret) {
index 55cf1351bfe86017d96b36ab0f162412b1096edf..824774ff128ae36addb22c0a9ef6a5f22edacc4e 100644 (file)
@@ -981,8 +981,8 @@ struct bt_ctf_event_class *get_event_class(struct debug_info_iterator *debug_it,
                struct bt_ctf_stream_class *writer_stream_class,
                struct bt_ctf_event_class *event_class)
 {
-       return bt_ctf_stream_class_get_event_class_by_name(writer_stream_class,
-                       bt_ctf_event_class_get_name(event_class));
+       return bt_ctf_stream_class_get_event_class_by_id(writer_stream_class,
+                       bt_ctf_event_class_get_id(event_class));
 }
 
 static
index cd692db2aa0edccc10446041ebf1e0e6bc2bdf30..91b9289929385c1420ac149608242ec823d73cbb 100644 (file)
@@ -155,8 +155,8 @@ struct bt_ctf_event_class *get_event_class(struct writer_component *writer_compo
                struct bt_ctf_stream_class *writer_stream_class,
                struct bt_ctf_event_class *event_class)
 {
-       return bt_ctf_stream_class_get_event_class_by_name(writer_stream_class,
-                       bt_ctf_event_class_get_name(event_class));
+       return bt_ctf_stream_class_get_event_class_by_id(writer_stream_class,
+                       bt_ctf_event_class_get_id(event_class));
 }
 
 struct bt_ctf_writer *insert_new_writer(
index 7ea4b5831638b646108c1a712d7296f9c38b0d50..9a790bbc181b3c42b0a0e2918d91acd6f60f1d49 100644 (file)
@@ -61,7 +61,7 @@
 #define DEFAULT_CLOCK_TIME 0
 #define DEFAULT_CLOCK_VALUE 0
 
-#define NR_TESTS 611
+#define NR_TESTS 607
 
 static int64_t current_time = 42;
 
@@ -434,17 +434,6 @@ void append_simple_event(struct bt_ctf_stream_class *stream_class,
                "bt_ctf_stream_class_get_event_class_by_id returns a correct event class");
        bt_put(ret_event_class);
 
-       ok(bt_ctf_stream_class_get_event_class_by_name(NULL, "some event name") == NULL,
-               "bt_ctf_stream_class_get_event_class_by_name handles a NULL stream class correctly");
-       ok(bt_ctf_stream_class_get_event_class_by_name(stream_class, NULL) == NULL,
-               "bt_ctf_stream_class_get_event_class_by_name handles a NULL event class name correctly");
-       ok(bt_ctf_stream_class_get_event_class_by_name(stream_class, "some event name") == NULL,
-               "bt_ctf_stream_class_get_event_class_by_name handles non-existing event class names correctly");
-       ret_event_class = bt_ctf_stream_class_get_event_class_by_name(stream_class, "Simple Event");
-       ok(ret_event_class == simple_event_class,
-               "bt_ctf_stream_class_get_event_class_by_name returns a correct event class");
-       bt_put(ret_event_class);
-
        simple_event = bt_ctf_event_create(simple_event_class);
        ok(simple_event,
                "Instantiate an event containing a single integer field");
@@ -2500,8 +2489,8 @@ void append_existing_event_class(struct bt_ctf_stream_class *stream_class)
 
        event_class = bt_ctf_event_class_create("Simple Event");
        assert(event_class);
-       ok(bt_ctf_stream_class_add_event_class(stream_class, event_class),
-               "two event classes with the same name cannot cohabit within the same stream class");
+       ok(bt_ctf_stream_class_add_event_class(stream_class, event_class) == 0,
+               "two event classes with the same name may cohabit within the same stream class");
        bt_put(event_class);
 
        event_class = bt_ctf_event_class_create("different name, ok");
This page took 0.032256 seconds and 4 git commands to generate.