1 #ifndef BABELTRACE2_CTF_WRITER_VISITOR_H
2 #define BABELTRACE2_CTF_WRITER_VISITOR_H
5 * Copyright (c) 2010-2019 EfficiOS Inc. and Linux Foundation
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 @defgroup ctfirvisitor CTF IR visitor
33 @brief CTF IR visitor.
36 #include <babeltrace2/trace-ir/visitor.h>
39 A CTF IR <strong><em>visitor</em></strong> is a function that you
40 can use to visit the hierarchy of a
41 \link ctfirtraceclass CTF IR trace class\endlink with
42 bt_ctf_trace_visit() or of a
43 \link ctfirstreamclass CTF IR stream class\endlink with
44 bt_ctf_stream_class_visit().
46 The traversal of the object's hierarchy is always done in a
53 @brief CTF IR visitor types and functions.
56 @addtogroup ctfirvisitor
62 @brief A CTF IR object wrapper.
64 This structure wraps both a CTF IR object and its type
65 (see #bt_ctf_object_type). It is used in the visiting function.
67 You can use the bt_ctf_object_get_type() and
68 bt_ctf_object_get_object() accessors to get the type and wrapped
69 CTF IR object of a CTF IR object wrapper.
71 A CTF IR object wrapper has <strong>no reference count</strong>: do \em
72 not use bt_ctf_object_put_ref() or bt_ctf_object_get_ref() on it.
76 struct bt_ctf_visitor_object
;
79 @brief CTF IR object wrapper type.
81 enum bt_ctf_visitor_object_type
{
82 /// Unknown (used for errors).
83 BT_CTF_VISITOR_OBJECT_TYPE_UNKNOWN
= -1,
85 /// \ref ctfirtraceclass.
86 BT_CTF_VISITOR_OBJECT_TYPE_TRACE
= 0,
88 /// \ref ctfirstreamclass.
89 BT_CTF_VISITOR_OBJECT_TYPE_STREAM_CLASS
= 1,
92 BT_CTF_VISITOR_OBJECT_TYPE_STREAM
= 2,
94 /// \ref ctfireventclass.
95 BT_CTF_VISITOR_OBJECT_TYPE_EVENT_CLASS
= 3,
98 BT_CTF_VISITOR_OBJECT_TYPE_EVENT
= 4,
100 /// Number of entries in this enumeration.
101 BT_CTF_VISITOR_OBJECT_TYPE_NR
,
105 @brief Visting function type.
107 A function of this type is called by bt_ctf_trace_visit() or
108 bt_ctf_stream_class_visit() when visiting the CTF IR object wrapper
111 \p object has <strong>no reference count</strong>: do \em not use
112 bt_ctf_object_put_ref() or bt_ctf_object_get_ref() on it.
114 @param[in] object Currently visited CTF IR object wrapper.
115 @param[in] data User data.
116 @returns 0 on success, or a negative value on error.
120 @sa bt_ctf_trace_visit(): Accepts a visitor to visit a trace class.
121 @sa bt_ctf_stream_class_visit(): Accepts a visitor to visit a stream
124 typedef int (*bt_ctf_visitor
)(struct bt_ctf_visitor_object
*object
,
128 @brief Returns the type of the CTF IR object wrapped by the CTF IR
129 object wrapper \p object.
131 @param[in] object Object wrapper of which to get the type.
132 @returns Type of \p object.
136 @sa bt_ctf_visitor_object_get_object(): Returns the object wrapped by a given
137 CTF IR object wrapper.
139 enum bt_ctf_visitor_object_type
bt_ctf_visitor_object_get_type(
140 struct bt_ctf_visitor_object
*object
);
143 @brief Returns the CTF IR object wrapped by the CTF IR object
146 The reference count of \p object is \em not incremented by this
147 function. On success, you must call bt_ctf_object_get_ref() on the return value to
148 have your own reference.
150 @param[in] object Object wrapper of which to get the wrapped
152 @returns CTF IR object wrapped by \p object.
155 @post The reference count of the returned object is not modified.
157 @sa bt_ctf_visitor_object_get_type(): Returns the type of a given
158 CTF IR object wrapper.
160 void *bt_ctf_visitor_object_get_object(struct bt_ctf_visitor_object
*object
);
168 #endif /* BABELTRACE2_CTF_WRITER_VISITOR_H */