plugin_registry.hpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:9k
- /*
- * ===========================================================================
- * PRODUCTION $Log: plugin_registry.hpp,v $
- * PRODUCTION Revision 1000.3 2004/04/16 17:49:03 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [CATCHUP_003] Dev-tree R1.23
- * PRODUCTION
- * ===========================================================================
- */
- #ifndef GUI_CORE___PLUGIN_REGISTRY__HPP
- #define GUI_CORE___PLUGIN_REGISTRY__HPP
- /* $Id: plugin_registry.hpp,v 1000.3 2004/04/16 17:49:03 gouriano Exp $
- * ===========================================================================
- *
- * PUBLIC DOMAIN NOTICE
- * National Center for Biotechnology Information
- *
- * This software/database is a "United States Government Work" under the
- * terms of the United States Copyright Act. It was written as part of
- * the author's official duties as a United States Government employee and
- * thus cannot be copyrighted. This software/database is freely available
- * to the public for use. The National Library of Medicine and the U.S.
- * Government have not placed any restriction on its use or reproduction.
- *
- * Although all reasonable efforts have been taken to ensure the accuracy
- * and reliability of the software and data, the NLM and the U.S.
- * Government do not and cannot warrant the performance or results that
- * may be obtained by using this software or data. The NLM and the U.S.
- * Government disclaim all warranties, express or implied, including
- * warranties of performance, merchantability or fitness for any particular
- * purpose.
- *
- * Please cite the author in any work or product based on this material.
- *
- * ===========================================================================
- *
- * Authors: Mike DiCuccio
- *
- * File Description:
- * CPluginRegistry -- central repository for all plugin information
- */
- #include <corelib/ncbiobj.hpp>
- #include <gui/core/plugin_handle.hpp>
- #include <gui/core/plugin_factory.hpp>
- #include <gui/plugin/PluginCommandSet.hpp>
- #include <set>
- BEGIN_NCBI_SCOPE
- // a predeclaration for the plugin cache avoids an include here
- // this needs to be wrapped in namespace objects::
- BEGIN_SCOPE(objects)
- class CPluginCache;
- END_SCOPE(objects)
- class IDocument;
- class CSelectionBuffer;
- //
- // class CPluginRegistry is responsible for maintaining a list of the active
- // plugin handles and controlling the loading of all plugins.
- //
- // This class maintains a list of all plugin handles available for the system.
- // There are accessor functions to retrieve plugins based on different sets of
- // criteria (i.e., all view plugins, all algorithm plugins, etc.).
- //
- class NCBI_GUICORE_EXPORT CPluginRegistry
- {
- friend class CPluginHandle_Impl;
- public:
- // flags controlling what sorts of plugins to retrieve
- enum EFlags {
- fHidden = 0x01 // include "hidden" plugins (plugins with no menu item)
- };
- typedef int TFlags;
- // enum controlling how user plugins are serialized
- enum EUserPlugin {
- ePersistent,
- eNonPersistent
- };
- // typedef for a set of plugin handles - intended for external consumption
- typedef list<CPluginHandle> TPlugins;
- // Add to the current registry the plugins listed in a plugin cache file
- // found in the specified directory
- static void InitPlugins(const string& path);
- // Clear() is called at application exit by the document manager. The
- // intent is to flush any CRef<>'d pointers out of the internal store
- static void Clear(void);
- // add a plugin implemented indirectly, e.g., via an external executable
- static void RegisterPlugin(CRef<objects::CPluginInfo> info,
- CPluginFactoryBase *factory);
- // add a user-defined plugin
- static CPluginHandle AddPlugin(objects::CPluginLibInfo& libinfo,
- EUserPlugin mode = ePersistent);
- // Retrieve a specifically and uniquely named plugin
- static CPluginHandle GetPlugin(const string& name);
- // retrieve a list of all plugins
- static TPlugins GetPlugins(TFlags flags = 0);
- // retrieve a list of plugins for a given command type (data, algo, or view)
- static TPlugins GetPlugins(objects::CPluginCommandSet::E_Choice,
- TFlags flags = 0);
- // retrieve a list of plugins for a given command. This version will
- // return only those plugins that support an input parameter compatible
- // with a given of the current document. This command is a specific view,
- // data, or algorithm command
- static TPlugins GetPlugins(objects::EAlgoCommand cmd,
- TFlags flags = 0);
- static TPlugins GetPlugins(objects::EDataCommand cmd,
- const IDocument* doc,
- TFlags flags = 0);
- static TPlugins GetPlugins(objects::EViewCommand cmd,
- TFlags flags = 0);
- static TPlugins GetPlugins(objects::EDataCommand cmd,
- const CSelectionBuffer& buf,
- TFlags flags = 0);
- protected:
- // force loading of a library
- static void x_LoadLibrary(const string& lib_name);
- // internal init function, called after successful reading of a plugin
- // cache file
- static void x_InitPlugins(const string& path,
- objects::CPluginCache& cache);
- };
- END_NCBI_SCOPE
- #endif // GUI_CORE___PLUGIN_REGISTRY__HPP
- /*
- * ===========================================================================
- * $Log: plugin_registry.hpp,v $
- * Revision 1000.3 2004/04/16 17:49:03 gouriano
- * PRODUCTION: UPGRADED [CATCHUP_003] Dev-tree R1.23
- *
- * Revision 1.23 2004/04/16 14:31:30 dicuccio
- * Changed plugin access for algorithms and views - no selection arguments
- * required
- *
- * Revision 1.22 2003/11/06 19:54:22 dicuccio
- * Removed USING_SCOPE(objects).
- *
- * Revision 1.21 2003/11/04 17:12:24 dicuccio
- * Added Clear() to purge existing handles and plugin instances
- *
- * Revision 1.20 2003/10/27 17:28:32 dicuccio
- * Changed AddUserPlugin() to more general AddPlugin()
- *
- * Revision 1.19 2003/10/23 16:12:30 dicuccio
- * Added API for manually adding plugins
- *
- * Revision 1.18 2003/09/04 14:00:26 dicuccio
- * Introduce IDocument and IView as abstract base classes. Use IDocument instead
- * of CDocument.
- *
- * Revision 1.17 2003/08/21 12:13:42 dicuccio
- * Removed stray ',' that was causing some compiler warnings
- *
- * Revision 1.16 2003/07/28 19:29:29 jcherry
- * Added CPluginRegistry::RegisterPlugin for registering 'external'
- * (executable) plugins
- *
- * Revision 1.15 2003/07/21 19:19:00 dicuccio
- * Added interface to request plugins given a set of selections
- *
- * Revision 1.14 2003/06/30 13:43:13 dicuccio
- * Added API to screen for plugins that shouldn't appear in menus
- *
- * Revision 1.13 2003/06/25 19:55:23 dicuccio
- * Fixed compilation for Windows - missing include, namespace weirdness
- *
- * Revision 1.12 2003/06/25 16:59:41 dicuccio
- * Changed CPluginHandle into a pointer-to-implementation (the previous
- * implementation is now the pointer held). Lots of #include file clean-ups.
- *
- * Revision 1.11 2003/05/19 13:32:43 dicuccio
- * Moved gui/core/plugin --> gui/plugin/
- *
- * Revision 1.10 2003/05/08 16:17:39 dicuccio
- * Changed CFastMutex -> CMutex (locks must be recursive-safe)
- *
- * Revision 1.9 2003/05/06 15:50:46 dicuccio
- * Added mutex guarding access to the plugin registry
- *
- * Revision 1.8 2003/05/05 12:39:59 dicuccio
- * Added new interface function 9CanFitArgs()) for testing whether a group of
- * selections or objects could possibly apply to a set of arguments
- *
- * Revision 1.7 2003/04/29 14:29:43 dicuccio
- * Added interface function (template) to retrieve plugins that support a given
- * plugin command
- *
- * Revision 1.6 2003/03/25 19:36:04 dicuccio
- * Remove explicit class qualifier from static member function
- *
- * Revision 1.5 2003/03/25 14:20:47 dicuccio
- * Changed export specifier from XGBPLUGIN to GUICORE
- *
- * Revision 1.4 2003/03/13 18:13:23 dicuccio
- * Added accessor for single, named plugin
- *
- * Revision 1.3 2003/02/24 13:00:17 dicuccio
- * Renamed classes in plugin spec:
- * CArgSeg --> CPluginArgSet
- * CArgument --> CPluginArg
- * CPluginArgs --> CPluginCommand
- * CPluginCommands --> CPluginCommandSet
- *
- * Revision 1.2 2003/02/21 16:44:13 dicuccio
- * Added Win32 export specifiers for new plugin library. Fixed compilation
- * issues for Win32.
- *
- * Revision 1.1 2003/02/20 19:44:06 dicuccio
- * Created new plugin architecture, mediated via an ASN.1 spec. Moved GBENCH
- * framework over to use new plugin architecture.
- *
- * ===========================================================================
- */