validator_plg.cpp
来自「ncbi源码」· C++ 代码 · 共 356 行
CPP
356 行
/* * =========================================================================== * PRODUCTION $Log: validator_plg.cpp,v $ * PRODUCTION Revision 1000.4 2004/06/01 20:57:16 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.22 * PRODUCTION * =========================================================================== *//* $Id: validator_plg.cpp,v 1000.4 2004/06/01 20:57:16 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: Mati Shomrat * * File Description: * A plugin wrap for the validator * */#include <ncbi_pch.hpp>#include <corelib/ncbistd.hpp>#include <gui/core/doc_manager.hpp>#include <gui/core/idocument.hpp>#include <gui/core/version.hpp>#include <gui/core/plugin_utils.hpp>#include <gui/plugin/PluginArg.hpp>#include <gui/plugin/PluginRequest.hpp>#include <gui/plugin/PluginArgSet.hpp>#include <gui/plugin/PluginCommandSet.hpp>#include <gui/plugin/PluginInfo.hpp>#include <gui/plugin/PluginReply.hpp>#include <gui/plugin/PluginValue.hpp>#include <gui/utils/message_box.hpp>#include <objects/seq/Seq_annot.hpp>#include <objects/seqset/Seq_entry.hpp>#include <objects/submit/Seq_submit.hpp>#include <objmgr/object_manager.hpp>#include <objmgr/scope.hpp>#include <objtools/validator/validator.hpp>#include <FL/Fl.H>#include "validator_plg.hpp"#include "val_progress.hpp"BEGIN_NCBI_SCOPEUSING_SCOPE(ncbi::objects);USING_SCOPE(ncbi::validator);USING_SCOPE(ncbi::validator);void CValidatorPlugin::GetInfo(CPluginInfo& info){ info.Reset(); // version info macro info.SetInfo(CPluginVersion::eMajor, CPluginVersion::eMinor, 0, string(__DATE__) + " " + string(__TIME__), "CValidatorPlugin", "Validate", "Validate the content of the current selections", ""); // command info CPluginCommand& cmd = info.SetCommands().AddAlgoCommand(eAlgoCommand_run); // IMPORTANT: The validator take either a Seq-entry, Seq_submit // or Seq_annot as the object to validate. Due to lack of // support from CPluginArg::EType we use eObject as our // type. cmd.AddArgument("object", "Object to validate", CSeq_entry::GetTypeInfo()); //cmd. AddDefaultArgument("options", "Validator options", // CPluginArg::eInteger, 0);}void CValidatorPlugin::RunCommand(CPluginMessage& msg){ const CPluginCommand& args = msg.GetRequest().GetCommand(); CPluginReply& reply = msg.SetReply(); _TRACE("CValidatorPlugin::Run()"); try { const CPluginArg& arg = args["object"]; // our argument should have only one value const CSeq_entry& se = *dynamic_cast<const CSeq_entry*>(arg.GetObject()); const IDocument& doc = *arg.GetDocument(); CScope* scope = &doc.GetScope(); CObjectManager& objmgr = CDocManager::GetObjectManager(); Uint4 options = GetOptions(); // Create the validator CRef<CValidator> validator(new CValidator(objmgr)); // Register progress callback auto_ptr<CValProgress> dlg_prg(new CValProgress); dlg_prg->show(); validator->SetProgressCallback(x_ProgressCallback, dlg_prg.get()); // Perform validation CConstRef<CValidError> errors; errors.Reset (validator->Validate(se, scope, options).Release()); /** case CPluginArg::eSeq_annot: {{ const CSeq_annot& sa = args["object"].AsSeq_annot(); obj = &sa; errors.Reset(validator->Validate(sa, scope, options).release()); }} break; default: {{ const CSeq_submit& ss = dynamic_cast<const CSeq_submit&>(args["object"].AsObject()); obj = &ss; errors.Reset(validator->Validate(ss, scope, options).release()); }} break; } **/ x_PostViewRequest(doc, errors, se, *scope, options); reply.SetStatus(eMessageStatus_success); } catch ( const exception& ) { reply.SetStatus(eMessageStatus_failed); return; } }CValidatorPlugin::CValidatorPlugin(void){}CValidatorPlugin::~CValidatorPlugin(void){}// =============================== Private ===================================Uint4 CValidatorPlugin::GetOptions(void) { return 0;}void CValidatorPlugin::x_PostViewRequest(const IDocument& doc, CConstRef<CValidError> errors, const CObject& obj, const CScope& scope, Uint4 options) const{ if ( !errors ) { return; } CRef<CPluginMessage> msg(new CPluginMessage); msg->SetDestination("CViewValidator"); CPluginCommand& view_request = msg->SetRequest().SetView(); view_request.SetCommand(eViewCommand_new_view); // document CRef<CPluginArg> doc_pa(new CPluginArg); doc_pa->SetName("document"); doc_pa->SetDocument(doc); // validerror (error repository) CRef<CPluginArg> err_pa(new CPluginArg); err_pa->SetName("errors"); err_pa->SetObject(doc, *errors); // The object which was validated CRef<CPluginArg> obj_pa(new CPluginArg); obj_pa->SetName("object"); obj_pa->SetObject(doc, obj); // scope CRef<CPluginArg> scope_pa(new CPluginArg); scope_pa->SetName("scope"); scope_pa->SetObject(doc, scope); // options CRef<CPluginArg> options_pa(new CPluginArg); options_pa->SetName("options"); options_pa->SetInteger(options); CPluginArgSet::Tdata& view_args = view_request.SetArgs().Set(); view_args.push_back(doc_pa); view_args.push_back(err_pa); view_args.push_back(obj_pa); view_args.push_back(scope_pa); view_args.push_back(options_pa); CPluginUtils::CallPlugin(*msg);}// callback functionbool CValidatorPlugin::x_ProgressCallback(CValidator::CProgressInfo* pInfo){ Fl::check(); if ( pInfo == 0 ) { return false; } CValProgress* pDlg = reinterpret_cast<CValProgress*>(pInfo->GetUserData()); if( !pDlg ) { return false; } if ( !pDlg->Cancel() ) { pDlg->Update(pInfo); } else { return true; } return false;}END_NCBI_SCOPE/* * =========================================================================== * * $Log: validator_plg.cpp,v $ * Revision 1000.4 2004/06/01 20:57:16 gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.22 * * Revision 1.22 2004/05/21 22:27:48 gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.21 2004/01/27 18:45:29 dicuccio * Added missing header files * * Revision 1.20 2003/12/22 19:27:49 dicuccio * Use CPluginUtils::CallPlugin() instead of posting directly to the message queue * * Revision 1.19 2003/11/24 15:45:32 dicuccio * Renamed CVersion to CPluginVersion * * Revision 1.18 2003/11/04 17:49:24 dicuccio * Changed calling parameters for plugins - pass CPluginMessage instead of paired * CPluginCommand/CPluginReply * * Revision 1.17 2003/10/07 13:47:05 dicuccio * Renamed CPluginURL* to CPluginValue* * * Revision 1.16 2003/09/04 14:05:25 dicuccio * Use IDocument instead of CDocument * * Revision 1.15 2003/08/05 17:07:17 dicuccio * Changed calling semantics for the message queue - pass by reference, not * CConstRef<> * * Revision 1.14 2003/07/31 17:02:27 dicuccio * Changed plugin message queue class name to be application agnostic * * Revision 1.13 2003/07/22 15:32:16 dicuccio * Changed to make use of new API in plugin_utils.hpp - GetArgValue() * * Revision 1.12 2003/07/14 11:16:11 shomrat * Plugin messageing system related changes * * Revision 1.11 2003/06/26 15:33:40 dicuccio * Moved GetURLValue() from PluginURL.hpp to plugin_utils.hpp. Fixed compilation * errors relating to missing #includes * * Revision 1.10 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.9 2003/06/20 14:52:36 dicuccio * Revised plugin registration - moved GetInfo() into the plugin handler * * Revision 1.8 2003/06/02 16:06:22 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.7 2003/05/30 13:01:38 dicuccio * Use MessageBox() instead of fl_alert() / fl_message() * * Revision 1.6 2003/05/19 13:39:44 dicuccio * Moved gui/core/plugin/ --> gui/plugin/. Merged core libraries into libgui_core * * Revision 1.5 2003/05/15 12:19:49 dicuccio * release() -> Release() to match CConstRef<> * * Revision 1.4 2003/05/12 16:09:52 dicuccio * Updated to use new plugin action args * * Revision 1.3 2003/04/25 14:15:58 dicuccio * Fixed compilation errors resulting from changes to plugin API * * Revision 1.2 2003/04/22 16:17:38 shomrat * Fl -> FL * * Revision 1.1 2003/04/18 18:55:46 shomrat * Initial revision * * * =========================================================================== */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?