doc_manager.hpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:10k
- /*
- * ===========================================================================
- * PRODUCTION $Log: doc_manager.hpp,v $
- * PRODUCTION Revision 1000.2 2004/06/01 19:46:44 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.25
- * PRODUCTION
- * ===========================================================================
- */
- #ifndef GUI_CORE___DOC_MANAGER__HPP
- #define GUI_CORE___DOC_MANAGER__HPP
- /* $Id: doc_manager.hpp,v 1000.2 2004/06/01 19:46:44 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:
- * Central document arbiter for GBENCH
- */
- #include <corelib/ncbiobj.hpp>
- #include <gui/gui.hpp>
- #include <list>
- BEGIN_NCBI_SCOPE
- BEGIN_SCOPE(objects)
- class CObjectManager;
- class CScope;
- class CSeq_id;
- class CPluginMessage;
- class CPluginMRUList;
- END_SCOPE(objects)
- class CDocMgrView;
- class IDocument;
- class CSelectionBuffer;
- class CSettings;
- class CSerialObject;
- class CEvent;
- //
- // class CDocManager is the central repository for all documents
- //
- // This class maintains all active records and controls the creation of any new
- // records. This class holds the one and only instance of the object manager,
- // and mediates communication between document loaders and the object manager
- // itself. In addition, this class is a clearing house for global
- // application-specific settings, provided that these settings do not directly
- // require the presence of a GUI: the settings may be colors, for example, but
- // not widgets. class CDocManager supports a limited viewing context by
- // maintaining a list of specific document manager view classes that are bound
- // to it. These view classes receive update notifications when the document
- // manager changes.
- //
- class NCBI_GUICORE_EXPORT CDocManager
- {
- public:
- typedef list< CRef<IDocument> > TDocList;
- typedef list< CRef<CDocMgrView> > TViewList;
- // Explicitly force the document manager to shut everything down:
- // destroy all views and documents, shutdown the underlying object manager
- static void ShutDown();
- // Request a new document, referencing some sequence in a scope
- // by a sequence ID. This is used for things such as remote fetch
- // or simple indexed retrieval.
- static IDocument* CreateDocument(objects::CScope& scope,
- const objects::CSeq_id& id);
- // Request a document wrapped around a substantial object.
- // This object can be any CSerialObject-derived object, and represents
- // a core chunk of information, such as a seq-entry or a seq-submit.
- static IDocument* CreateDocument(objects::CScope& scope,
- const CSerialObject& obj);
- // Release a document from management
- static bool ReleaseDocument(IDocument* doc);
- // retrieve a document from its scope
- static IDocument* GetDocumentFromScope(objects::CScope& scope);
- static const IDocument* GetDocumentFromScope(const objects::CScope& scope);
- // Attach a view to the document manager.
- // NOTE: this is distinct from views managed by documents; these views
- // receive notification on updates to the document manager only, and are
- // not connected to any real document!
- static void AttachView(CDocMgrView* view);
- // Update all views.
- // Facilitates communication between the document manager and its views.
- static void UpdateAllViews(TUpdateFlags flags = fAllEvents);
- // Notify all views
- // Event broadcasting function
- static void NotifyAllViews(const CEvent * event);
- // Get a list of all currently loaded documents
- static TDocList& GetDocuments(void);
- // access the object manager
- static objects::CObjectManager& GetObjectManager(void);
- // access our selection buffer
- static CSelectionBuffer& GetSelBuffer(void);
- // access the global settings repository
- static CSettings& GetSettings(void);
- // Cache the plugin messgae for the Most Recent Used list
- static void AddMRUEntry(objects::CPluginMessage& msg, string label = kEmptyStr);
- static objects::CPluginMRUList& GetMRUCache(void);
- private:
- // our one and only object manager
- static CRef<objects::CObjectManager> sm_ObjMgr;
- // a list of the documents we manage
- static TDocList sm_Documents;
- // an index of scope -> document
- typedef map< CRef<objects::CScope>, CRef<IDocument> > TScopeIndex;
- static TScopeIndex sm_ScopeIdx;
- // a list of the views attached to the document manager
- // this list received information only when the document manager is updated
- // these views are not connected to any document!
- static TViewList sm_Views;
- // The document manager also maintains a global selection pool
- static CRef<CSelectionBuffer> sm_SelBuffer;
- // We maintain one clearing-house for all application-wide settings
- static CRef<CSettings> sm_Settings;
- // force creation of the data loader structures
- static void x_CreateObjectManager(void);
- // Most Recently Used plugin message cache
- static CRef<objects::CPluginMRUList> sm_PluginMessageCache;
- // all constructing / copying of doc managers is forbidden
- CDocManager();
- ~CDocManager();
- CDocManager(const CDocManager&);
- CDocManager& operator= (const CDocManager&);
- };
- END_NCBI_SCOPE
- #endif // GUI_CORE___DOC_MANAGER__HPP
- /*
- * ===========================================================================
- * $Log: doc_manager.hpp,v $
- * Revision 1000.2 2004/06/01 19:46:44 gouriano
- * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.25
- *
- * Revision 1.25 2004/06/01 18:06:39 dicuccio
- * FOrmatting changes. Renamed GetPluginMessageCache() -> GetMRUCache()
- *
- * Revision 1.24 2004/05/18 11:31:17 friedman
- * Handle adding recently loaded documents into the MRU list.
- *
- * Revision 1.23 2004/04/21 17:12:58 dicuccio
- * Added const version of GetDocumentFromScope()
- *
- * Revision 1.22 2004/04/07 12:33:21 dicuccio
- * Added GetDocumentFromScope(), scope -> document index
- *
- * Revision 1.21 2004/03/30 17:08:44 tereshko
- * Added NotifyAllViews function
- *
- * Revision 1.20 2004/03/11 17:14:57 dicuccio
- * Changed gui/types to gui/gui
- *
- * Revision 1.19 2003/09/29 15:20:06 dicuccio
- * Deprecated gui/scope.hpp. Merged gui/core/types.hpp into gui/types.hpp
- *
- * Revision 1.18 2003/09/16 14:03:43 dicuccio
- * Removed API for creating documents based on seq-annots - replaced with generic
- * API to create documents based on CSerialObject
- *
- * Revision 1.17 2003/09/04 14:00:26 dicuccio
- * Introduce IDocument and IView as abstract base classes. Use IDocument instead
- * of CDocument.
- *
- * Revision 1.16 2003/08/22 15:54:48 dicuccio
- * General clean-up: Removed unneeded export specifiers from templates; removed
- * 'USING_SCOPE(objects)'
- *
- * Revision 1.15 2003/06/29 13:10:56 dicuccio
- * Use DEFINE_STATIC_MUTEX() instead of static member variable
- *
- * Revision 1.14 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.13 2003/06/02 16:01:29 dicuccio
- * Rearranged include/objects/ subtree. This includes the following shifts:
- * - include/objects/alnmgr --> include/objtools/alnmgr
- * - include/objects/cddalignview --> include/objtools/cddalignview
- * - include/objects/flat --> include/objtools/flat
- * - include/objects/objmgr/ --> include/objmgr/
- * - include/objects/util/ --> include/objmgr/util/
- * - include/objects/validator --> include/objtools/validator
- *
- * Revision 1.12 2003/05/08 16:17:39 dicuccio
- * Changed CFastMutex -> CMutex (locks must be recursive-safe)
- *
- * Revision 1.11 2003/04/30 13:51:50 dicuccio
- * Made access of CDocmanager internals thread safe
- *
- * Revision 1.10 2003/04/24 16:10:43 dicuccio
- * Added new interface functions for creating documents from a number of
- * data-model types
- *
- * Revision 1.9 2003/01/15 20:54:46 dicuccio
- * Corrected docoumentation. Added CSettings class to hold global app-wide
- * settings (colors, etc.)
- *
- * Revision 1.8 2003/01/13 13:11:41 dicuccio
- * Namespace clean-up. Retired namespace gui -> converted to namespace ncbi.
- * Moved all FLUID-generated code into namespace ncbi.
- *
- * Revision 1.7 2002/12/26 14:19:55 dicuccio
- * Added Win32 export specifiers.
- *
- * Revision 1.6 2002/12/19 18:13:02 dicuccio
- * Added export specifiers for Win32.
- *
- * Revision 1.5 2002/12/12 15:17:30 dicuccio
- * Added a selection buffer specific to the document manager - provides global
- * selections
- *
- * Revision 1.4 2002/11/29 15:55:17 dicuccio
- * Added somewhat obtuse work-around for MSVC's handling of namespaces (the
- * nested namespace ncbi::objects presents a lot of difficulty for MSVC's
- * compiler)
- *
- * Revision 1.3 2002/11/25 19:26:07 dicuccio
- * Reverted singleton interface in favor of a pure static interface (more in line
- * with the remainder of the framework).
- *
- * Revision 1.2 2002/11/07 18:20:12 dicuccio
- * Moved #ifdef to top of file.
- *
- * Revision 1.1 2002/11/04 21:09:05 dicuccio
- * Initial revision
- *
- * ===========================================================================
- */