file_loader.cpp

来自「ncbi源码」· C++ 代码 · 共 1,097 行 · 第 1/3 页

CPP
1,097
字号
}//// x_Load() - load a given record into a document//void CDataPlugin_FileLoader::x_Load(CBioseq_set& bioseq_set, IDocument* doc,                         CPluginReply& reply){    CObjectConverter::TObjList objs;    CRef<CScope> scope;    if (doc) {        scope = &doc->GetScope();    } else {        scope = (new CScope(CDocManager::GetObjectManager()));        scope->AddDefaults();    }    CObjectConverter::Convert(*scope, bioseq_set,                              CSeq_entry::GetTypeInfo(), objs);    NON_CONST_ITERATE (CObjectConverter::TObjList, iter, objs) {        CSeq_entry& entry =            const_cast<CSeq_entry&>(dynamic_cast<const CSeq_entry&>(**iter));        x_Load(entry, doc, reply);    }}//// x_Load() - load a given record into a document//void CDataPlugin_FileLoader::x_Load(CBioseq& bioseq, IDocument* doc,                         CPluginReply& reply){    CObjectConverter::TObjList objs;    CRef<CScope> scope;    if (doc) {        scope = &doc->GetScope();    } else {        scope = (new CScope(CDocManager::GetObjectManager()));        scope->AddDefaults();    }    CObjectConverter::Convert(*scope, bioseq,                              CSeq_entry::GetTypeInfo(), objs);    ITERATE (CObjectConverter::TObjList, iter, objs) {        CSeq_entry& entry =            const_cast<CSeq_entry&>(dynamic_cast<const CSeq_entry&>(**iter));        x_Load(entry, doc, reply);    }}//// x_Load() - load a given record into a document// This version adds a given annotation to the current record, or creates a new// one as needed.//void CDataPlugin_FileLoader::x_Load(CSeq_annot& annot, IDocument* doc,                         CPluginReply& reply){    try {        if (doc) {            doc->AttachAnnot(annot);            doc->PostDocumentChanged();            reply.SetStatus(eMessageStatus_success);            LOG_POST(Info << "Imported and attached Seq-annot");        } else {            CRef<CScope> scope(new CScope(CDocManager::GetObjectManager()));            scope->AddDefaults();            IDocument* doc = CDocManager::CreateDocument(*scope, annot);            reply.AddObject(*doc);            reply.SetStatus(eMessageStatus_success);            LOG_POST(Info << "Imported Seq-annot");        }    }    catch (CDocException& e) {        LOG_POST(Error << "Error loading annotation: " << e.what());    }}//// x_Load() - load a given record into a document//void CDataPlugin_FileLoader::x_Load(CSeq_submit& submit, IDocument* doc,                         CPluginReply& reply){    CRef<CScope> scope;    if (doc) {        scope.Reset(&doc->GetScope());    } else {        scope.Reset(new CScope(CDocManager::GetObjectManager()));        scope->AddDefaults();    }    // a seq-submit may contain multiple records    // first, Seq-entries    if (submit.GetData().IsEntrys()) {        NON_CONST_ITERATE (CSeq_submit::C_Data::TEntrys, iter,                           submit.SetData().SetEntrys()) {            scope->AddTopLevelSeqEntry(**iter);        }    }    // next, Seq-annots    if (submit.GetData().IsAnnots()) {        CObjectConverter::TObjList entries;        NON_CONST_ITERATE (CSeq_submit::C_Data::TAnnots, iter,                           submit.SetData().SetAnnots()) {            CObjectConverter::Convert(*scope, **iter,                                      CSeq_entry::GetTypeInfo(), entries);        }        ITERATE (CObjectConverter::TObjList, iter, entries) {            const CSeq_entry& entry = dynamic_cast<const CSeq_entry&>(**iter);            scope->AddTopLevelSeqEntry(const_cast<CSeq_entry&>(entry));        }    }    if ( !doc ) {        doc = CDocManager::CreateDocument(*scope, submit);        reply.AddObject(*doc);    } else {        reply.AddObject(*doc, submit);    }    reply.SetStatus(eMessageStatus_success);    LOG_POST(Info << "Imported Seq-submit");}END_NCBI_SCOPE/* * =========================================================================== * $Log: file_loader.cpp,v $ * Revision 1000.6  2004/06/01 20:57:37  gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.67 * * Revision 1.67  2004/05/25 17:21:59  dicuccio * Modified class names.  Fonts to 12 point * * Revision 1.66  2004/05/21 22:27:48  gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.65  2004/05/18 11:22:34  friedman * Add recently loaded documents to the MRU list. * * Revision 1.64  2004/05/03 13:05:42  dicuccio * gui/utils --> gui/objutils where needed * * Revision 1.63  2004/04/14 21:04:11  jcherry * Open file in binary mode so binary asn.1 works * * Revision 1.62  2004/04/09 18:37:26  dicuccio * Added default resolvers to scopre for seq-submit * * Revision 1.61  2004/04/05 14:27:10  dicuccio * Added check to make sure the file exists before opening.  Added support for * seq-align-set conversions * * Revision 1.60  2004/03/29 20:06:35  jcherry * Don't try to get scope from null document pointer * * Revision 1.59  2004/03/24 22:13:36  ucko * Use the correct type (CT_POS_TYPE rather than int) for tellg's return value. * * Revision 1.58  2004/03/23 22:09:01  jcherry * Isolate stream operations from file stuff * * Revision 1.57  2004/03/23 13:38:47  dicuccio * Cleaned up use of convert function - use standard object conversion routines * * Revision 1.56  2004/03/22 15:14:27  jcherry * Added short synonyms for file type strings * * Revision 1.55  2004/03/16 15:59:50  vasilche * Removed warning about unused exception variable * * Revision 1.54  2004/03/11 17:42:01  dicuccio * Dropped unneeded #includes * * Revision 1.53  2004/03/09 22:12:50  jcherry * Catch std::exception when reading Newick * * Revision 1.52  2004/03/01 22:55:56  jcherry * Use string rather than char* for format names (find was comparing * pointer values) * * Revision 1.51  2004/03/01 21:42:39  dicuccio * Use correct exception class for alignment reader * * Revision 1.50  2004/03/01 15:12:04  dicuccio * Added support for CLUSTAL alignments.  Added handling of type specification in * plugin args.  Added support for Newic format phylogenetic trees. * * Revision 1.49  2004/01/27 18:45:32  dicuccio * Added missing header files * * Revision 1.48  2004/01/21 12:38:19  dicuccio * redesigned CObjectCOnverter API to eliminate temporary object creation * * Revision 1.47  2004/01/06 20:48:17  dicuccio * Moved CFltkCursorGuard into CPlugin::Execute() - broadly applied to all plugins * * Revision 1.46  2004/01/06 20:15:53  dicuccio * Use CFltkCursorGuard on load / import / search * * Revision 1.45  2004/01/06 17:19:09  rsmith * Took out class specifier (CSniffReader::) within class definition. * * Revision 1.44  2004/01/05 15:02:57  kuznets * Bug fix: implemented Reset() function to correctly restore after a * failed try. * * Revision 1.43  2003/12/31 20:29:31  dicuccio * Turned on use of file type arguments.  Fixed issues relating to importation of * items into scopes - can now import anything. * * Revision 1.42  2003/12/22 19:29:35  dicuccio * Updated to macth API changes in IDocument - UpdateAllViews() goes away * * Revision 1.41  2003/11/24 15:45:33  dicuccio * Renamed CVersion to CPluginVersion * * Revision 1.40  2003/11/18 17:49:01  dicuccio * Added standard processing of return values * * Revision 1.39  2003/11/06 20:12:15  dicuccio * Cleaned up handling of USING_SCOPE - removed from all headers * * Revision 1.38  2003/11/04 17:49:24  dicuccio * Changed calling parameters for plugins - pass CPluginMessage instead of paired * CPluginCommand/CPluginReply * * Revision 1.37  2003/10/10 17:17:28  dicuccio * Added Import() method - split out from Load() * * Revision 1.36  2003/10/07 13:47:05  dicuccio * Renamed CPluginURL* to CPluginValue* * * Revision 1.35  2003/09/16 14:07:28  dicuccio * Removed Save function - split into separate plugin class * * Revision 1.34  2003/09/04 14:51:01  dicuccio * Use IDocument instead of CDocument * * Revision 1.33  2003/07/25 14:59:05  kuznets * Improved diagnostics when Open/Create document throws an exception. * * Revision 1.32  2003/07/23 19:14:09  dicuccio * Moved logic for validating plugin arguments into CPluginUtils. * * Revision 1.31  2003/07/21 19:33:27  dicuccio * Call IDocument::UpdateAllViews() after adding annotations to a document * * Revision 1.30  2003/07/14 11:16:41  shomrat * Plugin messageing system related changes * * Revision 1.29  2003/07/08 20:17:31  kuznets * Improved diagnostics * * Revision 1.28  2003/06/25 17:02:58  dicuccio * Split CPluginHandle into a handle (pointer-to-implementation) and * implementation file.  Lots of #include file clean-ups. * * Revision 1.27  2003/06/23 13:23:13  dicuccio * Deprecated seq_utils.[h,c]pp - moved functions into gui.utils/utils.hpp * * Revision 1.26  2003/06/20 14:52:57  dicuccio * Revised plugin registration - moved GetInfo() into the plugin handler * * Revision 1.25  2003/06/19 16:15:23  dicuccio * Check to make sure the argument named 'document' exists before referencing it. * * Revision 1.24  2003/06/17 19:14:56  dicuccio * Cleaned up and re-enabled file importing * * Revision 1.23  2003/06/16 16:00:44  dicuccio * Code clean-up - removed old functions, reformatted. * * Revision 1.22  2003/06/10 14:59:13  kuznets * File opening reimplemented using CObjectsSniffer(obj_sniff.hpp) * * Revision 1.21  2003/06/04 19:40:37  ucko * Update #include for FASTA reader. * * Revision 1.20  2003/05/19 13:40:44  dicuccio * Moved gui/core/plugin/ -> gui/plugin/.  Merged core libraries into libgui_core. * Removed old, unused dialog box. * * Revision 1.19  2003/04/24 16:39:08  dicuccio * Updated to reflect changes in plugin API.  Changed location of document marshal * from framework to plugin * * Revision 1.18  2003/04/16 18:25:28  dicuccio * Removed older file read mechanism, in favor of a more precise mechanism, * especially when reading ASN.1 text or XML * * Revision 1.17  2003/03/11 15:23:29  kuznets * iterate -> ITERATE * * Revision 1.16  2003/02/28 15:07:21  dicuccio * Restored adding of default scope after loading a file * * Revision 1.15  2003/02/24 13:03:16  dicuccio * Renamed classes in plugin spec: *     CArgSeg --> CPluginArgSet *     CArgument --> CPluginArg *     CPluginArgs --> CPluginCommand *     CPluginCommands --> CPluginCommandSet * * Revision 1.14  2003/02/20 19:49:56  dicuccio * Created new plugin architecture, based on ASN.1 spec.  Moved GBENCH frameowrk * over to use new plugin architecture. * * Revision 1.13  2003/02/06 18:48:36  dicuccio * Made 'catch (...)' conditional for non-debug builds * * Revision 1.12  2003/02/05 19:55:23  dicuccio * Major reworking of handling of files.  Implemented file save. * * Revision 1.11  2003/01/13 13:10:07  dicuccio * Namespace clean-up.  Retired namespace gui -> converted all to namespace ncbi. * Moved all FLUID-generated code into namespace ncbi. * * Revision 1.10  2003/01/10 17:34:56  dicuccio * Converted some _TRACE() -> LOG_POST statements (judicious tracking of what a * user is trying to load) * * Revision 1.9  2003/01/03 17:25:13  dicuccio * Changed most LOG_POST() -> _TRACE(). * * Revision 1.8  2002/12/30 17:48:28  dicuccio * Added mechanism for data loader plugins to announce supported modes of * operation (load, import, save currently) * * Revision 1.7  2002/12/23 13:55:37  dicuccio * Set the default scope *after* a file has been retrieved. * * Revision 1.6  2002/12/12 15:22:20  dicuccio * Must always save the scope used to create a CBioseq_Handle.  Removed some * extraneous _TRACE() statements. * * Revision 1.5  2002/12/11 18:55:56  dicuccio * Added some additional log tracing during file open * * Revision 1.4  2002/12/09 20:35:59  dicuccio * Large revision to file loading code - added ability to read more object types, * added ability to import annotations into current document. * * Revision 1.3  2002/12/09 13:34:22  dicuccio * Fixed file loading (temporarily) * * Revision 1.2  2002/11/25 22:11:54  dicuccio * Fixed minor compilation errors * * Revision 1.1  2002/11/25 20:51:01  dicuccio * Initial revision. * * =========================================================================== */

⌨️ 快捷键说明

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