Class: Babeltrace2::BTEventClass

Inherits:
BTSharedObject show all
Defined in:
lib/babeltrace2/trace-ir/event-class.rb

Constant Summary collapse

SetNameStatus =
BTEventClassSetNameStatus
LogLevel =
BTEventClassLogLevel
SetEmfUriStatus =
BTEventClassSetEmfUriStatus
SetFieldClassStatus =
BTEventClassSetFieldClassStatus

Instance Attribute Summary

Attributes inherited from BTObject

#handle

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BTSharedObject

inherited

Methods inherited from BTObject

#==, #to_ptr

Constructor Details

#initialize(handle = nil, retain: true, auto_release: true, stream_class: nil, id: nil) ⇒ BTEventClass

Returns a new instance of BTEventClass.



165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/babeltrace2/trace-ir/event-class.rb', line 165

def initialize(handle = nil, retain: true, auto_release: true,
               stream_class: nil, id: nil)
  if handle
    super(handle, retain: retain, auto_release: auto_release)
  else
    handle = if id
        Babeltrace2.bt_event_class_create_with_id(stream_class, id)
      else
        Babeltrace2.bt_event_class_create(stream_class)
      end
    raise Babeltrace2.process_error if handle.null?
    super(handle)
  end
end

Class Method Details

.from_h(trace_class, stream_class, h, stream_class_h) ⇒ Object



304
305
306
307
308
309
310
311
312
313
314
315
316
317
# File 'lib/babeltrace2/trace-ir/event-class.rb', line 304

def self.from_h(trace_class, stream_class, h, stream_class_h)
  id = stream_class.assigns_automatic_event_class_id? ? nil : h[:id]
  o = self.new(stream_class: stream_class, id: id)
  o.name = h[:name] if h[:name]
  o.log_level = h[:log_level] if h[:log_level]
  o.emf_uri = h[:emf_uri] if h[:emf_uri]
  o.specific_context_field_class = BTFieldClass.from_h(trace_class,
    h[:specific_context_field_class], stream_class_h) if h[:specific_context_field_class]
  o.payload_field_class = BTFieldClass.from_h(trace_class,
    h[:payload_field_class], stream_class_h) if h[:payload_field_class]
  o.user_attributes = h[:user_attributes] if h[:user_attributes]
  h[:bt_event_class] = o
  o
end

Instance Method Details

#emf_uri=(emf_uri) ⇒ Object



231
232
233
234
# File 'lib/babeltrace2/trace-ir/event-class.rb', line 231

def emf_uri=(emf_uri)
  set_emf_uri(emf_uri)
  emf_uri
end

#get_emf_uriObject Also known as: emf_uri



236
237
238
# File 'lib/babeltrace2/trace-ir/event-class.rb', line 236

def get_emf_uri
  Babeltrace2.bt_event_class_get_emf_uri(@handle)
end

#get_idObject Also known as: id



186
187
188
# File 'lib/babeltrace2/trace-ir/event-class.rb', line 186

def get_id
  Babeltrace2.bt_event_class_get_id(@handle)
end

#get_log_levelObject Also known as: log_level



217
218
219
220
221
222
# File 'lib/babeltrace2/trace-ir/event-class.rb', line 217

def get_log_level
  ptr = FFI::MemoryPointer.new(:int)
  res = Babeltrace2.bt_event_class_get_log_level(@handle, ptr)
  return nil if res == :BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE
  BTEventClassLogLevel.from_native(ptr.read_int, nil)
end

#get_nameObject Also known as: name



202
203
204
# File 'lib/babeltrace2/trace-ir/event-class.rb', line 202

def get_name
  Babeltrace2.bt_event_class_get_name(@handle)
end

#get_payload_field_classObject Also known as: payload_field_class



252
253
254
255
256
# File 'lib/babeltrace2/trace-ir/event-class.rb', line 252

def get_payload_field_class
  handle = Babeltrace2.bt_event_class_borrow_payload_field_class(@handle)
  return nil if handle.null?
  BTFieldClass.from_handle(handle)
end

#get_specific_context_field_classObject Also known as: specific_context_field_class



270
271
272
273
274
# File 'lib/babeltrace2/trace-ir/event-class.rb', line 270

def get_specific_context_field_class
  handle = Babeltrace2.bt_event_class_borrow_specific_context_field_class(@handle)
  return nil if handle.null?
  BTFieldClass.from_handle(handle)
end

#get_stream_classObject Also known as: stream_class



180
181
182
183
# File 'lib/babeltrace2/trace-ir/event-class.rb', line 180

