Class: Babeltrace2::BTTrace
- Inherits:
-
BTSharedObject
- Object
- BTObject
- BTSharedObject
- Babeltrace2::BTTrace
- Defined in:
- lib/babeltrace2/trace-ir/trace.rb
Constant Summary collapse
- SetNameStatus =
BTTraceSetNameStatus
- SetEnvironmentEntryStatus =
BTTraceSetEnvironmentEntryStatus
- AddListenerStatus =
BTTraceAddListenerStatus
- RemoveListenerStatus =
BTTraceRemoveListenerStatus
Instance Attribute Summary
Attributes inherited from BTObject
Instance Method Summary collapse
- #add_destruction_listener(user_func, user_data: nil) ⇒ Object
- #environment=(hash) ⇒ Object
- #get_class ⇒ Object
- #get_environement_entry_by_index(index) ⇒ Object
- #get_environment ⇒ Object (also: #environment)
- #get_environment_entry_count ⇒ Object (also: #environment_entry_count)
- #get_environment_entry_value_by_name(name) ⇒ Object
- #get_name ⇒ Object (also: #name)
- #get_stream_by_id(id) ⇒ Object
- #get_stream_by_index(index) ⇒ Object
- #get_stream_count ⇒ Object (also: #stream_count)
- #get_user_attributes ⇒ Object (also: #user_attributes)
- #get_uuid ⇒ Object (also: #uuid)
-
#initialize(handle = nil, retain: true, auto_release: true, trace_class: nil) ⇒ BTTrace
constructor
A new instance of BTTrace.
- #name=(name) ⇒ Object
- #remove_destruction_listener(listener_id) ⇒ Object
- #set_environement(hash) ⇒ Object
- #set_environment_entry_integer(name, value) ⇒ Object
- #set_environment_entry_string(name, value) ⇒ Object
- #set_name(name) ⇒ Object
- #set_user_attributes(user_attributes) ⇒ Object
- #set_uuid(uuid) ⇒ Object
- #user_attributes=(user_attributes) ⇒ Object
- #uuid=(uuid) ⇒ Object
Methods inherited from BTSharedObject
Methods inherited from BTObject
Constructor Details
#initialize(handle = nil, retain: true, auto_release: true, trace_class: nil) ⇒ BTTrace
Returns a new instance of BTTrace.
156 157 158 159 160 161 162 163 164 165 |
# File 'lib/babeltrace2/trace-ir/trace.rb', line 156 def initialize(handle = nil, retain: true, auto_release: true, trace_class: nil) if(handle) super(handle, retain: retain, auto_release: auto_release) else handle = Babeltrace2.bt_trace_create(trace_class) raise Babeltrace2.process_error if handle.null? super(handle, retain: false) end end |
Instance Method Details
#add_destruction_listener(user_func, user_data: nil) ⇒ Object
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 |
# File 'lib/babeltrace2/trace-ir/trace.rb', line 298 def add_destruction_listener(user_func, user_data: nil) user_func = Babeltrace2._wrap_trace_destruction_listener_func(user_func) id = @handle.to_i ptr = FFI::MemoryPointer.new(:uint64) res = Babeltrace2.bt_trace_add_destruction_listener(@handle, user_func, user_data, ptr) raise Babeltrace2.process_error(res) if res != :BT_TRACE_ADD_LISTENER_STATUS_OK listener_id = ptr.read_uint64 h = Babeltrace2._callbacks[id][:destruction_listener_funcs] if h.nil? h = {} Babeltrace2._callbacks[id][:destruction_listener_funcs] = h end h[listener_id] = [user_func, user_data] listener_id end |
#environment=(hash) ⇒ Object
278 279 280 281 |
# File 'lib/babeltrace2/trace-ir/trace.rb', line 278 def environment=(hash) set_environement(hash) hash end |
#get_class ⇒ Object
167 168 169 170 |
# File 'lib/babeltrace2/trace-ir/trace.rb', line 167 def get_class BTTraceClass.new( Babeltrace2.bt_trace_borrow_class(@handle), retain: true) end |
#get_environement_entry_by_index(index) ⇒ Object
239 240 241 242 243 244 245 246 247 248 |
# File 'lib/babeltrace2/trace-ir/trace.rb', line 239 def get_environement_entry_by_index(index) return nil if index >= get_environment_entry_count ptr1 = FFI::MemoryPointer.new(:pointer) ptr2 = FFI::MemoryPointer.new(:pointer) Babeltrace2.bt_trace_borrow_environment_entry_by_index_const( @handle, index, ptr1, ptr2) name = ptr1.read_pointer.read_string value = BTValue.from_handle(BTValueHandle.new(ptr2.read_pointer)) return [name, value] end |
#get_environment ⇒ Object Also known as: environment
257 258 259 260 261 |
# File 'lib/babeltrace2/trace-ir/trace.rb', line 257 def get_environment get_environment_entry_count.times.collect { |index| get_environement_entry_by_index(index) }.collect { |name, value| [name, value.value] }.to_h end |
#get_environment_entry_count ⇒ Object Also known as: environment_entry_count
234 235 236 |
# File 'lib/babeltrace2/trace-ir/trace.rb', line 234 def get_environment_entry_count Babeltrace2.bt_trace_get_environment_entry_count(@handle) end |
#get_environment_entry_value_by_name(name) ⇒ Object
250 251 252 253 254 255 |
# File 'lib/babeltrace2/trace-ir/trace.rb', line 250 def get_environment_entry_value_by_name(name) handle = Babeltrace2.bt_trace_borrow_environment_entry_value_by_name_const( @handle, name) return nil if handle.null? BTValue.from_handle(handle) end |
#get_name ⇒ Object Also known as: name
200 201 202 |
# File 'lib/babeltrace2/trace-ir/trace.rb', line 200 def get_name Babeltrace2.bt_trace_get_name(@handle) end |
#get_stream_by_id(id) ⇒ Object
183 184 185 186 187 |
# File 'lib/babeltrace2/trace-ir/trace.rb', line 183 def get_stream_by_id(id) handle = Babeltrace2.bt_trace_borrow_stream_by_id(@handle, id) return nil if handle.null? BTStream.new(handle, retain: true) end |
#get_stream_by_index(index) ⇒ Object
177 178 179 180 181 |
# File 'lib/babeltrace2/trace-ir/trace.rb', line 177 def get_stream_by_index(index) return nil if index >= get_stream_count BTStream.new( Babeltrace2.bt_trace_borrow_stream_by_index(@handle, index), retain: true) end |
#get_stream_count ⇒ Object Also known as: stream_count
172 173 174 |
# File 'lib/babeltrace2/trace-ir/trace.rb', line 172 def get_stream_count Babeltrace2.bt_trace_get_stream_count(@handle) end |
#get_user_attributes ⇒ Object Also known as: user_attributes
293 294 295 |
# File 'lib/babeltrace2/trace-ir/trace.rb', line 293 def get_user_attributes BTValueMap.new(Babeltrace2.bt_trace_borrow_user_attributes(@handle), retain: true) end |
#get_uuid ⇒ Object Also known as: uuid
215 216 217 218 219 |
# File 'lib/babeltrace2/trace-ir/trace.rb', line 215 def get_uuid uuid = Babeltrace2.bt_trace_get_uuid(@handle) return nil if uuid.null? uuid end |
#name=(name) ⇒ Object
195 196 197 198 |
# File 'lib/babeltrace2/trace-ir/trace.rb', line 195 def name=(name) set_name(name) name end |
#remove_destruction_listener(listener_id) ⇒ Object
314 315 316 317 318 319 |
# File 'lib/babeltrace2/trace-ir/trace.rb', line 314 def remove_destruction_listener(listener_id) res = Babeltrace2.bt_trace_remove_destruction_listener(@handle, listener_id) raise Babeltrace2.process_error(res) if res != :BT_TRACE_REMOVE_LISTENER_STATUS_OK Babeltrace2._callbacks[@handle.to_i][:destruction_listener_funcs].delete(listener_id) self end |
#set_environement(hash) ⇒ Object
264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/babeltrace2/trace-ir/trace.rb', line 264 def set_environement(hash) hash.each { |k, v| case v when String set_environment_entry_string(k, v) when Integer set_environment_entry_integer(k, v) else raise "invalid value type" end } self end |
#set_environment_entry_integer(name, value) ⇒ Object
222 223 224 225 226 |
# File 'lib/babeltrace2/trace-ir/trace.rb', line 222 def set_environment_entry_integer(name, value) res = Babeltrace2.bt_trace_set_environment_entry_integer(@handle, name, value) raise Babeltrace2.process_error(res) if res != :BT_TRACE_SET_ENVIRONMENT_ENTRY_STATUS_OK self end |
#set_environment_entry_string(name, value) ⇒ Object
228 229 230 231 232 |
# File 'lib/babeltrace2/trace-ir/trace.rb', line 228 def set_environment_entry_string(name, value) res = Babeltrace2.bt_trace_set_environment_entry_string(@handle, name, value) raise Babeltrace2.process_error(res) if res != :BT_TRACE_SET_ENVIRONMENT_ENTRY_STATUS_OK self end |
#set_name(name) ⇒ Object
189 190 191 192 193 |
# File 'lib/babeltrace2/trace-ir/trace.rb', line 189 def set_name(name) res = Babeltrace2.bt_trace_set_name(@handle, name) raise Babeltrace2.process_error(res) if res != :BT_TRACE_SET_NAME_STATUS_OK self end |
#set_user_attributes(user_attributes) ⇒ Object
283 284 285 286 |
# File 'lib/babeltrace2/trace-ir/trace.rb', line 283 def set_user_attributes(user_attributes) Babeltrace2.bt_trace_set_user_attributes(@handle, BTValue.from_value(user_attributes)) self end |
#set_uuid(uuid) ⇒ Object
205 206 207 208 |
# File 'lib/babeltrace2/trace-ir/trace.rb', line 205 def set_uuid(uuid) Babeltrace2.bt_trace_set_uuid(@handle, uuid) self end |
#user_attributes=(user_attributes) ⇒ Object
288 289 290 291 |
# File 'lib/babeltrace2/trace-ir/trace.rb', line 288 def user_attributes=(user_attributes) set_user_attributes(user_attributes) user_attributes end |
#uuid=(uuid) ⇒ Object
210 211 212 213 |
# File 'lib/babeltrace2/trace-ir/trace.rb', line 210 def uuid=(uuid) set_uuid(uuid) uuid end |