@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.
@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);
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.
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)
{
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) {
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
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(
#define DEFAULT_CLOCK_TIME 0
#define DEFAULT_CLOCK_VALUE 0
-#define NR_TESTS 611
+#define NR_TESTS 607
static int64_t current_time = 42;
"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");
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");