sage_reader.cpp
来自「ncbi源码」· C++ 代码 · 共 193 行
CPP
193 行
/* * =========================================================================== * PRODUCTION $Log: sage_reader.cpp,v $ * PRODUCTION Revision 1000.4 2004/06/01 20:58:42 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.8 * PRODUCTION * =========================================================================== *//* $Id: sage_reader.cpp,v 1000.4 2004/06/01 20:58:42 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: * */#include <ncbi_pch.hpp>#include <corelib/ncbifile.hpp>#include <gui/core/doc_exception.hpp>#include <gui/core/doc_manager.hpp>#include <gui/core/idocument.hpp>#include <gui/core/plugin_utils.hpp>#include <gui/utils/system_path.hpp>#include <gui/core/version.hpp>#include <gui/plugin/PluginCommandSet.hpp>#include <gui/plugin/PluginInfo.hpp>#include <gui/plugin/PluginValue.hpp>#include <gui/utils/message_box.hpp>#include <objmgr/object_manager.hpp>#include <objects/seqset/Seq_entry.hpp>#include <serial/iterator.hpp>#include <serial/objostrasn.hpp>#include <serial/serial.hpp>#include "sage_reader.hpp"#include <objtools/data_loaders/table/sage_dload.hpp>#include <sqlite/sqlite.hpp>BEGIN_NCBI_SCOPEUSING_SCOPE(objects);CSageReader::CSageReader(){}CSageReader::~CSageReader(){}void CSageReader::GetInfo(CPluginInfo& info){ info.Reset(); // version info macro info.SetInfo(CPluginVersion::eMajor, CPluginVersion::eMinor, 0, string(__DATE__) + " " + string(__TIME__), "CSageReader", "Import SAGE Data", "Import SAGE data from a table", ""); // command info CPluginCommandSet& cmds = info.SetCommands(); CPluginCommand& import_args = cmds.AddDataCommand(eDataCommand_import); import_args.AddArgument("document", "Document", CPluginArg::eDocument); import_args.AddArgument("fname", "File to load", CPluginArg::eFile);}void CSageReader::Import(CPluginMessage& msg){ const CPluginCommand& args = msg.GetRequest().GetCommand(); CPluginReply& reply = msg.SetReply(); IDocument* doc = const_cast<IDocument*> (&args["document"].AsDocument()); if ( !doc ) { reply.SetStatus(eMessageStatus_ignored); return; } const string& fname = args["fname"].AsString(); CSageDataLoader* loader = NULL; TLoaders::iterator iter = m_Loaders.find(fname); if (iter != m_Loaders.end()) { loader = iter->second; } string import_name; bool delete_file = true; if ( !CSQLite::IsValidDB(fname) ) { if (NcbiMessageBox("Do you want to import the file for future use?", eDialog_YesNo, eIcon_Question, "Import Permanently?") == eYes) { import_name = fname; import_name += ".db"; delete_file = false; } } else { import_name = fname; delete_file = false; } if (import_name.empty()) { import_name = CSystemPath::ResolvePath("<home>", "tmp"); CDir dir(import_name); if ( !dir.Exists() ) { dir.Create(); } import_name = CFile::GetTmpNameEx(import_name, "tdb_"); } if ( !loader ) { loader = new CSageDataLoader(fname, import_name, delete_file); CDocManager::GetObjectManager().RegisterDataLoader(*loader); m_Loaders[loader->GetName()] = loader; } // create our data loader CScope& scope = doc->GetScope(); scope.AddDataLoader(loader->GetName(), 80); doc->PostDocumentChanged(); reply.SetStatus(eMessageStatus_success);}END_NCBI_SCOPE/* * =========================================================================== * $Log: sage_reader.cpp,v $ * Revision 1000.4 2004/06/01 20:58:42 gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.8 * * Revision 1.8 2004/05/21 22:27:48 gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.7 2004/02/17 20:35:27 rsmith * moved core/settings.[ch]pp and core/system_path.[ch]pp to config and utils, respectively. * * Revision 1.6 2004/02/11 21:01:52 jcherry * Use file argument rather than manually launching file chooser * * Revision 1.5 2003/12/22 19:30:11 dicuccio * Updated to match change in IDocument - UpdateAllViews() goes away * * Revision 1.4 2003/11/24 15:45:41 dicuccio * Renamed CVersion to CPluginVersion * * Revision 1.3 2003/11/04 17:49:25 dicuccio * Changed calling parameters for plugins - pass CPluginMessage instead of paired * CPluginCommand/CPluginReply * * Revision 1.2 2003/10/10 17:19:33 dicuccio * Added Import() interface. Removed dead Save() interfaces * * Revision 1.1 2003/10/07 13:42:10 dicuccio * Added SAGE import plugin * * =========================================================================== */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?