I received a question about the difference between batch and interactive mode for plug-ins. This is my attempt to create some de-facto documentation about the subject.
When a plug-in is executed, it can either be executed in batch mode or interactive mode. An individual plug-in can also decide if it will support only one or both modes of execution. When a plug-in is executed in batch mode, it is not permitted to prompt the user for any information. When a plug-in is executed in interactive mode, it may create gui’s and it may prompt the user for information. A plug-in that is executed in interactive mode is not required to create gui’s, nor is it required to prompt the user for information. In order to facilitate this, a plug-in can have different input and output arguments depending on whether it will be executed in batch or interactive mode.
To provide further clarification, the Opticks application can also be run either interactively or in batch mode. To run the Opticks application in batch mode, you must execute OpticksBatch.exe (or OpticksBatch on Solaris). To run the Opticks application in interactive mode, you must execute Opticks.exe (or Opticks on Solaris). When OpticksBatch is run, the application runs using just the command-line and no windows or gui’s can be created. So, when a plug-in is executed in interactive mode it is guaranteed that the Opticks application is also being executed in interactive mode, so a plug-in can create gui’s (ie. windows, layers, dock windows, dialogs, etc.). When a plug-in is executed in batch mode, it could running in an interactive Opticks application, in which case a batch mode plug-in can create gui’s (ie. windows, layers), but the plug-in cannot prompt the user for information. If however a batch mode plug-in is being executed inside OpticksBatch, the plug-in cannot create any gui’s and also cannot prompt the user for information.
In order for a plug-in to be executable, it must implement the Executable interface. Before a plug-in is executed (i.e. before Executable::execute()) is called, either Executable::setBatch() or Executable::setInteractive() will be called on the plug-in instance to put the plug-in in either batch or interactive mode. If a plug-in doesn’t wish to support a mode, it should return false from it’s implementation of setBatch() or setInteractive(), otherwise it should return true. After this has been called, Executable::getInputSpecification() and Executable::getOutputSpecification() will be called to determine the input and output arguments. The implementations of these methods can and should use the batch or interactive mode of the plug-in to return different argument lists. When a plug-in is executed (i.e. when Executable::execute() is called), it should use the batch or interactive mode of the plug-in to perform different executions. For example, if a plug-in is executing in batch mode it cannot prompt the user for any information. If a plug-in executing in batch mode would like to determine whether it is being executed inside an interactive or batch version of Opticks, it can use the following code:
bool appIsBatch = Service<ApplicationServices>()->isBatch();
bool appIsInteractive = Service<ApplicationServices>()->isInteractive();
//if appIsBatch == true, then plug-in is being executed inside OpticksBatch.exe and it cannot create any gui’s
//if appIsInteractive == true, then the plug-in is being executed inside Opticks.exe and can create gui’s and may or may not prompt the user depending on the execution mode of the plug-in.
If a plug-in is going to support both batch and interactive mode, you can subclass ExecutableShell and it already provides implementations of Executable::setBatch() and Executable::setInteractive() and provides a method ExecutableShell::isBatch() that will return true if the current execution mode is batch and false if the current execution mode is interactive.
This message and any enclosures are intended only for the addressee. Please notify the sender by email if you are not the intended recipient. If you are not the intended recipient, you may not use, copy, disclose, or distribute this message or its contents or enclosures to any other person and any such actions may be unlawful. Ball reserves the right to monitor and review all messages and enclosures sent to or from this email address.
|Free forum by Nabble||Edit this page|