Core modules

Plugin manager — discovers and loads plugin classes.

Plugins are discovered via Python package entry-points under the group stoner_measurement.plugins. Each entry-point value must be a subclass of BasePlugin.

class stoner_measurement.core.plugin_manager.PluginManager(*args: Any, **kwargs: Any)[source]

Bases: QObject

Discovers, loads, and provides access to measurement plugins.

Signals

plugins_changed:

Emitted after the plugin registry is (re-)built.

discover() None[source]

Scan entry-points and instantiate all registered plugins.

get(name: str) BasePlugin | None[source]

Return the plugin with name, or None if not found.

property plugin_names: list[str]

Sorted list of registered plugin names.

property plugins: dict[str, BasePlugin]

Mapping of plugin name → plugin instance.

plugins_by_type(plugin_type: str) dict[str, BasePlugin][source]

Return a filtered mapping of plugins matching plugin_type.

Args:
plugin_type (str):

The plugin_type tag to filter by (e.g. "trace", "state", "monitor", "transform").

Returns:
(dict[str, BasePlugin]):

Mapping of plugin name → plugin instance for all registered plugins whose plugin_type equals plugin_type.

Examples:
>>> from PyQt6.QtWidgets import QApplication
>>> _ = QApplication.instance() or QApplication([])
>>> from stoner_measurement.core.plugin_manager import PluginManager
>>> from stoner_measurement.plugins.trace import DummyPlugin
>>> pm = PluginManager()
>>> pm.register("dummy", DummyPlugin())
>>> pm.plugins_by_type("trace")
{'dummy': <...DummyPlugin...>}
>>> pm.plugins_by_type("state")
{}
register(name: str, plugin: BasePlugin) None[source]

Manually register a plugin instance (useful for testing).

Parameters:
  • name – Unique identifier for the plugin.

  • plugin – Plugin instance to register.

unregister(name: str) None[source]

Remove a plugin from the registry.

Parameters:

name – Identifier of the plugin to remove.