plugin_handle.cpp

来自「ncbi源码」· C++ 代码 · 共 464 行

CPP
464
字号
/* * =========================================================================== * PRODUCTION $Log: plugin_handle.cpp,v $ * PRODUCTION Revision 1000.5  2004/06/01 20:44:23  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.22 * PRODUCTION * =========================================================================== *//*  $Id: plugin_handle.cpp,v 1000.5 2004/06/01 20:44:23 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 <gui/core/plugin_exception.hpp>#include <gui/core/plugin_factory.hpp>#include <gui/core/plugin_handle.hpp>#include <gui/core/plugin_registry.hpp>#include <gui/core/idocument.hpp>#include <gui/plugin/PluginArgSet.hpp>#include <gui/plugin/PluginInfo.hpp>#include <gui/plugin/PluginLibInfo.hpp>#include <gui/plugin/PluginMessage.hpp>#include "plugin_handle_impl.hpp"BEGIN_NCBI_SCOPEUSING_SCOPE(objects);// comparison operators for plugin handlesbool operator< (const CPluginHandle& h1, const CPluginHandle& h2){    return (h1.LessThan(h2));}bool operator== (const CPluginHandle& h1, const CPluginHandle& h2){    return ( !(h1 < h2)  && !(h2 < h1) );}bool operator!= (const CPluginHandle& h1, const CPluginHandle& h2){    return !(h1 == h2);}CPluginHandle::CPluginHandle(){}CPluginHandle::CPluginHandle(CPluginHandle_Impl& impl)    : m_Impl(&impl){}CPluginHandle::CPluginHandle(const CPluginHandle& handle)    : m_Impl(const_cast<CPluginHandle_Impl*>(handle.m_Impl.GetPointer())){}CPluginHandle& CPluginHandle::operator=(const CPluginHandle& handle){    if (this != &handle) {        m_Impl.Reset            (const_cast<CPluginHandle_Impl*>(handle.m_Impl.GetPointer()));    }    return *this;}CPluginHandle::~CPluginHandle(){}//// all requests are forwarded to our implementation//const CPluginInfo& CPluginHandle::GetInfo(void) const{    if ( !m_Impl ) {        x_ThrowInvalidHandle();    }    return m_Impl->GetInfo();}//// all requests are forwarded to our implementation//const CPluginLibInfo& CPluginHandle::GetLibInfo(void) const{    if ( !m_Impl ) {        x_ThrowInvalidHandle();    }    return m_Impl->GetLibInfo();}CPluginCommandSet::E_Choice CPluginHandle::GetCommand(void) const{    if ( !m_Impl ) {        x_ThrowInvalidHandle();    }    return m_Impl->GetCommand();}bool CPluginHandle::IsLoaded(void) const{    if ( !m_Impl ) {        x_ThrowInvalidHandle();    }    return m_Impl->IsLoaded();}bool CPluginHandle::IsEnabled(void) const{    if ( !m_Impl ) {        x_ThrowInvalidHandle();    }    return m_Impl->IsEnabled();}const string& CPluginHandle::GetClassName(void) const{    if ( !m_Impl ) {        x_ThrowInvalidHandle();    }    return m_Impl->GetClassName();}const string CPluginHandle::GetHelpFile(void) const{    if ( !m_Impl ) {        x_ThrowInvalidHandle();    }    return m_Impl->GetHelpFile();}const string& CPluginHandle::GetLibrary(void) const{    if ( !m_Impl ) {        x_ThrowInvalidHandle();    }    return m_Impl->GetLibrary();}const string& CPluginHandle::GetMenuItem(void) const{    if ( !m_Impl ) {        x_ThrowInvalidHandle();    }    return m_Impl->GetMenuItem();}const string& CPluginHandle::GetToolTip(void) const{    if ( !m_Impl ) {        x_ThrowInvalidHandle();    }    return m_Impl->GetToolTip();}int CPluginHandle::GetVerMajor(void) const{    if ( !m_Impl ) {        x_ThrowInvalidHandle();    }    return m_Impl->GetVerMajor();}int CPluginHandle::GetVerMinor(void) const{    if ( !m_Impl ) {        x_ThrowInvalidHandle();    }    return m_Impl->GetVerMinor();}int CPluginHandle::GetVerRevision(void) const{    if ( !m_Impl ) {        x_ThrowInvalidHandle();    }    return m_Impl->GetVerRevision();}const string& CPluginHandle::GetVerBuildDate(void) const{    if ( !m_Impl ) {        x_ThrowInvalidHandle();    }    return m_Impl->GetVerBuildDate();}//// determine if a given command subtype is supported//bool CPluginHandle::HasCommandSubtype(EAlgoCommand cmd) const{    if ( !m_Impl ) {        x_ThrowInvalidHandle();    }    return m_Impl->HasCommandSubtype(cmd);}bool CPluginHandle::HasCommandSubtype(EDataCommand cmd) const{    if ( !m_Impl ) {        x_ThrowInvalidHandle();    }    return m_Impl->HasCommandSubtype(cmd);}bool CPluginHandle::HasCommandSubtype(EViewCommand cmd) const{    if ( !m_Impl ) {        x_ThrowInvalidHandle();    }    return m_Impl->HasCommandSubtype(cmd);}// return a properly formatted CPluginMessage object to invoke this// pluginCRef<CPluginMessage> CPluginHandle::CreateMessage(EAlgoCommand cmd){    if ( !m_Impl ) {        x_ThrowInvalidHandle();    }    return m_Impl->CreateMessage(cmd);}CRef<CPluginMessage> CPluginHandle::CreateMessage(EDataCommand cmd){    if ( !m_Impl ) {        x_ThrowInvalidHandle();    }    return m_Impl->CreateMessage(cmd);}CRef<CPluginMessage> CPluginHandle::CreateMessage(EViewCommand cmd){    if ( !m_Impl ) {        x_ThrowInvalidHandle();    }    return m_Impl->CreateMessage(cmd);}//// fill in the default set of arguments for a given command//bool CPluginHandle::FillDefaults(EAlgoCommand cmd, CPluginCommand& args) const{    if ( !m_Impl ) {        x_ThrowInvalidHandle();    }    return m_Impl->FillDefaults(cmd, args);}bool CPluginHandle::FillDefaults(EDataCommand cmd, CPluginCommand& args) const{    if ( !m_Impl ) {        x_ThrowInvalidHandle();    }    return m_Impl->FillDefaults(cmd, args);}bool CPluginHandle::FillDefaults(EViewCommand cmd, CPluginCommand& args) const{    if ( !m_Impl ) {        x_ThrowInvalidHandle();    }    return m_Impl->FillDefaults(cmd, args);}void CPluginHandle::Execute(CPluginMessage& msg){    if ( !m_Impl ) {        x_ThrowInvalidHandle();    }    m_Impl->Execute(msg);}void CPluginHandle::FinalizeArgs(CPluginMessage& msg){    if ( !m_Impl ) {        x_ThrowInvalidHandle();    }    m_Impl->FinalizeArgs(msg);}bool CPluginHandle::LessThan(const CPluginHandle& handle) const{    if (m_Impl.GetPointer()  &&  handle.m_Impl.GetPointer()) {        return (*m_Impl < *handle.m_Impl);    }    if ( !m_Impl ) {        return false;    }    return true;}void CPluginHandle::x_ThrowInvalidHandle() const{    NCBI_THROW(CPluginException, eInvalidHandle,               "Attempt to access invalid plugin handle");}END_NCBI_SCOPE/* * =========================================================================== * $Log: plugin_handle.cpp,v $ * Revision 1000.5  2004/06/01 20:44:23  gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.22 * * Revision 1.22  2004/05/25 17:08:50  dicuccio * Added CreateMessage() API to generate a new plugin message for a given plugin * call * * Revision 1.21  2004/05/21 22:27:40  gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.20  2004/02/12 23:03:02  mjohnson * Added documentation lookup. * * Revision 1.19  2004/01/15 22:50:17  jcherry * Added FinalizeArgs() for plugins * * Revision 1.18  2003/12/04 18:10:11  dicuccio * Refactored expcetion throwing to make it easier to track errors * * Revision 1.17  2003/11/26 17:06:32  dicuccio * Modified to use standard exception throwing function * * Revision 1.16  2003/11/06 20:06:29  dicuccio * Moved USING_SCOPE(objects) to implementation files * * Revision 1.15  2003/11/04 17:18:41  dicuccio * Changed calling API for plugins - take CPluginMessage directly instead of * paired command/reply * * Revision 1.14  2003/10/23 16:16:12  dicuccio * Exposed CPluginLibInfo object * * Revision 1.13  2003/09/04 14:01:51  dicuccio * Introduce IDocument and IView as abstract base classes for CDocument and CView * * Revision 1.12  2003/08/05 17:07:15  dicuccio * Changed calling semantics for the message queue - pass by reference, not * CConstRef<> * * Revision 1.11  2003/07/14 11:00:54  shomrat * Plugin messageing system related changes * * Revision 1.10  2003/06/27 14:37:24  shomrat * Added comparison operators == and != * * Revision 1.9  2003/06/25 19:54:14  dicuccio * Fixed compilation error for Windows - ambiguous op&& * * Revision 1.8  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.7  2003/06/20 14:47:41  dicuccio * Revised handling of plugin registration (moved GetInfo() out of plugin * factory and into each handler as a static function) * * Revision 1.6  2003/05/19 13:35:59  dicuccio * Moved gui/core/plugin/ -> gui/plugin/.  Merged gui/core/algo, gui/core/doc/, * and gui/core/view/ into one library (gui/core/) * * Revision 1.5  2003/03/10 22:58:51  kuznets * iterate -> ITERATE * * Revision 1.4  2003/02/28 15:06:39  dicuccio * Added enabled flag.  Made help file an optional component * * Revision 1.3  2003/02/26 14:20:13  dicuccio * Removed some unnecessary _TRACE() statements * * Revision 1.2  2003/02/24 13:03:15  dicuccio * Renamed classes in plugin spec: *     CArgSeg --> CPluginArgSet *     CArgument --> CPluginArg *     CPluginArgs --> CPluginCommand *     CPluginCommands --> CPluginCommandSet * * Revision 1.1  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. * * =========================================================================== */

⌨️ 快捷键说明

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