Executable.h

Go to the documentation of this file.
00001 /*
00002  * The information in this file is
00003  * Copyright(c) 2007 Ball Aerospace & Technologies Corporation
00004  * and is subject to the terms and conditions of the
00005  * GNU Lesser General Public License Version 2.1
00006  * The license text is available from   
00007  * http://www.gnu.org/licenses/lgpl.html
00008  */
00009 
00010 #ifndef EXECUTABLE_H
00011 #define EXECUTABLE_H
00012 
00013 class PlugInArgList;
00014 
00015 #include <string>
00016 #include <vector>
00017 
00018 /**
00019  *  Provides a common interface for plug-in execution.
00020  *
00021  *  Defines a generic interface for all plug-ins that is used
00022  *  to query the plug-in for its input/ouput parameters and
00023  *  to execute it in a common way.
00024  */
00025 class Executable
00026 {
00027 public:
00028    /**
00029     *  The name for a Progress argument.
00030     *
00031     *  Input arguments with this name will be automatically populated with a
00032     *  Progress pointer when the plug-in is executed with an ExecutableAgent.
00033     *  Arguments with this name should be of the type Progress.
00034     *
00035     *  @see     ExecutableAgent::execute()
00036     */
00037    static std::string ProgressArg() { return "Progress"; }
00038 
00039    /**
00040     *  The description for a Progress argument.
00041     *
00042     *  This description can be used to populate the Description field for 
00043     *  a plug-in's input argument list when attaching a Progress argument.
00044     *
00045     *  @see     ExecutableAgent::execute()
00046     */
00047    static std::string ProgressArgDescription() { return "Progress object for this plugin."; }
00048 
00049    /**
00050     *  The name for a menu command argument.
00051     *
00052     *  Input arguments with this name will be automatically populated with the
00053     *  menu command name from which the plug-in was executed when the plug-in
00054     *  is executed with an ExecutableAgent.  Arguments with this name should
00055     *  be of the type std::string.
00056     *
00057     *  @see     ExecutableAgent::execute()
00058     */
00059    static std::string MenuCommandArg() { return "Menu Command"; }
00060 
00061    /**
00062     *  The name for a Window argument.
00063     *
00064     *  Input arguments with this name will be automatically populated with a
00065     *  Window pointer when the plug-in is executed with an ExecutableAgent.
00066     *  Arguments with this name should be of the type Window or one of its
00067     *  subclasses.
00068     *  It should not be used by an Exporter or subclasses derived from Exporter
00069     *  to access the window associated with the exported item.
00070     *
00071     *  @see     ExecutableAgent::execute()
00072     */
00073    static std::string WindowArg() { return "Window"; }
00074 
00075    /**
00076     *  The name for a View argument.
00077     *
00078     *  Input arguments with this name will be automatically populated with a
00079     *  View pointer when the plug-in is executed with an ExecutableAgent.
00080     *  Arguments with this name should be of the type View or one of its
00081     *  subclasses.
00082     *  It should not be used by an Exporter or subclasses derived from Exporter
00083     *  to access the view associated with the exported item.
00084     *
00085     *  @see     ExecutableAgent::execute()
00086     */
00087    static std::string ViewArg() { return "View"; }
00088 
00089    /**
00090     *  The name for a Layer argument.
00091     *
00092     *  Input arguments with this name will be automatically populated with a
00093     *  Layer pointer when the plug-in is executed with an ExecutableAgent.
00094     *  Arguments with this name should be of the type Layer or one of its
00095     *  subclasses.
00096     *  It should not be used by an Exporter or classes derived from Exporter
00097     *  to access the layer associated with the exported item.
00098     *
00099     *  @see     ExecutableAgent::execute()
00100     */
00101    static std::string LayerArg() { return "Layer"; }
00102 
00103    /**
00104     *  The name for a DataElement argument.
00105     *
00106     *  Input arguments with this name will be automatically populated with a
00107     *  DataElement pointer when the plug-in is executed with an ExecutableAgent.
00108     *  Arguments with this name should be of the type DataElement or one of its
00109     *  subclasses.
00110     *  It should not be used by Exporter or classes derived from Exporter to access a 
00111     *  DataElement associated with the exported item.
00112     *
00113     *  @see     ExecutableAgent::execute()
00114     */
00115    static std::string DataElementArg() { return "Data Element"; }
00116 
00117    /**
00118     *  Queries whether the plug-in is automatically executed when the
00119     *  application starts.
00120     *
00121     *  @return  Returns \b true if the plug-in is automatically executed when
00122     *           the application is created; otherwise returns \b false.
00123     */
00124    virtual bool isExecutedOnStartup() const = 0;
00125 
00126    /**
00127     *  Queries whether the plug-in is automatically destroyed after it is
00128     *  successfully executed. Plug-ins which are not successfully executed are
00129     *  automatically destroyed by the application.
00130     *
00131     *  After a plug-in is successfully executed, it can be destroyed by the application
00132     *  or stay resident in memory.  A plug-in may need to exist after execution,
00133     *  such as those containing modeless GUI components that require user
00134     *  interaction or continually display data.
00135     *
00136     *  @return  Returns \b true if the plug-in is automatically destroyed after
00137     *           it is successfully executed; otherwise returns \b false.
00138     *
00139     *  @see     execute()
00140     */
00141    virtual bool isDestroyedAfterExecute() const = 0;
00142 
00143    /**
00144     *  Returns the menu locations and names of the commands from which the
00145     *  plug-in is executed.
00146     *
00147     *  @return  A vector of strings representing the menu locations and names
00148     *           of the commands that are used to execute the plug-in.<br><br>
00149     *           Each string is formatted with brackets ([,]) to specify a
00150     *           toolbar and a slash (/) to indicate submenus.  The toolbar name
00151     *           appears first in the string, followed by an optional slash, and
00152     *           then the menus, submenus and command name separated by slashes.
00153     *           If the optional slash appears following the toolbar name, this
00154     *           indicates that the submenus and command should be added to the
00155     *           default toolbar menu, which has the same name as the toolbar.
00156     *           If a slash does not follow the toolbar name, the menus and
00157     *           command are added directly to the toolbar.  If the string does
00158     *           not include a toolbar name, the menus and command are added to
00159     *           the main menu bar.  The string cannot end with a slash, and the
00160     *           name after the last slash indicates the command name.<br><br>
00161     *           Examples of the menu string include the following:
00162     *           <ul><li>[Geo]/Georeference</li>
00163     *           <li>&Tools/Flicker %Window</li></ul><br>
00164     *           An empty vector is returned if the plug-in should not be
00165     *           executed from the menus.
00166     */
00167    virtual const std::vector<std::string>& getMenuLocations() const = 0;
00168 
00169    /**
00170     *  Sets the plug-in to execute in batch mode.
00171     *
00172     *  This method is used to set the plug-in to execute in a
00173     *  non-GUI mode.
00174     *
00175     *  @return  Returns \b true if batch mode is supported and the plug-in was
00176     *           successfully set to execute in a non-GUI mode.  Returns
00177     *           \b false if the plug-in does not support batch mode, or if
00178     *           batch mode cannot currently be set on the plug-in.
00179     *
00180     *  @see     setInteractive()
00181     */
00182    virtual bool setBatch() = 0;
00183 
00184    /**
00185     *  Sets the plug-in to execute in interactive mode.
00186     *
00187     *  This method is used to set the plug-in to execute in a
00188     *  GUI mode.
00189     *
00190     *  @return  Returns \b true if interactive mode is supported and the
00191     *           plug-in was successfully set to execute in a GUI mode.  Returns
00192     *           \b false if the plug-in does not support interactive mode, or
00193     *           if interactive mode cannot currently be set on the plug-in.
00194     *
00195     *  @see     setBatch()
00196     */
00197    virtual bool setInteractive() = 0;
00198 
00199    /**
00200     *  Retrieves the plug-in input parameters.
00201     *
00202     *  This method queries the plug-in for its input parameters
00203     *  that are needed to execute properly.  The input arguments
00204     *  may be different in interactive mode and batch mode.
00205     *
00206     *  @param   pArgList
00207     *           A plug-in arg list pointer that is set to a created
00208     *           input argument list specifying the plug-in input
00209     *           parameters.  \b NULL is a valid pointer value if the
00210     *           plug-in does not require any input arguments.
00211     *
00212     *  @return  Returns \b true if the input parameter argument list was
00213     *           successfully created.  If the plug-in does not require input
00214     *           arguments, \b true is returned, but the given plug-in arg list
00215     *           pointer may be \b NULL.
00216     *
00217     *  @see     PlugInArgList
00218     */
00219    virtual bool getInputSpecification(PlugInArgList*& pArgList) = 0;
00220 
00221    /**
00222     *  Retrieves the plug-in output parameters.
00223     *
00224     *  This method queries the plug-in for its output parameters that are
00225     *  created during execution.  The output arguments may be different in
00226     *  interactive mode and batch mode.
00227     *
00228     *  @param   pArgList
00229     *           A plug-in arg list pointer that is set to a created
00230     *           output argument list specifying the plug-in output
00231     *           parameters.  \b NULL is a valid pointer value if the
00232     *           plug-in does not provide any output arguments.
00233     *
00234     *  @return  Returns \b true if the output parameter argument list was
00235     *           successfully created.  If the plug-in does not provide output
00236     *           arguments, \b true is returned, but the given plug-in arg list
00237     *           pointer may be \b NULL.
00238     *
00239     *  @see     PlugInArgList
00240     */
00241    virtual bool getOutputSpecification(PlugInArgList*& pArgList) = 0;
00242 
00243    /**
00244     *  Initializes the plug-in before execution.
00245     *
00246     *  This method is used by the plug-in manager to initialize the
00247     *  plug-in before it is executed.
00248     *
00249     *  @return  Returns \b true if the plug-in initialization was sucessful;
00250     *           otherwise returns \b false.
00251     */
00252    virtual bool initialize() = 0;
00253 
00254    /**
00255     *  Executes the plug-in.
00256     *
00257     *  @param   pInArgList
00258     *           On input, \em pInArgList contains a complete input argument
00259     *           list for the plug-in.  The actual values are used as inputs
00260     *           when executing the plug-in.  Default values may be used if
00261     *           an actual value is not present.
00262     *  @param   pOutArgList
00263     *           On input, \em pOutArgList contains a complete output argument
00264     *           list for the plug-in, although actual values and default values
00265     *           will be ignored.  On return, the actual values in the argument
00266     *           list will be updated to include all output parameters defined
00267     *           by the plug-in.
00268     *
00269     *  @return  Returns \b true if the execution was successful.  Returns
00270     *           \b false if an error occurred or if the user cancelled the
00271     *           plug-in while in interactive mode.
00272     *
00273     *  @see     getInputSpecification(), getOutputSpecification()
00274     */
00275    virtual bool execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList) = 0;
00276 
00277    /**
00278     *  Aborts the plug-in during execution.
00279     *
00280     *  This method may be called by the application to attempt to gracefully
00281     *  abort a plug-in.  Depending on the specific plug-in implementation of
00282     *  this method, it may simply initiate the abort process and return
00283     *  or it may attempt to complete the abort process before returning.
00284     *
00285     *  @return  Returns \b true if the plug-in was successfully aborted or
00286     *           transformed to an aborted state, which does not necessarily
00287     *           mean that the plug-in has completed aborting.  Returns
00288     *           \b false if the plug-in could not abort successfully or if the
00289     *           plug-in does not support aborting.
00290     *
00291     *  @see     hasAbort()
00292     */
00293    virtual bool abort() = 0;
00294 
00295    /**
00296     *  Queries whether the plug-in can be aborted.
00297     *
00298     *  This method may be called to determine if the plug-in can be aborted.
00299     *  This can be useful in GUI applications where the user may not be given
00300     *  the chance to cancel.
00301     *
00302     *  @return  Returns \b true if the plug-in supports the ability to abort,
00303     *           otherwise returns \b false.  Plug-ins that do not have
00304     *           significant processing or loops can also return \b false.
00305     */
00306    virtual bool hasAbort() = 0;
00307 
00308    /**
00309     *  Queries whether the plug-in performs background processing.
00310     *
00311     *  This method is called by the application after executing the plug-in to
00312     *  determine if the plug-in should be unloaded or should wait until
00313     *  processing is finished.  This method is called before
00314     *  isDestroyedAfterExecute() is called, so a return value of \b false does
00315     *  not necessarily mean that the plug-in will be destroyed.
00316     *
00317     *  @return  Returns \b true if the plug-in performs background processing.
00318     *           Destruction and possible unloading of the plug-in will be
00319     *           delayed until the plug-in indicates that background processing
00320     *           has ended.  Returns \b false if the plug-in does not support
00321     *           background processing or is not performing background
00322     *           processing during this instance.
00323     *
00324     *  @see     DesktopServices::registerCallback()
00325     */
00326    virtual bool isBackground() const = 0;
00327 
00328    /**
00329     * Queries whether the plug-in supports being added as a wizard item.
00330     *
00331     * This method is called by the application to determine if the user
00332     * should be able to add this plug-in as a wizard item in the wizard
00333     * builder.
00334     *
00335     * @return Returns \b true if the user should be able to add this
00336     *         plug-in to the wizard builder.  Returns \b false if
00337     *         the user should NOT be able to add this plug-in to
00338     *         the wizard builder.
00339     */
00340    virtual bool hasWizardSupport() const = 0;
00341 
00342 protected:
00343    /**
00344     * This should be destroyed by calling PlugInManagerServices::destroyPlugIn.
00345     */
00346    virtual ~Executable() {}
00347 };
00348 
00349 #endif

Software Development Kit - Opticks 4.9.0 Build 16218