Interface Plugin

All Known Subinterfaces:
Compiler, CPU, Device, Memory
All Known Implementing Classes:
AbstractCompiler, AbstractCPU, AbstractPlugin

public interface Plugin
Plugin main interface. This interface is available only to emuStudio, not to other plugins. Plugins communicate with each other using special entities called "contexts".

CONTRACT:

Each plugin must meet several requirements:

- this interface, or its derivative, must be implemented by one and only one class (so-called "root class") - the root class has to be annotated with PluginRoot annotation with required parameters - the root class has to have single constructor with 3 parameters (see below).

The constructor signature has to look like this:

\@PluginRoot(...) SamplePlugin(long pluginId, ApplicationApi emustudio, PluginSettings settings) { ... }

1. pluginId is a unique plugin identification. Operations around plugin contexts require it as input argument.

2. emustudio is the API provided by emuStudio application, to be used by plugins.

3. settings plugin's settings. A plugin can use it for reading/writing its custom settings. Updated settings are saved immediately in the configuration file, in the same thread.

NOTE: Plugins should register the contexts they provide into the ContextPool, which can be obtained from ApplicationApi API.

Plugins must not try to obtain contexts from the context pool from plugin constructor. The reason is that the order of plugin context registration is fixed, and in the plugin construction time some contexts don't need to be available yet. Plugin contexts can be safely obtained within initialize() method.

  • Method Details

    • initialize

      default void initialize() throws PluginInitializationException
      Initialize plugin.

      Called once, after all plugins were created. Here the plugin can request already registered contexts from the ApplicationApi.getContextPool().

      Throws:
      PluginInitializationException - thrown when initialization process was not successful
    • reset

      default void reset()
      Reset plugin to its "initial state", as it was after calling initialize().
    • startAutomation

      default CompletableFuture<Void> startAutomation()
      Starts configured work after reset during automatic emulation, independently of the GUI. Complete the returned future when the plugin is ready for the first guest instruction.
    • stopAutomation

      default CompletableFuture<Void> stopAutomation()
      Requests cooperative stop, including when startup failed or was skipped. Return promptly and complete the future when the plugin's automation workers have stopped accessing the machine.
    • destroy

      default void destroy()
      Destroys all plugin resources (unregister contexts, stop threads, dispose windows).

      Called when the user closes the emulator.

    • showSettings

      default void showSettings(JFrame parent)
      Show GUI of plugin settings. Called only if isShowSettingsSupported() returns true.
      Parameters:
      parent - emuStudio main window
    • isShowSettingsSupported

      default boolean isShowSettingsSupported()
      Check if showSettings(JFrame) is supported by this plugin.
      Returns:
      true if the plugin has a GUI for settings; false otherwise
    • getTitle

      default String getTitle()
      Get run-time title of this plugin. Defaults to PluginRoot.title().
      Returns:
      run-time title of the plugin
    • getDescription

      default String getDescription()
      Get plugin short description. Defaults to PluginRoot.description().
      Returns:
      plugin description
    • getDocumentationUrl

      default String getDocumentationUrl()
      Get the plugin's user documentation URL. Defaults to PluginRoot.documentationUrl().
      Returns:
      documentation URL, or an empty string if none is available
    • getVersion

      default String getVersion()
      Get version of the plugin, read as version key from a version.properties resource bundle in the plugin class's package. A missing bundle or key returns "(unknown)".
      Returns:
      version string
    • getCopyright

      default String getCopyright()
      Get copyright string, read as copyright key from the same resource bundle as getVersion().
      Returns:
      copyright string
    • isAutomationSupported

      default boolean isAutomationSupported()
      Determines if this plugin supports emulation automation.
      Returns:
      true if the plugin supports emulation automation; false otherwise