component = bt2_component._create_component_from_ptr_and_get_ref(
component_ptr, component_type
)
- port = bt2_port._create_from_ptr_and_get_ref(port_ptr, port_type)
+ port = bt2_port._create_from_const_ptr_and_get_ref(port_ptr, port_type)
user_listener(component, port)
upstream_component = bt2_component._create_component_from_ptr_and_get_ref(
upstream_component_ptr, upstream_component_type
)
- upstream_port = bt2_port._create_from_ptr_and_get_ref(
+ upstream_port = bt2_port._create_from_const_ptr_and_get_ref(
upstream_port_ptr, native_bt.PORT_TYPE_OUTPUT
)
downstream_component = bt2_component._create_component_from_ptr_and_get_ref(
downstream_component_ptr, downstream_component_type
)
- downstream_port = bt2_port._create_from_ptr_and_get_ref(
+ downstream_port = bt2_port._create_from_const_ptr_and_get_ref(
downstream_port_ptr, native_bt.PORT_TYPE_INPUT
)
user_listener(
_get_ref = staticmethod(native_bt.graph_get_ref)
_put_ref = staticmethod(native_bt.graph_put_ref)
- def __init__(self):
- ptr = native_bt.graph_create()
+ def __init__(self, mip_version=0):
+ utils._check_uint64(mip_version)
+
+ if mip_version > bt2.get_maximal_mip_version():
+ raise ValueError('unknown MIP version {}'.format(mip_version))
+
+ ptr = native_bt.graph_create(mip_version)
if ptr is None:
raise bt2._MemoryError('cannot create graph object')
return bt2_component._create_component_from_ptr(comp_ptr, cc_type)
def connect_ports(self, upstream_port, downstream_port):
- utils._check_type(upstream_port, bt2_port._OutputPort)
- utils._check_type(downstream_port, bt2_port._InputPort)
+ utils._check_type(upstream_port, bt2_port._OutputPortConst)
+ utils._check_type(downstream_port, bt2_port._InputPortConst)
status, conn_ptr = native_bt.graph_connect_ports(
self._ptr, upstream_port._ptr, downstream_port._ptr
)
utils._handle_func_status(status, 'cannot connect component ports within graph')
assert conn_ptr
- return bt2_connection._Connection._create_from_ptr(conn_ptr)
+ return bt2_connection._ConnectionConst._create_from_ptr(conn_ptr)
def add_port_added_listener(self, listener):
if not callable(listener):