Cleanup: remove private babeltrace.h
[babeltrace.git] / src / ctf-writer / stream.h
CommitLineData
3dca2276
PP
1#ifndef BABELTRACE_CTF_WRITER_STREAM_INTERNAL_H
2#define BABELTRACE_CTF_WRITER_STREAM_INTERNAL_H
3
4/*
3dca2276
PP
5 * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 *
7 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a copy
10 * of this software and associated documentation files (the "Software"), to deal
11 * in the Software without restriction, including without limitation the rights
12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 * copies of the Software, and to permit persons to whom the Software is
14 * furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * SOFTWARE.
26 *
27 * The Common Trace Format (CTF) Specification is available at
28 * http://www.efficios.com/ctf
29 */
30
578e048b 31#include "common/assert.h"
91d81473 32#include "common/macros.h"
3fadfbc0 33#include <babeltrace2/ctf-writer/stream.h>
578e048b 34#include "ctfser/ctfser.h"
3dca2276
PP
35#include <stdint.h>
36
578e048b
MJ
37#include "assert-pre.h"
38#include "object.h"
39#include "stream.h"
40#include "utils.h"
41
16ca5ff0
PP
42struct bt_ctf_stream_common;
43
44struct bt_ctf_stream_common {
e1e02a22 45 struct bt_ctf_object base;
16ca5ff0
PP
46 int64_t id;
47 struct bt_ctf_stream_class_common *stream_class;
48 GString *name;
49};
50
51BT_HIDDEN
52int bt_ctf_stream_common_initialize(
53 struct bt_ctf_stream_common *stream,
54 struct bt_ctf_stream_class_common *stream_class, const char *name,
e1e02a22 55 uint64_t id, bt_ctf_object_release_func release_func);
16ca5ff0
PP
56
57BT_HIDDEN
58void bt_ctf_stream_common_finalize(struct bt_ctf_stream_common *stream);
59
60static inline
61struct bt_ctf_stream_class_common *bt_ctf_stream_common_borrow_class(
62 struct bt_ctf_stream_common *stream)
63{
64 BT_ASSERT(stream);
65 return stream->stream_class;
66}
67
68static inline
69const char *bt_ctf_stream_common_get_name(struct bt_ctf_stream_common *stream)
70{
67d2ce02 71 BT_CTF_ASSERT_PRE_NON_NULL(stream, "Stream");
16ca5ff0
PP
72 return stream->name ? stream->name->str : NULL;
73}
74
75static inline
76int64_t bt_ctf_stream_common_get_id(struct bt_ctf_stream_common *stream)
77{
78 int64_t ret;
79
67d2ce02 80 BT_CTF_ASSERT_PRE_NON_NULL(stream, "Stream");
16ca5ff0
PP
81 ret = stream->id;
82 if (ret < 0) {
83 BT_LOGV("Stream's ID is not set: addr=%p, name=\"%s\"",
84 stream, bt_ctf_stream_common_get_name(stream));
85 }
86
87 return ret;
88}
89
3dca2276 90struct bt_ctf_stream {
16ca5ff0 91 struct bt_ctf_stream_common common;
3dca2276
PP
92 struct bt_ctf_field *packet_header;
93 struct bt_ctf_field *packet_context;
94
95 /* Array of pointers to bt_ctf_event for the current packet */
96 GPtrArray *events;
013f35c6 97 struct bt_ctfser ctfser;
3dca2276
PP
98 unsigned int flushed_packet_count;
99 uint64_t discarded_events;
3dca2276
PP
100 uint64_t last_ts_end;
101};
102
3dca2276
PP
103BT_HIDDEN
104struct bt_ctf_stream *bt_ctf_stream_create_with_id(
105 struct bt_ctf_stream_class *stream_class,
106 const char *name, uint64_t id);
107
108#endif /* BABELTRACE_CTF_WRITER_STREAM_INTERNAL_H */
This page took 0.047489 seconds and 4 git commands to generate.