Commit | Line | Data |
---|---|---|
8bf65fbd JG |
1 | #ifndef BABELTRACE_CTF_IR_VISITOR_H |
2 | #define BABELTRACE_CTF_IR_VISITOR_H | |
3 | ||
4 | /* | |
5 | * BabelTrace - CTF IR: Visitor | |
6 | * | |
7 | * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com> | |
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 | ||
304b3717 PP |
37 | /** |
38 | @defgroup ctfirvisitor CTF IR visitor | |
39 | @ingroup ctfir | |
40 | @brief CTF IR visitor. | |
41 | ||
42 | A CTF IR <strong><em>visitor</em></strong> is a function that you | |
43 | can use to visit the hierarchy of a | |
44 | \link ctfirtraceclass CTF IR trace class\endlink with | |
45 | bt_ctf_trace_visit() or of a | |
46 | \link ctfirstreamclass CTF IR stream class\endlink with | |
47 | bt_ctf_stream_class_visit(). | |
48 | ||
49 | The traversal of the object's hierarchy is always done in a | |
50 | pre-order fashion. | |
51 | ||
52 | @sa ctfirstreamclass | |
53 | @sa ctfirtraceclass | |
54 | ||
55 | @file | |
56 | @brief CTF IR visitor types and functions. | |
57 | @sa ctfirvisitor | |
58 | ||
59 | @addtogroup ctfirvisitor | |
60 | @{ | |
61 | */ | |
62 | ||
63 | /** | |
64 | @struct bt_ctf_object | |
65 | @brief A CTF IR object wrapper. | |
66 | ||
67 | This structure wraps both a CTF IR object and its type | |
68 | (see #bt_ctf_object_type). It is used in the visiting function. | |
69 | ||
70 | You can use the bt_ctf_object_get_type() and | |
71 | bt_ctf_object_get_object() accessors to get the type and wrapped | |
72 | CTF IR object of a CTF IR object wrapper. | |
73 | ||
74 | A CTF IR object wrapper has <strong>no reference count</strong>: do \em | |
75 | not use bt_put() or bt_get() on it. | |
76 | ||
77 | @sa ctfirvisitor | |
78 | */ | |
d9a13d86 | 79 | struct bt_ctf_object; |
8bf65fbd | 80 | |
304b3717 PP |
81 | /** |
82 | @brief CTF IR object wrapper type. | |
83 | */ | |
d9a13d86 | 84 | enum bt_ctf_object_type { |
304b3717 | 85 | /// Unknown (used for errors). |
d9a13d86 | 86 | BT_CTF_OBJECT_TYPE_UNKNOWN = -1, |
304b3717 PP |
87 | |
88 | /// \ref ctfirtraceclass. | |
d9a13d86 | 89 | BT_CTF_OBJECT_TYPE_TRACE = 0, |
304b3717 PP |
90 | |
91 | /// \ref ctfirstreamclass. | |
d9a13d86 | 92 | BT_CTF_OBJECT_TYPE_STREAM_CLASS = 1, |
304b3717 PP |
93 | |
94 | /// \ref ctfirstream. | |
d9a13d86 | 95 | BT_CTF_OBJECT_TYPE_STREAM = 2, |
304b3717 PP |
96 | |
97 | /// \ref ctfireventclass. | |
d9a13d86 | 98 | BT_CTF_OBJECT_TYPE_EVENT_CLASS = 3, |
304b3717 PP |
99 | |
100 | /// \ref ctfirevent. | |
d9a13d86 | 101 | BT_CTF_OBJECT_TYPE_EVENT = 4, |
304b3717 PP |
102 | |
103 | /// Number of entries in this enumeration. | |
d9a13d86 | 104 | BT_CTF_OBJECT_TYPE_NR, |
8bf65fbd JG |
105 | }; |
106 | ||
304b3717 PP |
107 | /** |
108 | @brief Visting function type. | |
109 | ||
110 | A function of this type is called by bt_ctf_trace_visit() or | |
111 | bt_ctf_stream_class_visit() when visiting the CTF IR object wrapper | |
112 | \p object. | |
113 | ||
114 | \p object has <strong>no reference count</strong>: do \em not use | |
115 | bt_put() or bt_get() on it. | |
116 | ||
117 | @param[in] object Currently visited CTF IR object wrapper. | |
118 | @param[in] data User data. | |
119 | @returns 0 on success, or a negative value on error. | |
120 | ||
121 | @prenotnull{object} | |
122 | ||
123 | @sa bt_ctf_trace_visit(): Accepts a visitor to visit a trace class. | |
124 | @sa bt_ctf_stream_class_visit(): Accepts a visitor to visit a stream | |
125 | class. | |
126 | */ | |
d9a13d86 | 127 | typedef int (*bt_ctf_visitor)(struct bt_ctf_object *object, |
8bf65fbd JG |
128 | void *data); |
129 | ||
304b3717 PP |
130 | /** |
131 | @brief Returns the type of the CTF IR object wrapped by the CTF IR | |
132 | object wrapper \p object. | |
8bf65fbd | 133 | |
304b3717 PP |
134 | @param[in] object Object wrapper of which to get the type. |
135 | @returns Type of \p object. | |
136 | ||
137 | @prenotnull{object} | |
138 | ||
139 | @sa bt_ctf_object_get_object(): Returns the object wrapped by a given | |
140 | CTF IR object wrapper. | |
141 | */ | |
142 | enum bt_ctf_object_type bt_ctf_object_get_type(struct bt_ctf_object *object); | |
143 | ||
144 | /** | |
145 | @brief Returns the CTF IR object wrapped by the CTF IR object | |
146 | wrapper \p object. | |
147 | ||
148 | @param[in] object Object wrapper of which to get the wrapped | |
149 | CTF IR object. | |
150 | @returns CTF IR object wrapped by \p object. | |
151 | ||
152 | @prenotnull{object} | |
153 | ||
154 | @sa bt_ctf_object_get_type(): Returns the type of a given | |
155 | CTF IR object wrapper. | |
156 | */ | |
d9a13d86 | 157 | void *bt_ctf_object_get_object(struct bt_ctf_object *object); |
8bf65fbd | 158 | |
304b3717 PP |
159 | /** @} */ |
160 | ||
8bf65fbd JG |
161 | #ifdef __cplusplus |
162 | } | |
163 | #endif | |
164 | ||
165 | #endif /* BABELTRACE_CTF_IR_VISITOR_H */ |