TSDuck v3.40-3963
MPEG Transport Stream Toolkit
|
This base class is derived by all TSDuck classes which are backed by a C++ object. More...
Public Member Functions | |
__init__ (self) | |
Constructor for subclasses. | |
delete (self) | |
Explicitly free the underlying C++ object. | |
Protected Member Functions | |
_getNative (self) | |
Get the native object. | |
_setNative (self, obj) | |
Set the native object. | |
This base class is derived by all TSDuck classes which are backed by a C++ object.
There is an inherent problem when garbage-collected languages such as Python are interfaced with languages using explicit memory management. When a Python class encapsulates a native C++ object of the corresponding C++ class, when should the C++ object be deleted? This is a problem which has been discussed many times on the Internet and the answer is disappointing: there is no good solution.
In the Python TSDuck bindings, all classes which encapsulate a C++ object derive from the base class NativeObject which provides the delete() method to explicitly delete the C++ object. In practice, users have the choice between solutions 2 or 3.
tsduck.NativeObject.__init__ | ( | self | ) |
Constructor for subclasses.
Reimplemented in tsduck.Report, tsduck.NullReport, tsduck.StdErrReport, tsduck.AbstractPluginEventHandler, tsduck.PluginEventHandlerRegistry, tsduck.SectionFile, tsduck.DuckContext, tsduck.TSProcessor, tsduck.InputSwitcher, tsduck.SystemMonitor, tsduck.AbstractSyncReport, tsduck.AbstractAsyncReport, and tsduck.AsyncReport.
tsduck.NativeObject.delete | ( | self | ) |
Explicitly free the underlying C++ object.
After this call, the object becomes unusable. Most usages are unpredictable but most likely will do nothing.
Reimplemented in tsduck.AsyncReport, tsduck.DuckContext, tsduck.AbstractPluginEventHandler, tsduck.SectionFile, tsduck.SystemMonitor, tsduck.TSProcessor, and tsduck.InputSwitcher.
|
protected |
Set the native object.
This is typically done by subclass constructors.
obj | Address of the C++ native object to store. |
|
protected |
Get the native object.
This is typically used by subclasses.