Fix: lib: add NULL check for destroy_listeners in destroy_component_class
[babeltrace.git] / src / ctf-writer / stream.h
CommitLineData
3dca2276 1/*
0235b0db 2 * SPDX-License-Identifier: MIT
3dca2276 3 *
0235b0db 4 * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
3dca2276
PP
5 *
6 * The Common Trace Format (CTF) Specification is available at
7 * http://www.efficios.com/ctf
8 */
9
0235b0db
MJ
10#ifndef BABELTRACE_CTF_WRITER_STREAM_INTERNAL_H
11#define BABELTRACE_CTF_WRITER_STREAM_INTERNAL_H
12
578e048b 13#include "common/assert.h"
91d81473 14#include "common/macros.h"
217cf9d3 15#include <babeltrace2-ctf-writer/stream.h>
578e048b 16#include "ctfser/ctfser.h"
3dca2276
PP
17#include <stdint.h>
18
578e048b
MJ
19#include "assert-pre.h"
20#include "object.h"
21#include "stream.h"
22#include "utils.h"
23
16ca5ff0
PP
24struct bt_ctf_stream_common;
25
26struct bt_ctf_stream_common {
e1e02a22 27 struct bt_ctf_object base;
16ca5ff0
PP
28 int64_t id;
29 struct bt_ctf_stream_class_common *stream_class;
30 GString *name;
31};
32
33BT_HIDDEN
34int bt_ctf_stream_common_initialize(
35 struct bt_ctf_stream_common *stream,
36 struct bt_ctf_stream_class_common *stream_class, const char *name,
e1e02a22 37 uint64_t id, bt_ctf_object_release_func release_func);
16ca5ff0
PP
38
39BT_HIDDEN
40void bt_ctf_stream_common_finalize(struct bt_ctf_stream_common *stream);
41
42static inline
43struct bt_ctf_stream_class_common *bt_ctf_stream_common_borrow_class(
44 struct bt_ctf_stream_common *stream)
45{
98b15851 46 BT_ASSERT_DBG(stream);
16ca5ff0
PP
47 return stream->stream_class;
48}
49
50static inline
51const char *bt_ctf_stream_common_get_name(struct bt_ctf_stream_common *stream)
52{
67d2ce02 53 BT_CTF_ASSERT_PRE_NON_NULL(stream, "Stream");
16ca5ff0
PP
54 return stream->name ? stream->name->str : NULL;
55}
56
57static inline
58int64_t bt_ctf_stream_common_get_id(struct bt_ctf_stream_common *stream)
59{
60 int64_t ret;
61
67d2ce02 62 BT_CTF_ASSERT_PRE_NON_NULL(stream, "Stream");
16ca5ff0
PP
63 ret = stream->id;
64 if (ret < 0) {
ef267d12 65 BT_LOGT("Stream's ID is not set: addr=%p, name=\"%s\"",
16ca5ff0
PP
66 stream, bt_ctf_stream_common_get_name(stream));
67 }
68
69 return ret;
70}
71
3dca2276 72struct bt_ctf_stream {
16ca5ff0 73 struct bt_ctf_stream_common common;
3dca2276
PP
74 struct bt_ctf_field *packet_header;
75 struct bt_ctf_field *packet_context;
76
77 /* Array of pointers to bt_ctf_event for the current packet */
78 GPtrArray *events;
013f35c6 79 struct bt_ctfser ctfser;
3dca2276
PP
80 unsigned int flushed_packet_count;
81 uint64_t discarded_events;
3dca2276
PP
82 uint64_t last_ts_end;
83};
84
3dca2276
PP
85BT_HIDDEN
86struct bt_ctf_stream *bt_ctf_stream_create_with_id(
87 struct bt_ctf_stream_class *stream_class,
88 const char *name, uint64_t id);
89
90#endif /* BABELTRACE_CTF_WRITER_STREAM_INTERNAL_H */
This page took 0.076363 seconds and 4 git commands to generate.