PlugInManagerServices.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 PLUGINMANAGERSERVICES_H
00011 #define PLUGINMANAGERSERVICES_H
00012 
00013 #include "Service.h"
00014 #include "Subject.h"
00015 #include "TypesFile.h"
00016 
00017 #include <vector>
00018 #include <string>
00019 
00020 class DataElement;
00021 class DynamicModule;
00022 class Layer;
00023 class PlotWidget;
00024 class PlugIn;
00025 class PlugInArg;
00026 class PlugInArgList;
00027 class PlugInDescriptor;
00028 class Progress;
00029 class View;
00030 class WorkspaceWindow;
00031 
00032 /**
00033  *  \ingroup ServiceModule
00034  *  Provides access to the plug-in argument list and their arguments.
00035  *
00036  *  PlugInManagerServices provides methods for creating and destroying
00037  *  PlugInArgs and ArgLists. These arg lists are used for passing arguments
00038  *  to plugins. A plug-in needs to create a new input and output arglist
00039  *  every time its getInputSpecification or getOutputSpecification methods
00040  *  are called. It is the responsibility of the caller of the plug-in to
00041  *  destroy the arg lists when they are done with them.
00042  *
00043  *  This subclass of Subject will notify upon the following conditions:
00044  *  - The plug-in list is updated.
00045  *  - A plug-in instance is created.
00046  *  - A plug-in instance is destroyed.
00047  *  - Everything else documented in Subject.
00048  *
00049  *  @see        PlugInArg, PlugInArgList
00050  */
00051 class PlugInManagerServices : public Subject
00052 {
00053 public:
00054    /**
00055     * The type that should be returned from PlugIn::getType()
00056     * for types of plug-in that implement the Importer interface.
00057     *
00058     * @return Returns the type used for importer plug-ins.
00059     */
00060    static std::string ImporterType()
00061    {
00062       return "Importer";
00063    }
00064    
00065    /**
00066     * The type that should be returned from PlugIn::getType()
00067     * for algorithm plug-ins.
00068     *
00069     * @return Returns the type used for algorithm plug-ins.
00070     *
00071     * @see AlgorithmShell
00072     */
00073    static std::string AlgorithmType()
00074    {
00075       return "Algorithm";
00076    }
00077 
00078    /**
00079     *  The type that should be returned from PlugIn::getType() for dock window
00080     *  plug-ins.
00081     *
00082     *  @return  Returns the type used for dock window plug-ins.
00083     *
00084     *  @see     DockWindowShell
00085     */
00086    static std::string DockWindowType()
00087    {
00088       return "DockWindow";
00089    }
00090 
00091    /**
00092     * The type that should be returned from PlugIn::getType()
00093     * for types of plug-in that implement the Exporter interface.
00094     *
00095     * @return Returns the type used for exporter plug-ins.
00096     */
00097    static std::string ExporterType()
00098    {
00099       return "Exporter";
00100    }
00101 
00102    /**
00103     * The type that should be returned from PlugIn::getType()
00104     * for types of plug-in that implement the Georeference interface.
00105     *
00106     * @return Returns the type used for georeference plug-ins.
00107     */
00108    static std::string GeoreferenceType()
00109    {
00110       return "Georeference";
00111    }
00112 
00113    /**
00114     * The type that should be returned from PlugIn::getType()
00115     * for types of plug-in that implement the InterpreterManager interface.
00116     *
00117     * @return Returns the type used for interpreter plug-ins.
00118     */
00119    static std::string InterpreterManagerType()
00120    {
00121       return "InterpreterManager";
00122    }
00123 
00124    /**
00125     *  The type that should be returned from PlugIn::getType()
00126     *  for types of plug-ins that implement the Properties interface.
00127     *
00128     *  @return  Returns the type used for properties plug-ins.
00129     *
00130     *  @see     PropertiesShell
00131     */
00132    static std::string PropertiesType()
00133    {
00134       return "Properties";
00135    }
00136 
00137    /**
00138     * The type that should be returned from PlugIn::getType()
00139     * for types of plug-in that implement the RasterPager interface.
00140     *
00141     * @return Returns the type used for raster pager plug-ins.
00142     */
00143    static std::string RasterPagerType()
00144    {
00145       return "RasterPager";
00146    }
00147 
00148    /**
00149     * The type that should be returned from PlugIn::getType()
00150     * for viewer plug-ins.
00151     *
00152     * @return Returns the type used for viewer plug-ins.
00153     *
00154     * @see ViewerShell
00155     */
00156    static std::string ViewerType()
00157    {
00158       return "Viewer";
00159    }
00160 
00161    /**
00162     * The type that should be returned from PlugIn::getType()
00163     * for wizard plug-ins.
00164     *
00165     * @return Returns the type used for wizard plug-ins.
00166     *
00167     * @see WizardShell
00168     */
00169    static std::string WizardType()
00170    {
00171       return "Wizard";
00172    }
00173 
00174    /**
00175     * The type that should be returned from PlugIn::getType()
00176     * for types of plug-ins that implement the Option interface.
00177     */
00178    static std::string OptionType()
00179    {
00180       return "Option";
00181    }
00182 
00183    /**
00184     *  Emitted with any<PlugIn*> when a new plug-in instance is created.
00185     */
00186    SIGNAL_METHOD(PlugInManagerServices, PlugInCreated)
00187 
00188    /**
00189     *  Emitted with any<PlugIn*> when a plug-in instance is about to be destroyed.
00190     */
00191    SIGNAL_METHOD(PlugInManagerServices, PlugInDestroyed)
00192 
00193    /**
00194     *  Emitted with any<ModuleDescriptor*> when a new module descriptor is created.
00195     */
00196    SIGNAL_METHOD(PlugInManagerServices, ModuleCreated)
00197 
00198    /**
00199     *  Emitted with any<ModuleDescriptor*> when a module descriptor is about to be destroyed.
00200     */
00201    SIGNAL_METHOD(PlugInManagerServices, ModuleDestroyed)
00202 
00203    /**
00204     *  Get running instances of a plug-in.
00205     *
00206     *  This method returns all running instances of a plug-in.
00207     *
00208     *  @param  plugInName
00209     *          Get instances of this named plug-in. If this string is empty, it
00210     *          will get all of the running instances of all plug-ins.
00211     *
00212     *  @return A vector of PlugIn pointers for running instances of the plug-in.
00213     */
00214    virtual std::vector<PlugIn*> getPlugInInstances(const std::string &plugInName=std::string()) = 0;
00215    
00216    /**
00217     *  Creates a new instance of a plug-in.
00218     *
00219     *  This method instantiates the plug-in of the given name
00220     *  and returns a reference to the new plug-in.
00221     *
00222     *  @param   plugInName
00223     *           The name of the plug-in to create.
00224     *
00225     *  @return  A pointer to the new plug-in.  NULL is returned if
00226     *           the plug-in cannot be created.  This may occur if
00227     *           an instance of the plug in already exists and the
00228     *           plug-in does not support multiple instances.
00229     *
00230     *  @see     PlugIn::areMultipleInstancesAllowed()
00231     */
00232    virtual PlugIn* createPlugIn(const std::string& plugInName) = 0;
00233 
00234    /**
00235     *  Destroys an instance of a plug-in.
00236     *
00237     *  @param   pPlugIn
00238     *           The plug-in to destroy.
00239     *
00240     *  @return  TRUE if the plug-in was successfully destroyed, otherwise FALSE.
00241     */
00242    virtual bool destroyPlugIn(PlugIn* pPlugIn) = 0;
00243 
00244    /**
00245     * Returns a list of all PlugInDescriptors that match the given type
00246     * as returned by PlugIn::getType().
00247     *
00248     * @param plugInType
00249     *        The type of plug-ins for which to return descriptors for.  If
00250     *        any empty string is provided, descriptors for all available
00251     *        plug-ins will be returned.
00252     * 
00253     * @return Returns a list all PlugInDescriptors that match the given type.
00254     */
00255    virtual std::vector<PlugInDescriptor*> getPlugInDescriptors(const std::string& plugInType = "") const = 0;
00256 
00257    /** 
00258     * Returns the PlugInDescriptor for the given plug-in.
00259     *
00260     * @param plugInName
00261     *        The plug-in to return the descriptor for.
00262     *
00263     * @return Returns the PlugInDescriptor for the given plug-in or NULL if no plug-in
00264     *         has been registered with the given name.
00265     */
00266    virtual PlugInDescriptor* getPlugInDescriptor(const std::string& plugInName) const = 0;
00267 
00268    /**
00269     *  Create an empty plug-in arg list.
00270     *  
00271     *  Creates an empty plug-in arg list to have PlugInArgs added
00272     *  to it.
00273     *
00274     *  @return  A pointer to the new list, or NULL if unsuccessful.
00275     */
00276    virtual PlugInArgList* getPlugInArgList() = 0;
00277 
00278    /**
00279     *  Destroys a plug-in arg list.
00280     *
00281     *  This method destroys a plug-in arg list, including all of its
00282     *  plug-in args. The args should not be destroyed prior to calling
00283     *  this method.
00284     *
00285     *  @param   pArgList
00286     *           A pointer to the arg-list to destroy.
00287     *
00288     *  @return  TRUE if the list and all of its args were destroyed or
00289     *           FALSE otherwise.
00290     */
00291    virtual bool destroyPlugInArgList(PlugInArgList* pArgList) = 0;
00292 
00293    /**
00294     *  Get the names of the known types.
00295     *
00296     *  This method returns the names of each recognized arg type.  Plug-ins
00297     *  can retrieve this list to query if a data type is in the known list.  The
00298     *  wizard builder uses this list connect plug-in in sequence according to their
00299     *  type names.  If an arg type exists that is not in this list, the wizard builder
00300     *  indicates it as an unknown type.
00301     *
00302     *  The default known types are as follows:
00303     *  - char
00304     *  - signed char
00305     *  - unsigned char
00306     *  - short
00307     *  - unsigned short
00308     *  - int
00309     *  - unsigned int
00310     *  - long
00311     *  - unsigned long
00312     *  - Int64
00313     *  - int64_t
00314     *  - UInt64
00315     *  - uint64_t
00316     *  - float
00317     *  - double
00318     *  - bool
00319     *  - string
00320     *  - vector<char>
00321     *  - vector<signed char>
00322     *  - vector<unsigned char>
00323     *  - vector<short>
00324     *  - vector<unsigned short>
00325     *  - vector<int>
00326     *  - vector<unsigned int>
00327     *  - vector<long>
00328     *  - vector<unsigned long>
00329     *  - vector<Int64>
00330     *  - vector<int64_t>
00331     *  - vector<UInt64>
00332     *  - vector<uint64_t>
00333     *  - vector<float>
00334     *  - vector<double>
00335     *  - vector<bool>
00336     *  - vector<string>
00337     *  - vector<Filename>
00338     *  - Animation
00339     *  - AnimationController
00340     *  - AnnotationElement
00341     *  - AnnotationLayer
00342     *  - Any
00343     *  - AoiElement
00344     *  - AoiLayer
00345     *  - CartesianPlot
00346     *  - ClassificationLayer
00347     *  - ColorType
00348     *  - CustomLayer
00349     *  - DataDescriptor
00350     *  - DataElement
00351     *  - DateTime
00352     *  - #DisplayMode
00353     *  - DynamicObject
00354     *  - #EncodingType
00355     *  - #EndianType
00356     *  - FileDescriptor
00357     *  - Filename
00358     *  - GcpLayer
00359     *  - GcpList
00360     *  - #GeocoordType
00361     *  - GraphicElement
00362     *  - GraphicLayer
00363     *  - HistogramPlot
00364     *  - #InterleaveFormatType
00365     *  - LatLonLayer
00366     *  - Layer
00367     *  - #LayerType
00368     *  - MeasurementLayer
00369     *  - OrthographicView
00370     *  - #PassArea
00371     *  - PerspectiveView
00372     *  - PlotView
00373     *  - PlotWidget
00374     *  - PolarPlot
00375     *  - #ProcessingLocation
00376     *  - ProductView
00377     *  - ProductWindow
00378     *  - Progress
00379     *  - PseudocolorLayer
00380     *  - RasterDataDescriptor
00381     *  - #RasterChannelType
00382     *  - RasterElement
00383     *  - RasterFileDescriptor
00384     *  - RasterLayer
00385     *  - #RegionUnits
00386     *  - Signature
00387     *  - SignatureDataDescriptor
00388     *  - SignatureFileDescriptor
00389     *  - SignatureLibrary
00390     *  - SignaturePlot
00391     *  - SignatureSet
00392     *  - SpatialDataView
00393     *  - SpatialDataWindow
00394     *  - #SymbolType
00395     *  - ThresholdLayer
00396     *  - TiePointList
00397     *  - TiePointLayer
00398     *  - #UnitType
00399     *  - View
00400     *  - Wavelengths
00401     *  - #WavelengthUnitsType
00402     *  - Window
00403     *  - WizardObject
00404     *
00405     *  @return  A vector of strings specifying the name of each known arg type.
00406     */
00407    virtual const std::vector<std::string>& getArgTypes() = 0;
00408 
00409    /**
00410     *  Creates a plug-in arg.
00411     *
00412     *  Creates a blank plug-in arg that can be added to a PlugInArgList.
00413     *
00414     *  @return  A pointer to the new arg, or NULL if unsuccessful.
00415     */
00416    virtual PlugInArg* getPlugInArg() = 0;
00417 
00418    /**
00419     *  Creates an empty dynamic module.
00420     *
00421     *  @param   value
00422     *           The name of the plug-in.
00423     *
00424     *  @return  A pointer to the new DynamicModule, or NULL if
00425     *           the module could not be created.
00426     *
00427     *  @see     DynamicModule::load()
00428     */
00429    virtual DynamicModule* getDynamicModule(const std::string& value) = 0;
00430 
00431    /**
00432     *  Destroys a dynamic module.
00433     *
00434     *  @param   pModule
00435     *           A pointer to the dynamic module to destroy.
00436     *
00437     *  @return  TRUE if the dynamic module was destroyed or
00438     *           FALSE otherwise.
00439     */
00440    virtual bool destroyDynamicModule(DynamicModule* pModule) = 0;
00441 
00442    /**
00443     *  Retrieves a non-thread-safe Progress object for a given plug-in.
00444     *
00445     *  This method retrieves a valid Progress object for the given plug-in, which
00446     *  remains valid throughout the life of the plug-in.  Because the Progress object
00447     *  set into the plug-in's input arg list may be deleted when Executable::execute()
00448     *  returns, this method should be called for plug-ins that will stay loaded after
00449     *  Executable::execute() returns and that need a valid Progress object.  This is
00450     *  especially useful for plug-ins that create modeless dialogs.
00451     *
00452     *  If a thread-safe Progress object is needed for a background plug-in running in
00453     *  a separate thread, use UtilityServices::getProgress() instead.
00454     *
00455     *  @param   pPlugIn
00456     *           The plug-in for which to get a Progress object.
00457     *
00458     *  @return  A pointer to the Progress object for the given plug-in.
00459     *
00460     *  @see     Executable::isDestroyedAfterExecute()
00461     */
00462    virtual Progress* getProgress(PlugIn* pPlugIn) = 0;
00463 
00464 protected:
00465    /**
00466     * This will be cleaned up during application close.  Plug-ins do not
00467     * need to destroy it.
00468     */
00469    virtual ~PlugInManagerServices() {}
00470 };
00471 
00472 #endif

Software Development Kit - Opticks 4.9.0 Build 16218