Big cleanup of network live
[lttngtop.git] / lib / babeltrace / ctf-writer / event.h
1 #ifndef BABELTRACE_CTF_WRITER_EVENT_H
2 #define BABELTRACE_CTF_WRITER_EVENT_H
3
4 /*
5 * BabelTrace - CTF Writer: Event
6 *
7 * Copyright 2013 EfficiOS Inc.
8 *
9 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this software and associated documentation files (the "Software"), to deal
13 * in the Software without restriction, including without limitation the rights
14 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 * copies of the Software, and to permit persons to whom the Software is
16 * furnished to do so, subject to the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 * SOFTWARE.
28 *
29 * The Common Trace Format (CTF) Specification is available at
30 * http://www.efficios.com/ctf
31 */
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 struct bt_ctf_event_class;
38 struct bt_ctf_event;
39 struct bt_ctf_field;
40 struct bt_ctf_field_type;
41
42 /*
43 * bt_ctf_event_class_create: create an event class.
44 *
45 * Allocate a new event class of the given name. The creation of an event class
46 * sets its reference count to 1.
47 *
48 * @param name Event class name (will be copied).
49 *
50 * Returns an allocated event class on success, NULL on error.
51 */
52 extern struct bt_ctf_event_class *bt_ctf_event_class_create(const char *name);
53
54 /*
55 * bt_ctf_event_class_add_field: add a field to an event class.
56 *
57 * Add a field of type "type" to the event class. The event class will share
58 * type's ownership by increasing its reference count. The "name" will be
59 * copied.
60 *
61 * @param event_class Event class.
62 * @param type Field type to add to the event class.
63 * @param name Name of the new field.
64 *
65 * Returns 0 on success, a negative value on error.
66 */
67 extern int bt_ctf_event_class_add_field(struct bt_ctf_event_class *event_class,
68 struct bt_ctf_field_type *type,
69 const char *name);
70
71 /*
72 * bt_ctf_event_class__get and bt_ctf_event_class_put: increment and decrement
73 * the event class' reference count.
74 *
75 * These functions ensure that the event class won't be destroyed while it
76 * is in use. The same number of get and put (plus one extra put to
77 * release the initial reference done at creation) have to be done to
78 * destroy an event class.
79 *
80 * When the event class' reference count is decremented to 0 by a
81 * bt_ctf_event_class_put, the event class is freed.
82 *
83 * @param event_class Event class.
84 */
85 extern void bt_ctf_event_class_get(struct bt_ctf_event_class *event_class);
86 extern void bt_ctf_event_class_put(struct bt_ctf_event_class *event_class);
87
88 /*
89 * bt_ctf_event_create: instanciate an event.
90 *
91 * Allocate a new event of the given event class. The creation of an event
92 * sets its reference count to 1. Each instance shares the ownership of the
93 * event class using its reference count.
94 *
95 * @param event_class Event class.
96 *
97 * Returns an allocated field type on success, NULL on error.
98 */
99 extern struct bt_ctf_event *bt_ctf_event_create(
100 struct bt_ctf_event_class *event_class);
101
102 /*
103 * bt_ctf_event_set_payload: set an event's field.
104 *
105 * Set a manually allocated field as an event's payload. The event will share
106 * the field's ownership by using its reference count.
107 * bt_ctf_field_put() must be called on the returned value.
108 *
109 * @param event Event instance.
110 * @param name Event field name.
111 * @param value Instance of a field whose type corresponds to the event's field.
112 *
113 * Returns 0 on success, a negative value on error.
114 */
115 extern int bt_ctf_event_set_payload(struct bt_ctf_event *event,
116 const char *name,
117 struct bt_ctf_field *value);
118
119 /*
120 * bt_ctf_event_get_payload: get an event's field.
121 *
122 * Returns the field matching "name". bt_ctf_field_put() must be called on the
123 * returned value.
124 *
125 * @param event Event instance.
126 * @param name Event field name.
127 *
128 * Returns a field instance on success, NULL on error.
129 */
130 extern struct bt_ctf_field *bt_ctf_event_get_payload(struct bt_ctf_event *event,
131 const char *name);
132
133 /*
134 * bt_ctf_event_get and bt_ctf_event_put: increment and decrement
135 * the event's reference count.
136 *
137 * These functions ensure that the event won't be destroyed while it
138 * is in use. The same number of get and put (plus one extra put to
139 * release the initial reference done at creation) have to be done to
140 * destroy an event.
141 *
142 * When the event's reference count is decremented to 0 by a
143 * bt_ctf_event_put, the event is freed.
144 *
145 * @param event Event instance.
146 */
147 extern void bt_ctf_event_get(struct bt_ctf_event *event);
148 extern void bt_ctf_event_put(struct bt_ctf_event *event);
149
150 #ifdef __cplusplus
151 }
152 #endif
153
154 #endif /* BABELTRACE_CTF_WRITER_EVENT_H */
This page took 0.031642 seconds and 4 git commands to generate.