python: define _BaseObject._ptr property
Define the property `_ptr` on _BaseObject, which returns the value of
the currently-named `_ptr` field. Rename the `_ptr` field to
`_ptr_internal`, for the lack of a better name.
The goal is for mixin classes to be able to declare that they require
such a property to exist, using `abc.abstractmethod`, and for
_BaseObject to fill in the implementation (and for static type checkers
to be happy). For instance:
class MyMixin(abc.ABC):
@property
@abc.abstractmethod
def _ptr(self):
raise NotImplementedError
def my_method(self):
... do something with self._ptr ...
class MyObject(object._SharedObject, MyMixin):
...
In this case, object._SharedObject provides the `_ptr` implementation
that `MyMixin` requires.
Change-Id: I696c04ed690ede7cd50bcb71890cc0b7b25f44e4
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10326
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
This page took 0.025362 seconds and 4 git commands to generate.