2 * SPDX-License-Identifier: MIT
4 * Copyright (C) 2010-2019 EfficiOS Inc. and Linux Foundation
7 #ifndef BABELTRACE2_CTF_WRITER_VISITOR_H
8 #define BABELTRACE2_CTF_WRITER_VISITOR_H
15 @defgroup ctfirvisitor CTF IR visitor
17 @brief CTF IR visitor.
20 #include <babeltrace2/trace-ir/visitor.h>
23 A CTF IR <strong><em>visitor</em></strong> is a function that you
24 can use to visit the hierarchy of a
25 \link ctfirtraceclass CTF IR trace class\endlink with
26 bt_ctf_trace_visit() or of a
27 \link ctfirstreamclass CTF IR stream class\endlink with
28 bt_ctf_stream_class_visit().
30 The traversal of the object's hierarchy is always done in a
37 @brief CTF IR visitor types and functions.
40 @addtogroup ctfirvisitor
46 @brief A CTF IR object wrapper.
48 This structure wraps both a CTF IR object and its type
49 (see #bt_ctf_object_type). It is used in the visiting function.
51 You can use the bt_ctf_object_get_type() and
52 bt_ctf_object_get_object() accessors to get the type and wrapped
53 CTF IR object of a CTF IR object wrapper.
55 A CTF IR object wrapper has <strong>no reference count</strong>: do \em
56 not use bt_ctf_object_put_ref() or bt_ctf_object_get_ref() on it.
60 struct bt_ctf_visitor_object
;
63 @brief CTF IR object wrapper type.
65 enum bt_ctf_visitor_object_type
{
66 /// Unknown (used for errors).
67 BT_CTF_VISITOR_OBJECT_TYPE_UNKNOWN
= -1,
69 /// \ref ctfirtraceclass.
70 BT_CTF_VISITOR_OBJECT_TYPE_TRACE
= 0,
72 /// \ref ctfirstreamclass.
73 BT_CTF_VISITOR_OBJECT_TYPE_STREAM_CLASS
= 1,
76 BT_CTF_VISITOR_OBJECT_TYPE_STREAM
= 2,
78 /// \ref ctfireventclass.
79 BT_CTF_VISITOR_OBJECT_TYPE_EVENT_CLASS
= 3,
82 BT_CTF_VISITOR_OBJECT_TYPE_EVENT
= 4,
84 /// Number of entries in this enumeration.
85 BT_CTF_VISITOR_OBJECT_TYPE_NR
,
89 @brief Visting function type.
91 A function of this type is called by bt_ctf_trace_visit() or
92 bt_ctf_stream_class_visit() when visiting the CTF IR object wrapper
95 \p object has <strong>no reference count</strong>: do \em not use
96 bt_ctf_object_put_ref() or bt_ctf_object_get_ref() on it.
98 @param[in] object Currently visited CTF IR object wrapper.
99 @param[in] data User data.
100 @returns 0 on success, or a negative value on error.
104 @sa bt_ctf_trace_visit(): Accepts a visitor to visit a trace class.
105 @sa bt_ctf_stream_class_visit(): Accepts a visitor to visit a stream
108 typedef int (*bt_ctf_visitor
)(struct bt_ctf_visitor_object
*object
,
112 @brief Returns the type of the CTF IR object wrapped by the CTF IR
113 object wrapper \p object.
115 @param[in] object Object wrapper of which to get the type.
116 @returns Type of \p object.
120 @sa bt_ctf_visitor_object_get_object(): Returns the object wrapped by a given
121 CTF IR object wrapper.
123 enum bt_ctf_visitor_object_type
bt_ctf_visitor_object_get_type(
124 struct bt_ctf_visitor_object
*object
);
127 @brief Returns the CTF IR object wrapped by the CTF IR object
130 The reference count of \p object is \em not incremented by this
131 function. On success, you must call bt_ctf_object_get_ref() on the return value to
132 have your own reference.
134 @param[in] object Object wrapper of which to get the wrapped
136 @returns CTF IR object wrapped by \p object.
139 @post The reference count of the returned object is not modified.
141 @sa bt_ctf_visitor_object_get_type(): Returns the type of a given
142 CTF IR object wrapper.
144 void *bt_ctf_visitor_object_get_object(struct bt_ctf_visitor_object
*object
);
152 #endif /* BABELTRACE2_CTF_WRITER_VISITOR_H */