Class: Babeltrace2Gen::BTStreamClass
- Inherits:
-
Object
- Object
- Babeltrace2Gen::BTStreamClass
- Extended by:
- BTFromH
- Defined in:
- lib/metababel/bt2_trace_class_generator.rb
Constant Summary collapse
- BT_MATCH_ATTRS =
%i[parent name packet_context_field_class event_common_context_field_class default_clock_class]
Constants included from BTPrinter
Babeltrace2Gen::BTPrinter::INDENT_INCREMENT
Instance Attribute Summary collapse
-
#default_clock_class ⇒ Object
readonly
Returns the value of attribute default_clock_class.
-
#event_classes ⇒ Object
readonly
Returns the value of attribute event_classes.
-
#event_common_context_field_class ⇒ Object
readonly
Returns the value of attribute event_common_context_field_class.
-
#get_getter(event:, arg_variables:) ⇒ Object
readonly
The getters code generated from event_common_context_field_class does not include the event variable name used by the getters.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#packet_context_field_class ⇒ Object
readonly
Returns the value of attribute packet_context_field_class.
Attributes included from BTLocator
Instance Method Summary collapse
- #get_declarator(variable:, trace_class:, self_component:) ⇒ Object
-
#initialize(parent:, name: nil, packet_context_field_class: nil, event_common_context_field_class: nil, event_classes: [], id: nil, assigns_automatic_event_class_id: nil, assigns_automatic_stream_id: nil, default_clock_class: nil) ⇒ BTStreamClass
constructor
A new instance of BTStreamClass.
Methods included from BTFromH
Methods included from BTMatch
Methods included from BTLocator
#rec_event_class, #rec_member_class, #rec_stream_class, #rec_trace_class, #resolve_path
Methods included from BTPrinter
context, #name_sanitized, pr, #scope
Methods included from BTUtils
Constructor Details
#initialize(parent:, name: nil, packet_context_field_class: nil, event_common_context_field_class: nil, event_classes: [], id: nil, assigns_automatic_event_class_id: nil, assigns_automatic_stream_id: nil, default_clock_class: nil) ⇒ BTStreamClass
Returns a new instance of BTStreamClass.
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/metababel/bt2_trace_class_generator.rb', line 131 def initialize(parent:, name: nil, packet_context_field_class: nil, event_common_context_field_class: nil, event_classes: [], id: nil, assigns_automatic_event_class_id: nil, assigns_automatic_stream_id: nil, default_clock_class: nil) # Handle clock class property: # https://babeltrace.org/docs/v2.0/libbabeltrace2/group__api-tir-clock-cls.html#gae0f705eb48cd65784da28b1906ca05a5 @parent = parent @name = name # Should put assert to check for struct @packet_context_field_class = BTFieldClass.from_h(self, packet_context_field_class) if packet_context_field_class # Should put assert to check for struct if event_common_context_field_class @event_common_context_field_class = BTFieldClass.from_h(self, event_common_context_field_class) end @assigns_automatic_event_class_id = assigns_automatic_event_class_id @event_classes = event_classes.collect do |ec| if ec[:id].nil? != (@assigns_automatic_event_class_id.nil? || @assigns_automatic_event_class_id.nil) raise 'Incorrect id scheme' end BTEventClass.from_h(self, ec) end @assigns_automatic_stream_id = assigns_automatic_stream_id @id = id @default_clock_class = default_clock_class end |
Instance Attribute Details
#default_clock_class ⇒ Object (readonly)
Returns the value of attribute default_clock_class.
128 129 130 |
# File 'lib/metababel/bt2_trace_class_generator.rb', line 128 def default_clock_class @default_clock_class end |
#event_classes ⇒ Object (readonly)
Returns the value of attribute event_classes.
128 129 130 |
# File 'lib/metababel/bt2_trace_class_generator.rb', line 128 def event_classes @event_classes end |
#event_common_context_field_class ⇒ Object (readonly)
Returns the value of attribute event_common_context_field_class.
128 129 130 |
# File 'lib/metababel/bt2_trace_class_generator.rb', line 128 def event_common_context_field_class @event_common_context_field_class end |
#get_getter(event:, arg_variables:) ⇒ Object (readonly)
The getters code generated from event_common_context_field_class does not include the event variable name used by the getters. As we do not know the variable name that should be generated, we can not put it directly in the template, since, if the code generation generates another name we must update the template in addition.
229 230 231 |
# File 'lib/metababel/bt2_trace_class_generator.rb', line 229 def get_getter @get_getter end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
128 129 130 |
# File 'lib/metababel/bt2_trace_class_generator.rb', line 128 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
128 129 130 |
# File 'lib/metababel/bt2_trace_class_generator.rb', line 128 def name @name end |
#packet_context_field_class ⇒ Object (readonly)
Returns the value of attribute packet_context_field_class.
128 129 130 |
# File 'lib/metababel/bt2_trace_class_generator.rb', line 128 def packet_context_field_class @packet_context_field_class end |
Instance Method Details
#get_declarator(variable:, trace_class:, self_component:) ⇒ Object
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/metababel/bt2_trace_class_generator.rb', line 162 def get_declarator(variable:, trace_class:, self_component:) if @id pr "#{variable} = bt_stream_class_create_with_id(#{trace_class}, #{@id});" else pr "#{variable} = bt_stream_class_create(#{trace_class});" end pr "bt_stream_class_set_name(#{variable}, \"#{name}\");" if @name if @default_clock_class clock_class_name = "#{variable}_dcc" scope do pr "bt_clock_class *#{clock_class_name};" # TODO: @default_clock_class.get_declarator(variable: clock_class_name, self_component: self_component) pr "#{clock_class_name} = bt_clock_class_create(#{self_component});" pr "bt_stream_class_set_default_clock_class(#{variable}, #{clock_class_name});" pr "bt_clock_class_put_ref(#{clock_class_name});" end end if @packet_context_field_class # Support for packets required for packet_context_field_class # We do not support create_packet neither packet_beginning_default_clock_snapshot (BT_FALSE) nor packet_end_default_clock_snapshot (BT_FALSE) pr "bt_stream_class_set_supports_packets(#{variable}, BT_TRUE, BT_FALSE, BT_FALSE);" var_pc = "#{variable}_pc_fc" scope do pr "bt_field_class *#{var_pc};" @packet_context_field_class.get_declarator(trace_class: trace_class, variable: var_pc) pr "bt_stream_class_set_packet_context_field_class(#{variable}, #{var_pc});" pr "bt_field_class_put_ref(#{var_pc});" end end if @event_common_context_field_class var_ecc = "#{variable}_ecc_fc" scope do pr "bt_field_class *#{var_ecc};" @event_common_context_field_class.get_declarator(trace_class: trace_class, variable: var_ecc) pr "bt_stream_class_set_event_common_context_field_class(#{variable}, #{var_ecc});" pr "bt_field_class_put_ref(#{var_ecc});" end end # Need to do is after common_context because it can refer members to those bt_set_conditionally(@assigns_automatic_event_class_id) do |v| pr "bt_stream_class_set_assigns_automatic_event_class_id(#{variable}, #{v});" end @event_classes.each_with_index do |ec, i| var_name = "#{variable}_ec_#{i}" scope do pr "bt_event_class *#{var_name};" ec.get_declarator(trace_class: trace_class, variable: var_name, stream_class: variable) pr "bt_event_class_put_ref(#{var_name});" end end bt_set_conditionally(@assigns_automatic_stream_id) do |v| pr "bt_stream_class_set_assigns_automatic_stream_id(#{variable}, #{v});" end pr "bt_stream_class_put_ref(#{variable});" end |