# create instance, not user-initialized yet
self = cls.__new__(cls)
+ # config object
+ config = cls._config_pycls()
+
# pointer to native self component object (weak/borrowed)
self._bt_ptr = comp_ptr
else:
params = None
- self.__init__(params, obj)
+ self.__init__(config, params, obj)
return self
def __call__(cls, *args, **kwargs):
)
)
+ if hasattr(iter_cls, '_user_can_seek_ns_from_origin') and not hasattr(
+ iter_cls, '_user_seek_ns_from_origin'
+ ):
+ raise bt2._IncompleteUserClass(
+ "cannot create component class '{}': message iterator class implements _user_can_seek_ns_from_origin but not _user_seek_ns_from_origin".format(
+ cls.__name__
+ )
+ )
+
+ if hasattr(iter_cls, '_user_can_seek_beginning') and not hasattr(
+ iter_cls, '_user_seek_beginning'
+ ):
+ raise bt2._IncompleteUserClass(
+ "cannot create component class '{}': message iterator class implements _user_can_seek_beginning but not _user_seek_beginning".format(
+ cls.__name__
+ )
+ )
+
cls._iter_cls = iter_cls
@property
def _user_get_supported_mip_versions(cls, params, obj, log_level):
return [0]
- def _bt_query_from_native(cls, priv_query_exec_ptr, object, params_ptr, method_obj):
+ def _bt_query_from_native(
+ cls, priv_query_exec_ptr, object_name, params_ptr, method_obj
+ ):
# this can raise, but the native side checks the exception
if params_ptr is not None:
params = bt2_value._create_from_const_ptr_and_get_ref(params_ptr)
try:
# this can raise, but the native side checks the exception
- results = cls._user_query(priv_query_exec, object, params, method_obj)
+ results = cls._user_query(priv_query_exec, object_name, params, method_obj)
finally:
# the private query executor is a private view on the query
# executor; it's not a shared object (the library does not
bt2_value._Value._get_ref(results_ptr)
return int(results_ptr)
- def _user_query(cls, priv_query_executor, object, params, method_obj):
+ def _user_query(cls, priv_query_executor, object_name, params, method_obj):
raise bt2.UnknownObject
def _bt_component_class_ptr(self):
native_bt.bt2_unregister_cc_ptr_to_py_cls(cc_ptr)
+# Configuration objects for components.
+#
+# These are passed in __init__ to allow components to change some configuration
+# parameters during initialization and not after. As you can see, they are not
+# used at the moment, but are there in case we want to add such parameters.
+
+
+class _UserComponentConfiguration:
+ pass
+
+
+class _UserSourceComponentConfiguration(_UserComponentConfiguration):
+ pass
+
+
+class _UserFilterComponentConfiguration(_UserComponentConfiguration):
+ pass
+
+
+class _UserSinkComponentConfiguration(_UserComponentConfiguration):
+ pass
+
+
# Subclasses must provide these methods or property:
#
# - _bt_as_not_self_specific_component_ptr: static method, must return the passed
ptr = self._bt_as_self_component_ptr(self._bt_ptr)
return native_bt.self_component_get_graph_mip_version(ptr)
- def __init__(self, params=None, obj=None):
+ def __init__(self, config, params, obj):
pass
def _user_finalize(self):
_bt_as_self_component_ptr = staticmethod(
native_bt.self_component_source_as_self_component
)
+ _config_pycls = _UserSourceComponentConfiguration
@property
def _output_ports(self):
_bt_as_self_component_ptr = staticmethod(
native_bt.self_component_filter_as_self_component
)
+ _config_pycls = _UserFilterComponentConfiguration
@property
def _output_ports(self):
_bt_as_self_component_ptr = staticmethod(
native_bt.self_component_sink_as_self_component
)
+ _config_pycls = _UserSinkComponentConfiguration
def _bt_graph_is_configured_from_native(self):
self._user_graph_is_configured()
def _create_input_port_message_iterator(self, input_port):
utils._check_type(input_port, bt2_port._UserComponentInputPort)
- status, msg_iter_ptr = native_bt.bt2_self_component_port_input_message_iterator_create_from_sink_component(
+ (
+ status,
+ msg_iter_ptr,
+ ) = native_bt.bt2_self_component_port_input_message_iterator_create_from_sink_component(
self._bt_ptr, input_port._ptr
)
utils._handle_func_status(status, 'cannot create message iterator object')