doc_manager.cpp

来自「ncbi源码」· C++ 代码 · 共 550 行 · 第 1/2 页

CPP
550
字号
    CRef<IDocument> doc(new CSeqIdDocument(scope, id));    sm_Documents.push_back(doc);    sm_ScopeIdx[ CRef<CScope>(&scope) ] = doc;    return doc.GetPointer();}IDocument* CDocManager::CreateDocument(CScope& scope, const CSerialObject& obj){    CMutexGuard LOCK(s_DocMgrMutex);    CRef<IDocument> doc(new CSerialObjDocument(scope, obj));    sm_Documents.push_back(doc);    sm_ScopeIdx[ CRef<CScope>(&scope) ] = doc;    return doc.GetPointer();}//// ReleaseDocument()// this is responsible for making sure that documents can indeed// be deleted//bool CDocManager::ReleaseDocument(IDocument* doc){    CMutexGuard LOCK(s_DocMgrMutex);    CRef<IDocument> ref(doc);    TDocList::iterator iter =        std::find(sm_Documents.begin(), sm_Documents.end(), ref);    if (iter != sm_Documents.end()) {        // clear all views from the document first        doc->Clear();        sm_Documents.erase(iter);        // also remove it from the scope index        NON_CONST_ITERATE (TScopeIndex, iter, sm_ScopeIdx) {            if (iter->second.GetPointer() == doc) {                sm_ScopeIdx.erase(iter);                break;            }        }        UpdateAllViews();        LOG_POST(Error << "unloaded document: " << ref->GetShortTitle());        return true;    } else {        return false;    }}//// CachePluginMessage// Cache the plugin messgae for the Most Recent Used list// void CDocManager::AddMRUEntry(objects::CPluginMessage& msg, string label){    // Cache messages whose reply is not formatted    if (msg.GetReply().IsSetFormatted()) {        return;    }        CMutexGuard LOCK(s_DocMgrMutex);//    sm_PluginMessageCache.Add(msg, CPluginUtils::GetPluginMessageLabel(msg));    GetMRUCache().Add(msg, label);}CPluginMRUList& CDocManager::GetMRUCache(void){    if ( !sm_PluginMessageCache ) {        CMutexGuard LOCK(s_DocMgrMutex);        if ( !sm_PluginMessageCache ) {            sm_PluginMessageCache.Reset(new CPluginMRUList("mru-cache"));        }    }    return *sm_PluginMessageCache;}END_NCBI_SCOPE/* * =========================================================================== * $Log: doc_manager.cpp,v $ * Revision 1000.5  2004/06/01 20:43:48  gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.50 * * Revision 1.50  2004/06/01 18:02:19  dicuccio * Changed GetPluginMessageCache() -> GetMRUCache() * * Revision 1.49  2004/05/21 22:27:40  gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.48  2004/05/18 11:13:24  friedman * Handle adding recently loaded documents into the MRU list. * * Revision 1.47  2004/05/07 15:40:33  dicuccio * gui/objutils/clipboard -> gui/objutils/obj_clipboard * * Revision 1.46  2004/05/03 12:48:46  dicuccio * gui/utils --> gui/objutils where needed * * Revision 1.45  2004/04/21 17:12:33  dicuccio * Added const version of GetDocumentFromScope() * * Revision 1.44  2004/04/16 14:37:28  dicuccio * Remove dead code in Update() * * Revision 1.43  2004/04/07 12:45:06  dicuccio * Formatting changes.  Added scope -> document index.  Added * GetDocumentFromScope() * * Revision 1.42  2004/03/30 17:09:01  tereshko * Added NotifyAllViews function * * Revision 1.41  2004/02/17 20:35:23  rsmith * moved core/settings.[ch]pp and core/system_path.[ch]pp to config and utils, respectively. * * Revision 1.40  2004/02/03 21:24:11  dicuccio * Clear the clipboard on ShutDown() * * Revision 1.39  2004/01/07 17:39:01  vasilche * Fixed include path to genbank loader. * * Revision 1.38  2003/12/22 19:18:48  dicuccio * COmmented out unnecessary view update * * Revision 1.37  2003/11/14 17:50:58  dicuccio * Fix silly compiler error introduced in last commit. * * Revision 1.36  2003/11/14 17:44:18  dicuccio * Changed ShutDown() to clear more components * * Revision 1.35  2003/11/04 17:15:52  dicuccio * Added more to ShutDown(): clear the object store; clear the registry * * Revision 1.34  2003/10/07 13:46:14  dicuccio * Drop documents in reverse order (safety concern if documents are * interdependent) * * Revision 1.33  2003/09/16 14:01:40  dicuccio * Removed CSeqannotDocument - replaced with generic CSerialObjDocument * * Revision 1.32  2003/09/04 14:01:51  dicuccio * Introduce IDocument and IView as abstract base classes for CDocument and CView * * Revision 1.31  2003/06/30 13:32:34  dicuccio * Removed GenBank data loader - this now lives in a plugin of its own * * Revision 1.30  2003/06/29 13:10:17  dicuccio * Use DEFINE_STATIC_MUTEX() instead of static member variables * * Revision 1.29  2003/06/25 17:02:54  dicuccio * Split CPluginHandle into a handle (pointer-to-implementation) and * implementation file.  Lots of #include file clean-ups. * * Revision 1.28  2003/06/18 13:54:48  rsmith * cnstr/destr of sm_Views or sm_Documents uses s_DocMgrMutex. Set order * accordingly.  Useless to guard GetSettings since a reference is returned. * * Revision 1.27  2003/06/02 16:06:17  dicuccio * Rearranged src/objects/ subtree.  This includes the following shifts: *     - src/objects/asn2asn --> arc/app/asn2asn *     - src/objects/testmedline --> src/objects/ncbimime/test *     - src/objects/objmgr --> src/objmgr *     - src/objects/util --> src/objmgr/util *     - src/objects/alnmgr --> src/objtools/alnmgr *     - src/objects/flat --> src/objtools/flat *     - src/objects/validator --> src/objtools/validator *     - src/objects/cddalignview --> src/objtools/cddalignview * In addition, libseq now includes six of the objects/seq... libs, and libmmdb * replaces the three libmmdb? libs. * * Revision 1.26  2003/05/30 14:15:41  dicuccio * Renamed MessageBox to NcbiMessageBox because brain-dead MSVC thinks this is * ::MessageBox and rewrites the symbol as MessageBoxA, which results in an * unresolved external and conflict with the Win32 API :(. * * Revision 1.25  2003/05/30 12:56:50  dicuccio * Converted code to use MessageBox() instead of * fl_ask()/fl_message()/fl_alert() * * Revision 1.24  2003/05/09 14:29:35  dicuccio * Remember to update all docmanager views after deleting a document.  Changed * log messaged for deleted document * * Revision 1.23  2003/05/08 20:10:24  dicuccio * Added LOG_POST for unloading documents * * Revision 1.22  2003/05/08 16:18:59  dicuccio * Changed CFastMutex --> CMutex - guards against recursive locking * * Revision 1.21  2003/04/30 13:53:14  dicuccio * Made access of CDocManager internals thread safe * * Revision 1.20  2003/04/29 14:37:17  dicuccio * Removed old typing system * * Revision 1.19  2003/04/24 16:27:09  dicuccio * Added new marshalling functions for creating documents from given object * components. * * Revision 1.18  2003/04/16 11:38:13  dicuccio * Reordered shutdown procedure - clear current doc manager views first * * Revision 1.17  2003/03/17 14:49:54  dicuccio * Removed header file dependency on view.hpp * * Revision 1.16  2003/03/10 22:58:51  kuznets * iterate -> ITERATE * * Revision 1.15  2003/02/20 19:49:54  dicuccio * Created new plugin architecture, based on ASN.1 spec.  Moved GBENCH frameowrk * over to use new plugin architecture. * * Revision 1.14  2003/02/05 19:50:52  dicuccio * Wrapped creation of a data loader in a try{}...catch(){} to avoid fatal * exceptions if there is no network available. * * Revision 1.13  2003/01/15 21:07:52  dicuccio * Added CSettings member variable.  Removed a number of dead _TRACE() * statements * * Revision 1.12  2003/01/13 13:10:06  dicuccio * Namespace clean-up.  Retired namespace gui -> converted all to namespace * ncbi.  Moved all FLUID-generated code into namespace ncbi. * * Revision 1.11  2003/01/10 17:36:41  dicuccio * Changed TPluginList --> TPlugins * * Revision 1.10  2002/12/30 17:53:26  dicuccio * Modified function of ReleaseDocument() - don't call UpdateAllViews() (this * function is called from a menu callback; we delay this call to avoid * inadvertently returning to a destroyed object). * * Revision 1.9  2002/12/20 19:16:49  dicuccio * Better handling of document release - must free views before releasing * document; also, notify all views and documents of a release through a new * event * * Revision 1.8  2002/12/12 15:17:30  dicuccio * Added a selection buffer specific to the document manager - provides global * selections * * Revision 1.7  2002/11/29 16:34:59  dicuccio * Reformatted tabs -> spaces * * Revision 1.6  2002/11/29 16:03:06  dicuccio * Removed a bunch of dead code.  Modified the use of NCBI_THROW to be correct * and avoid compile errors on Windows. * * Revision 1.5  2002/11/25 20:53:05  dicuccio * Changed singleton implementation of CDocManager to pure static implementation * (more in line with rest of framework) * * Revision 1.4  2002/11/14 16:15:48  dicuccio * Removed unecessary _TRACE() macros * * Revision 1.3  2002/11/09 20:50:09  dicuccio * Changed IDocument::x_GetViews() (non-const) and x_AttachView() from private * to public. * * Revision 1.2  2002/11/07 18:38:21  dicuccio * Changed the auto_ptr<> implementation to be a static auto_ptr<>. * Changed code to use ERR_POST() and _TRACE(). * * Revision 1.1  2002/11/06 15:49:47  dicuccio * Initial revision * * =========================================================================== */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?