Notification iterator: generate automatic notifications when missing
[babeltrace.git] / include / babeltrace / graph / notification-iterator-internal.h
CommitLineData
33b34c43
PP
1#ifndef BABELTRACE_COMPONENT_NOTIFICATION_ITERATOR_INTERNAL_H
2#define BABELTRACE_COMPONENT_NOTIFICATION_ITERATOR_INTERNAL_H
47e5a032
JG
3
4/*
5 * BabelTrace - Notification Iterator Internal
6 *
7 * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
3230ee6b 8 * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
47e5a032
JG
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a copy
11 * of this software and associated documentation files (the "Software"), to deal
12 * in the Software without restriction, including without limitation the rights
13 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the Software is
15 * furnished to do so, subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 * SOFTWARE.
27 */
28
29#include <babeltrace/babeltrace-internal.h>
890882ef 30#include <babeltrace/object-internal.h>
fb2dcc52 31#include <babeltrace/ref-internal.h>
b2e0c907
PP
32#include <babeltrace/graph/notification.h>
33#include <babeltrace/graph/notification-iterator.h>
34#include <babeltrace/graph/private-notification-iterator.h>
47e5a032 35
3230ee6b
PP
36struct bt_port;
37
47e5a032 38struct bt_notification_iterator {
b8a06801 39 struct bt_object base;
3230ee6b
PP
40 struct bt_component *upstream_component; /* owned by this */
41 struct bt_port *upstream_port; /* owned by this */
42 struct bt_notification *current_notification; /* owned by this */
43 GQueue *queue; /* struct bt_notification * (owned by this) */
44
45 /*
46 * This hash table keeps the state of a stream as viewed by
47 * this notification iterator. This is used to:
48 *
49 * * Automatically enqueue "stream begin", "packet begin",
50 * "packet end", and "stream end" notifications depending
51 * on the stream's state and on the next notification returned
52 * by the upstream component.
53 *
54 * * Make sure that, once the notification iterator has seen
55 * a "stream end" notification for a given stream, that no
56 * other notifications which refer to this stream can be
57 * delivered by this iterator.
58 *
59 * The key (struct bt_ctf_stream *) is not owned by this. The
60 * value is an allocated state structure.
61 */
62 GHashTable *stream_states;
63
64 /*
65 * This is an array of actions which can be rolled back. It's
66 * similar to the memento pattern, but it's not exactly that. It
67 * is allocated once and reset for each notification to process.
68 * More details near the implementation.
69 */
70 GArray *actions;
71
72 bool is_ended;
47e5a032
JG
73 void *user_data;
74};
75
890882ef
PP
76static inline
77struct bt_notification_iterator *bt_notification_iterator_from_private(
78 struct bt_private_notification_iterator *private_notification_iterator)
79{
80 return (void *) private_notification_iterator;
81}
82
83static inline
84struct bt_private_notification_iterator *
85bt_private_notification_iterator_from_notification_iterator(
86 struct bt_notification_iterator *notification_iterator)
87{
88 return (void *) notification_iterator;
89}
90
47e5a032
JG
91/**
92 * Allocate a notification iterator.
93 *
94 * @param component Component instance
95 * @returns A notification iterator instance
96 */
97BT_HIDDEN
98struct bt_notification_iterator *bt_notification_iterator_create(
3230ee6b
PP
99 struct bt_component *upstream_component,
100 struct bt_port *upstream_port);
47e5a032
JG
101
102/**
103 * Validate a notification iterator.
104 *
105 * @param iterator Notification iterator instance
106 * @returns One of #bt_component_status values
107 */
108BT_HIDDEN
109enum bt_notification_iterator_status bt_notification_iterator_validate(
110 struct bt_notification_iterator *iterator);
111
33b34c43 112#endif /* BABELTRACE_COMPONENT_NOTIFICATION_ITERATOR_INTERNAL_H */
This page took 0.036962 seconds and 4 git commands to generate.