Class: Babeltrace2Gen::BTEventClass
- Inherits:
-
Object
- Object
- Babeltrace2Gen::BTEventClass
- Extended by:
- BTFromH
- Defined in:
- lib/metababel/bt2_trace_class_generator.rb
Constant Summary collapse
- BT_MATCH_ATTRS =
%i[parent name specific_context_field_class payload_field_class]
Constants included from BTPrinter
Babeltrace2Gen::BTPrinter::INDENT_INCREMENT
Instance Attribute Summary collapse
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#payload_field_class ⇒ Object
readonly
Returns the value of attribute payload_field_class.
-
#register ⇒ Object
readonly
Returns the value of attribute register.
-
#set_id ⇒ Object
readonly
Returns the value of attribute set_id.
-
#specific_context_field_class ⇒ Object
readonly
Returns the value of attribute specific_context_field_class.
Attributes included from BTLocator
Instance Method Summary collapse
- #get_declarator(trace_class:, variable:, stream_class:) ⇒ Object
- #get_getter(event:, arg_variables:) ⇒ Object
- #get_setter(event:, arg_variables:) ⇒ Object
-
#initialize(parent:, name: nil, specific_context_field_class: nil, payload_field_class: nil, id: nil, set_id: nil, domain: nil, register: true) ⇒ BTEventClass
constructor
A new instance of BTEventClass.
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
Constructor Details
#initialize(parent:, name: nil, specific_context_field_class: nil, payload_field_class: nil, id: nil, set_id: nil, domain: nil, register: true) ⇒ BTEventClass
Returns a new instance of BTEventClass.
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/metababel/bt2_trace_class_generator.rb', line 250 def initialize(parent:, name: nil, specific_context_field_class: nil, payload_field_class: nil, id: nil, set_id: nil, domain: nil, register: true) @set_id = set_id @domain = domain @register = register @parent = parent @name = name raise 'Name is mandatory for BTEventClass' if name.nil? && !rec_trace_class.match if specific_context_field_class @specific_context_field_class = BTFieldClass.from_h(self, specific_context_field_class) end @payload_field_class = BTFieldClass.from_h(self, payload_field_class) if payload_field_class @id = id end |
Instance Attribute Details
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
248 249 250 |
# File 'lib/metababel/bt2_trace_class_generator.rb', line 248 def domain @domain end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
248 249 250 |
# File 'lib/metababel/bt2_trace_class_generator.rb', line 248 def name @name end |
#payload_field_class ⇒ Object (readonly)
Returns the value of attribute payload_field_class.
248 249 250 |
# File 'lib/metababel/bt2_trace_class_generator.rb', line 248 def payload_field_class @payload_field_class end |
#register ⇒ Object (readonly)
Returns the value of attribute register.
248 249 250 |
# File 'lib/metababel/bt2_trace_class_generator.rb', line 248 def register @register end |
#set_id ⇒ Object (readonly)
Returns the value of attribute set_id.
248 249 250 |
# File 'lib/metababel/bt2_trace_class_generator.rb', line 248 def set_id @set_id end |
#specific_context_field_class ⇒ Object (readonly)
Returns the value of attribute specific_context_field_class.
248 249 250 |
# File 'lib/metababel/bt2_trace_class_generator.rb', line 248 def specific_context_field_class @specific_context_field_class end |
Instance Method Details
#get_declarator(trace_class:, variable:, stream_class:) ⇒ Object
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
# File 'lib/metababel/bt2_trace_class_generator.rb', line 270 def get_declarator(trace_class:, variable:, stream_class:) # Store the variable name for introspection purposes (PATH) @variable = variable if @id pr "#{variable} = bt_event_class_create_with_id(#{stream_class}, #{@id});" else pr "#{variable} = bt_event_class_create(#{stream_class});" end pr "bt_event_class_set_name(#{variable}, \"#{@name}\");" if @name if @specific_context_field_class var_name = "#{variable}_sc_fc" scope do pr "bt_field_class *#{var_name};" @specific_context_field_class.get_declarator(trace_class: trace_class, variable: var_name) pr "bt_event_class_set_specific_context_field_class(#{variable}, #{var_name});" pr "bt_field_class_put_ref(#{var_name});" end end return unless @payload_field_class var_name = "#{variable}_p_fc" scope do pr "bt_field_class *#{var_name};" @payload_field_class.get_declarator(trace_class: trace_class, variable: var_name) pr "bt_event_class_set_payload_field_class(#{variable}, #{var_name});" pr "bt_field_class_put_ref(#{var_name});" end end |
#get_getter(event:, arg_variables:) ⇒ Object
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
# File 'lib/metababel/bt2_trace_class_generator.rb', line 328 def get_getter(event:, arg_variables:) if rec_trace_class.environment trace = 'trace' scope do pr "const bt_stream *stream = bt_event_borrow_stream_const(#{event});" pr "const bt_trace *#{trace} = bt_stream_borrow_trace_const(stream);" rec_trace_class.environment.get_getter(trace: trace, arg_variables: arg_variables) end end if rec_stream_class.event_common_context_field_class field = "#{event}_cc_f" scope do pr "const bt_field *#{field} = bt_event_borrow_common_context_field_const(#{event});" rec_stream_class.event_common_context_field_class.get_getter(variable: field, arg_variables: arg_variables) end end if @specific_context_field_class field = "#{event}_sc_f" scope do pr "const bt_field *#{field} = bt_event_borrow_specific_context_field_const(#{event});" @specific_context_field_class.get_getter(variable: field, arg_variables: arg_variables) end end return unless @payload_field_class field = "#{event}_p_f" scope do pr "const bt_field *#{field} = bt_event_borrow_payload_field_const(#{event});" @payload_field_class.get_getter(variable: field, arg_variables: arg_variables) end end |
#get_setter(event:, arg_variables:) ⇒ Object
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
# File 'lib/metababel/bt2_trace_class_generator.rb', line 302 def get_setter(event:, arg_variables:) if rec_stream_class.event_common_context_field_class field = "#{event}_cc_f" scope do pr "bt_field *#{field} = bt_event_borrow_common_context_field(#{event});" rec_stream_class.event_common_context_field_class.get_setter(variable: field, arg_variables: arg_variables) end end if @specific_context_field_class field = "#{event}_sc_f" scope do pr "bt_field *#{field} = bt_event_borrow_specific_context_field(#{event});" @specific_context_field_class.get_setter(variable: field, arg_variables: arg_variables) end end return unless @payload_field_class field = "#{event}_p_f" scope do pr "bt_field *#{field} = bt_event_borrow_payload_field(#{event});" @payload_field_class.get_setter(variable: field, arg_variables: arg_variables) end end |