1 #ifndef BABELTRACE_CTF_WRITER_VISITOR_H
2 #define BABELTRACE_CTF_WRITER_VISITOR_H
5 * BabelTrace - CTF writer: Visitor
7 * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
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:
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
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
29 * The Common Trace Format (CTF) Specification is available at
30 * http://www.efficios.com/ctf
38 @defgroup ctfirvisitor CTF IR visitor
40 @brief CTF IR visitor.
43 #include <babeltrace/trace-ir/visitor.h>
46 A CTF IR <strong><em>visitor</em></strong> is a function that you
47 can use to visit the hierarchy of a
48 \link ctfirtraceclass CTF IR trace class\endlink with
49 bt_ctf_trace_visit() or of a
50 \link ctfirstreamclass CTF IR stream class\endlink with
51 bt_ctf_stream_class_visit().
53 The traversal of the object's hierarchy is always done in a
60 @brief CTF IR visitor types and functions.
63 @addtogroup ctfirvisitor
69 @brief A CTF IR object wrapper.
71 This structure wraps both a CTF IR object and its type
72 (see #bt_object_type). It is used in the visiting function.
74 You can use the bt_object_get_type() and
75 bt_object_get_object() accessors to get the type and wrapped
76 CTF IR object of a CTF IR object wrapper.
78 A CTF IR object wrapper has <strong>no reference count</strong>: do \em
79 not use bt_object_put_ref() or bt_object_get_ref() on it.
83 struct bt_ctf_visitor_object
;
86 @brief CTF IR object wrapper type.
88 enum bt_ctf_visitor_object_type
{
89 /// Unknown (used for errors).
90 BT_CTF_VISITOR_OBJECT_TYPE_UNKNOWN
= -1,
92 /// \ref ctfirtraceclass.
93 BT_CTF_VISITOR_OBJECT_TYPE_TRACE
= 0,
95 /// \ref ctfirstreamclass.
96 BT_CTF_VISITOR_OBJECT_TYPE_STREAM_CLASS
= 1,
99 BT_CTF_VISITOR_OBJECT_TYPE_STREAM
= 2,
101 /// \ref ctfireventclass.
102 BT_CTF_VISITOR_OBJECT_TYPE_EVENT_CLASS
= 3,
105 BT_CTF_VISITOR_OBJECT_TYPE_EVENT
= 4,
107 /// Number of entries in this enumeration.
108 BT_CTF_VISITOR_OBJECT_TYPE_NR
,
112 @brief Visting function type.
114 A function of this type is called by bt_ctf_trace_visit() or
115 bt_ctf_stream_class_visit() when visiting the CTF IR object wrapper
118 \p object has <strong>no reference count</strong>: do \em not use
119 bt_object_put_ref() or bt_object_get_ref() on it.
121 @param[in] object Currently visited CTF IR object wrapper.
122 @param[in] data User data.
123 @returns 0 on success, or a negative value on error.
127 @sa bt_ctf_trace_visit(): Accepts a visitor to visit a trace class.
128 @sa bt_ctf_stream_class_visit(): Accepts a visitor to visit a stream
131 typedef int (*bt_ctf_visitor
)(struct bt_ctf_visitor_object
*object
,
135 @brief Returns the type of the CTF IR object wrapped by the CTF IR
136 object wrapper \p object.
138 @param[in] object Object wrapper of which to get the type.
139 @returns Type of \p object.
143 @sa bt_ctf_visitor_object_get_object(): Returns the object wrapped by a given
144 CTF IR object wrapper.
146 enum bt_ctf_visitor_object_type
bt_ctf_visitor_object_get_type(
147 struct bt_ctf_visitor_object
*object
);
150 @brief Returns the CTF IR object wrapped by the CTF IR object
153 The reference count of \p object is \em not incremented by this
154 function. On success, you must call bt_object_get_ref() on the return value to
155 have your own reference.
157 @param[in] object Object wrapper of which to get the wrapped
159 @returns CTF IR object wrapped by \p object.
162 @post The reference count of the returned object is not modified.
164 @sa bt_ctf_visitor_object_get_type(): Returns the type of a given
165 CTF IR object wrapper.
167 void *bt_ctf_visitor_object_get_object(struct bt_ctf_visitor_object
*object
);
175 #endif /* BABELTRACE_CTF_WRITER_VISITOR_H */