1 # The MIT License (MIT)
3 # Copyright (c) 2016-2017 Philippe Proulx <pproulx@efficios.com>
5 # Permission is hereby granted, free of charge, to any person obtaining a copy
6 # of this software and associated documentation files (the "Software"), to deal
7 # in the Software without restriction, including without limitation the rights
8 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 # copies of the Software, and to permit persons to whom the Software is
10 # furnished to do so, subject to the following conditions:
12 # The above copyright notice and this permission notice shall be included in
13 # all copies or substantial portions of the Software.
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 from bt2
import native_bt
, object, utils
24 from bt2
import clock_class
as bt2_clock_class
25 from bt2
import event_class
as bt2_event_class
26 from bt2
import packet
as bt2_packet
27 from bt2
import stream
as bt2_stream
28 from bt2
import field
as bt2_field
29 from bt2
import clock_snapshot
as bt2_clock_snapshot
33 class _Event(object._UniqueObject
):
36 event_class_ptr
= native_bt
.event_borrow_class(self
._ptr
)
37 assert event_class_ptr
is not None
38 return bt2_event_class
._EventClass
._create
_from
_ptr
_and
_get
_ref
(event_class_ptr
)
50 packet_ptr
= native_bt
.event_borrow_packet(self
._ptr
)
52 if packet_ptr
is None:
55 return bt2_packet
._Packet
._create
_from
_ptr
_and
_get
_ref
(packet_ptr
)
59 stream_ptr
= native_bt
.event_borrow_stream(self
._ptr
)
60 assert stream_ptr
is not None
61 return bt2_stream
._Stream
._create
_from
_ptr
_and
_get
_ref
(stream_ptr
)
64 def common_context_field(self
):
65 field_ptr
= native_bt
.event_borrow_common_context_field(self
._ptr
)
70 return bt2_field
._create
_field
_from
_ptr
(
71 field_ptr
, self
._owner
_ptr
, self
._owner
_get
_ref
, self
._owner
_put
_ref
75 def specific_context_field(self
):
76 field_ptr
= native_bt
.event_borrow_specific_context_field(self
._ptr
)
81 return bt2_field
._create
_field
_from
_ptr
(
82 field_ptr
, self
._owner
_ptr
, self
._owner
_get
_ref
, self
._owner
_put
_ref
86 def payload_field(self
):
87 field_ptr
= native_bt
.event_borrow_payload_field(self
._ptr
)
92 return bt2_field
._create
_field
_from
_ptr
(
93 field_ptr
, self
._owner
_ptr
, self
._owner
_get
_ref
, self
._owner
_put
_ref
96 def __getitem__(self
, key
):
98 payload_field
= self
.payload_field
100 if payload_field
is not None and key
in payload_field
:
101 return payload_field
[key
]
103 specific_context_field
= self
.specific_context_field
105 if specific_context_field
is not None and key
in specific_context_field
:
106 return specific_context_field
[key
]
108 common_context_field
= self
.common_context_field
110 if common_context_field
is not None and key
in common_context_field
:
111 return common_context_field
[key
]
113 packet_context_field
= self
.packet
.context_field
115 if packet_context_field
is not None and key
in packet_context_field
:
116 return packet_context_field
[key
]
This page took 0.030784 seconds and 4 git commands to generate.