Interface Plugin
- All Known Implementing Classes:
AbstractCompiler, AbstractCPU, AbstractPlugin
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 Summary
Modifier and TypeMethodDescriptiondefault voiddestroy()Destroys all plugin resources (unregister contexts, stop threads, dispose windows).default StringGet copyright string, read ascopyrightkey from the same resource bundle asgetVersion().default StringGet plugin short description.default StringGet the plugin's user documentation URL.default StringgetTitle()Get run-time title of this plugin.default StringGet version of the plugin, read asversionkey from aversion.propertiesresource bundle in the plugin class's package.default voidInitialize plugin.default booleanDetermines if this plugin supports emulation automation.default booleanCheck ifshowSettings(JFrame)is supported by this plugin.default voidreset()Reset plugin to its "initial state", as it was after callinginitialize().default voidshowSettings(JFrame parent) Show GUI of plugin settings.default CompletableFuture<Void> Starts configured work after reset during automatic emulation, independently of the GUI.default CompletableFuture<Void> Requests cooperative stop, including when startup failed or was skipped.
-
Method Details
-
initialize
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 callinginitialize(). -
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
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
Show GUI of plugin settings. Called only ifisShowSettingsSupported()returns true.- Parameters:
parent- emuStudio main window
-
isShowSettingsSupported
default boolean isShowSettingsSupported()Check ifshowSettings(JFrame)is supported by this plugin.- Returns:
- true if the plugin has a GUI for settings; false otherwise
-
getTitle
Get run-time title of this plugin. Defaults toPluginRoot.title().- Returns:
- run-time title of the plugin
-
getDescription
Get plugin short description. Defaults toPluginRoot.description().- Returns:
- plugin description
-
getDocumentationUrl
Get the plugin's user documentation URL. Defaults toPluginRoot.documentationUrl().- Returns:
- documentation URL, or an empty string if none is available
-
getVersion
Get version of the plugin, read asversionkey from aversion.propertiesresource bundle in the plugin class's package. A missing bundle or key returns"(unknown)".- Returns:
- version string
-
getCopyright
Get copyright string, read ascopyrightkey from the same resource bundle asgetVersion().- Returns:
- copyright string
-
isAutomationSupported
default boolean isAutomationSupported()Determines if this plugin supports emulation automation.- Returns:
- true if the plugin supports emulation automation; false otherwise
-