#include <babeltrace/context.h>
#include <babeltrace/ctf/types.h>
#include <babeltrace/ctf/events.h>
+/* TODO: fix object model for format-agnostic callbacks */
+#include <babeltrace/ctf/events-internal.h>
#include <babeltrace/ctf/iterator.h>
#include <babeltrace/ctf-text/types.h>
#include <babeltrace/iterator.h>
*/
__thread int bt_ctf_last_field_error = 0;
-struct definition *bt_ctf_get_top_level_scope(struct bt_ctf_event *event,
+const struct definition *bt_ctf_get_top_level_scope(const struct bt_ctf_event *event,
enum bt_ctf_scope scope)
{
struct definition *tmp = NULL;
return NULL;
}
-struct definition *bt_ctf_get_field(struct bt_ctf_event *event,
- struct definition *scope,
+const struct definition *bt_ctf_get_field(const struct bt_ctf_event *event,
+ const struct definition *scope,
const char *field)
{
struct definition *def;
return NULL;
}
-struct definition *bt_ctf_get_index(struct bt_ctf_event *event,
- struct definition *field,
+const struct definition *bt_ctf_get_index(const struct bt_ctf_event *event,
+ const struct definition *field,
unsigned int index)
{
struct definition *ret = NULL;
return ret;
}
-const char *bt_ctf_event_name(struct bt_ctf_event *event)
+const char *bt_ctf_event_name(const struct bt_ctf_event *event)
{
struct ctf_event *event_class;
struct ctf_stream_class *stream_class;
return CTF_TYPE_UNKNOWN;
}
-int bt_ctf_get_field_list(struct bt_ctf_event *event,
- struct definition *scope,
+int bt_ctf_get_field_list(const struct bt_ctf_event *event,
+ const struct definition *scope,
struct definition const * const **list,
unsigned int *count)
{
goto error;
case CTF_TYPE_STRUCT:
{
- struct definition_struct *def_struct;
+ const struct definition_struct *def_struct;
- def_struct = container_of(scope, struct definition_struct, p);
+ def_struct = container_of(scope, const struct definition_struct, p);
if (!def_struct)
goto error;
if (def_struct->fields->pdata) {
goto error;
case CTF_TYPE_VARIANT:
{
- struct definition_variant *def_variant;
+ const struct definition_variant *def_variant;
- def_variant = container_of(scope, struct definition_variant, p);
+ def_variant = container_of(scope, const struct definition_variant, p);
if (!def_variant)
goto error;
if (def_variant->fields->pdata) {
}
case CTF_TYPE_ARRAY:
{
- struct definition_array *def_array;
+ const struct definition_array *def_array;
- def_array = container_of(scope, struct definition_array, p);
+ def_array = container_of(scope, const struct definition_array, p);
if (!def_array)
goto error;
if (def_array->elems->pdata) {
}
case CTF_TYPE_SEQUENCE:
{
- struct definition_sequence *def_sequence;
+ const struct definition_sequence *def_sequence;
- def_sequence = container_of(scope, struct definition_sequence, p);
+ def_sequence = container_of(scope, const struct definition_sequence, p);
if (!def_sequence)
goto error;
if (def_sequence->elems->pdata) {
return -1;
}
-uint64_t bt_ctf_get_timestamp_raw(struct bt_ctf_event *event)
+uint64_t bt_ctf_get_timestamp_raw(const struct bt_ctf_event *event)
{
if (event && event->stream->has_timestamp)
return ctf_get_timestamp_raw(event->stream,
return -1ULL;
}
-uint64_t bt_ctf_get_timestamp(struct bt_ctf_event *event)
+uint64_t bt_ctf_get_timestamp(const struct bt_ctf_event *event)
{
if (event && event->stream->has_timestamp)
return ctf_get_timestamp(event->stream,
#include "events-private.h"
struct bt_ctf_iter *bt_ctf_iter_create(struct bt_context *ctx,
- struct bt_iter_pos *begin_pos,
- struct bt_iter_pos *end_pos)
+ const struct bt_iter_pos *begin_pos,
+ const struct bt_iter_pos *end_pos)
{
struct bt_ctf_iter *iter;
int ret;
#include <babeltrace/ctf/callbacks-internal.h>
#include <glib.h>
+struct ctf_stream;
+struct ctf_stream_event;
+/*
+ * the structure to manipulate events
+ */
+struct bt_ctf_event {
+ struct ctf_stream *stream;
+ struct ctf_stream_event *event;
+};
+
struct bt_ctf_iter {
struct bt_iter parent;
struct bt_ctf_event current_ctf_event; /* last read event */
#include <stdint.h>
-struct ctf_stream;
-struct ctf_stream_event;
struct definition;
+struct bt_ctf_event;
/*
* the top-level scopes in CTF
CTF_STRING_UNKNOWN,
};
-/*
- * the structure to manipulate events
- */
-struct bt_ctf_event {
- struct ctf_stream *stream;
- struct ctf_stream_event *event;
-};
-
/*
* bt_ctf_get_top_level_scope: return a definition of the top-level scope
*
* between the enum and the actual definition of top-level scopes.
* On error return NULL.
*/
-struct definition *bt_ctf_get_top_level_scope(struct bt_ctf_event *event,
+const struct definition *bt_ctf_get_top_level_scope(const struct bt_ctf_event *event,
enum bt_ctf_scope scope);
/*
* bt_ctf_event_get_name: returns the name of the event or NULL on error
*/
-const char *bt_ctf_event_name(struct bt_ctf_event *event);
+const char *bt_ctf_event_name(const struct bt_ctf_event *event);
/*
* bt_ctf_get_timestamp_raw: returns the timestamp of the event as written in
* the packet or -1ULL on error
*/
-uint64_t bt_ctf_get_timestamp_raw(struct bt_ctf_event *event);
+uint64_t bt_ctf_get_timestamp_raw(const struct bt_ctf_event *event);
/*
* bt_ctf_get_timestamp: returns the timestamp of the event offsetted with the
* system clock source or -1ULL on error
*/
-uint64_t bt_ctf_get_timestamp(struct bt_ctf_event *event);
+uint64_t bt_ctf_get_timestamp(const struct bt_ctf_event *event);
/*
* bt_ctf_get_field_list: set list pointer to an array of definition
* pointers and set count to the number of elements in the array.
* Return 0 on success and a negative value on error.
*/
-int bt_ctf_get_field_list(struct bt_ctf_event *event,
- struct definition *scope,
+int bt_ctf_get_field_list(const struct bt_ctf_event *event,
+ const struct definition *scope,
struct definition const * const **list,
unsigned int *count);
/*
* bt_ctf_get_field: returns the definition of a specific field
*/
-struct definition *bt_ctf_get_field(struct bt_ctf_event *event,
- struct definition *scope,
+const struct definition *bt_ctf_get_field(const struct bt_ctf_event *event,
+ const struct definition *scope,
const char *field);
/*
* bt_ctf_get_index: if the field is an array or a sequence, return the element
* at position index, otherwise return NULL;
*/
-struct definition *bt_ctf_get_index(struct bt_ctf_event *event,
- struct definition *field,
+const struct definition *bt_ctf_get_index(const struct bt_ctf_event *event,
+ const struct definition *field,
unsigned int index);
/*
* trace) is the EOF criterion.
*/
struct bt_ctf_iter *bt_ctf_iter_create(struct bt_context *ctx,
- struct bt_iter_pos *begin_pos,
- struct bt_iter_pos *end_pos);
+ const struct bt_iter_pos *begin_pos,
+ const struct bt_iter_pos *end_pos);
/*
* bt_ctf_get_iter - get iterator from ctf iterator.
struct bt_iter {
struct ptr_heap *stream_heap;
struct bt_context *ctx;
- struct bt_iter_pos *end_pos;
+ const struct bt_iter_pos *end_pos;
};
/*
* trace) is the EOF criterion.
*/
struct bt_iter *bt_iter_create(struct bt_context *ctx,
- struct bt_iter_pos *begin_pos,
- struct bt_iter_pos *end_pos);
+ const struct bt_iter_pos *begin_pos,
+ const struct bt_iter_pos *end_pos);
/*
* bt_iter_destroy - Free a trace collection iterator.
int bt_iter_init(struct bt_iter *iter,
struct bt_context *ctx,
- struct bt_iter_pos *begin_pos,
- struct bt_iter_pos *end_pos);
+ const struct bt_iter_pos *begin_pos,
+ const struct bt_iter_pos *end_pos);
void bt_iter_fini(struct bt_iter *iter);
#endif /* _BABELTRACE_ITERATOR_INTERNAL_H */
/*
* Lookup helpers.
*/
-struct definition *lookup_definition(struct definition *definition,
+struct definition *lookup_definition(const struct definition *definition,
const char *field_name);
-struct definition_integer *lookup_integer(struct definition *definition,
+struct definition_integer *lookup_integer(const struct definition *definition,
const char *field_name,
int signedness);
-struct definition_enum *lookup_enum(struct definition *definition,
+struct definition_enum *lookup_enum(const struct definition *definition,
const char *field_name,
int signedness);
-struct definition *lookup_variant(struct definition *definition,
+struct definition *lookup_variant(const struct definition *definition,
const char *field_name);
static inline
int bt_iter_init(struct bt_iter *iter,
struct bt_context *ctx,
- struct bt_iter_pos *begin_pos,
- struct bt_iter_pos *end_pos)
+ const struct bt_iter_pos *begin_pos,
+ const struct bt_iter_pos *end_pos)
{
int i, stream_id;
int ret = 0;
}
struct bt_iter *bt_iter_create(struct bt_context *ctx,
- struct bt_iter_pos *begin_pos,
- struct bt_iter_pos *end_pos)
+ const struct bt_iter_pos *begin_pos,
+ const struct bt_iter_pos *end_pos)
{
struct bt_iter *iter;
int ret;
}
static struct definition_scope *
- get_definition_scope(struct definition *definition)
+ get_definition_scope(const struct definition *definition)
{
return definition->scope;
}
g_free(scope);
}
-struct definition *lookup_definition(struct definition *definition,
+struct definition *lookup_definition(const struct definition *definition,
const char *field_name)
{
struct definition_scope *scope = get_definition_scope(definition);
scope);
}
-struct definition_integer *lookup_integer(struct definition *definition,
+struct definition_integer *lookup_integer(const struct definition *definition,
const char *field_name,
int signedness)
{
return lookup_integer;
}
-struct definition_enum *lookup_enum(struct definition *definition,
+struct definition_enum *lookup_enum(const struct definition *definition,
const char *field_name,
int signedness)
{
return lookup_enum;
}
-struct definition *lookup_variant(struct definition *definition,
+struct definition *lookup_variant(const struct definition *definition,
const char *field_name)
{
struct definition *lookup;