def get_stream_class
  handle = Babeltrace2.bt_event_class_borrow_stream_class(@handle)
  BTStreamClass.new(handle, retain: true)
end

#get_user_attributesObject Also known as: user_attributes



287
288
289
# File 'lib/babeltrace2/trace-ir/event-class.rb', line 287

def get_user_attributes
  BTValueMap.new(Babeltrace2.bt_event_class_borrow_user_attributes(@handle), retain: true)
end

#log_level=(log_level) ⇒ Object



212
213
214
215
# File 'lib/babeltrace2/trace-ir/event-class.rb', line 212

def log_level=(log_level)
  set_log_level(log_level)
  log_level
end

#name=(name) ⇒ Object



197
198
199
200
# File 'lib/babeltrace2/trace-ir/event-class.rb', line 197

def name=(name)
  set_name(name)
  name
end

#payload_field_class=(field_class) ⇒ Object



247
248
249
250
# File 'lib/babeltrace2/trace-ir/event-class.rb', line 247

def payload_field_class=(field_class)
  set_payload_field_class(field_class)
  field_class
end

#set_emf_uri(emf_uri) ⇒ Object



225
226
227
228
229
# File 'lib/babeltrace2/trace-ir/event-class.rb', line 225

def set_emf_uri(emf_uri)
  res = Babeltrace2.bt_event_class_set_emf_uri(@handle, emf_uri)
  raise Babeltrace2.process_error(res) if res != :BT_EVENT_CLASS_SET_EMF_URI_STATUS_OK
  self
end

#set_log_level(log_level) ⇒ Object



207
208
209
210
# File 'lib/babeltrace2/trace-ir/event-class.rb', line 207

def set_log_level(log_level)
  Babeltrace2.bt_event_class_set_log_level(@handle, log_level)
  self
end

#set_name(name) ⇒ Object



191
192
193
194
195
# File 'lib/babeltrace2/trace-ir/event-class.rb', line 191

def set_name(name)
  res = Babeltrace2.bt_event_class_set_name(@handle, name)
  raise Babeltrace2.process_error(res) if res != :BT_EVENT_CLASS_SET_NAME_STATUS_OK
  self
end

#set_payload_field_class(field_class) ⇒ Object



241
242
243
244
245
# File 'lib/babeltrace2/trace-ir/event-class.rb', line 241

def set_payload_field_class(field_class)
  res = Babeltrace2.bt_event_class_set_payload_field_class(@handle, field_class)
  raise Babeltrace2.process_error(res) if res != :BT_EVENT_CLASS_SET_FIELD_CLASS_STATUS_OK
  self
end

#set_specific_context_field_class(field_class) ⇒ Object



259
260
261
262
263
# File 'lib/babeltrace2/trace-ir/event-class.rb', line 259

def set_specific_context_field_class(field_class)
  res = Babeltrace2.bt_event_class_set_specific_context_field_class(@handle, field_class)
  raise Babeltrace2.process_error(res) if res != :BT_EVENT_CLASS_SET_FIELD_CLASS_STATUS_OK
  self
end

#set_user_attributes(user_attributes) ⇒ Object



277
278
279
280
# File 'lib/babeltrace2/trace-ir/event-class.rb', line 277

def set_user_attributes(user_attributes)
  Babeltrace2.bt_event_class_set_user_attributes(@handle, BTValue.from_value(user_attributes))
  self
end

#specific_context_field_class=(field_class) ⇒ Object



265
266
267
268
# File 'lib/babeltrace2/trace-ir/event-class.rb', line 265

def specific_context_field_class=(field_class)
  set_specific_context_field_class(field_class)
  field_class
end

#to_hObject



292
293
294
295
296
297
298
299
300
301
302
# File 'lib/babeltrace2/trace-ir/event-class.rb', line 292

def to_h
  res = { id: id }
  res[:name] = name if name
  res[:log_level] = log_level if log_level
  res[:emf_uri] = emf_uri if emf_uri
  res[:specific_context_field_class] = specific_context_field_class.to_h if specific_context_field_class
  res[:payload_field_class] = payload_field_class.to_h if payload_field_class
  user_attributes_value = user_attributes.value
  res[:user_attributes] = user_attributes_value if !user_attributes_value.empty?
  res
end

#user_attributes=(user_attributes) ⇒ Object



282
283
284
285
# File 'lib/babeltrace2/trace-ir/event-class.rb', line 282

def user_attributes=(user_attributes)
  set_user_attributes(user_attributes)
  user_attributes
end