⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 context_factory.hpp

📁 ncbi源码
💻 HPP
字号:
/* * =========================================================================== * PRODUCTION $Log: context_factory.hpp,v $ * PRODUCTION Revision 1000.0  2003/10/31 20:19:45  gouriano * PRODUCTION PRODUCTION: IMPORTED [ORIGINAL] Dev-tree R1.7 * PRODUCTION * =========================================================================== */#ifndef GUI_CORE___CONTEXT_FACTORY__HPP#define GUI_CORE___CONTEXT_FACTORY__HPP/*  $Id: context_factory.hpp,v 1000.0 2003/10/31 20:19:45 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: *    CContextFactory -- provides standard mechanisms for creating and managing *                       named plugin contexts */#include <gui/core/plugin_exception.hpp>#include <gui/core/plugin_factory.hpp>BEGIN_NCBI_SCOPE//// class CContextFactory defines a standard templated interface for maintenance// of a context-aware plugin.//// This class stores a list of explicitly named and managed contexts.  The// framework will marshall contexts per a user's requests and requirements.// There is one specially named context - the "empty name" context (where name// is the empty string).  This is the default context used by a given plugin,// where a default context is supported (i.e., data loaders, algorithms -// default context doesn't necessarily match a view's notion of context).//template <class PluginType>class CContextFactory : public CPluginFactory<PluginType>{private:    // we maintain a map of name to context    typedef map<string, CRef<PluginType> > TContexts;    TContexts m_Contexts;protected:    // modes of operation for context creation    enum EContextCreateMode {        eImplicitCreate,        eNoImplicitCreate    };    // query to see if a given named context exists    bool x_HasContext(const string& name) const    {        typename TContexts::const_iterator iter = m_Contexts.find(name);        return (iter != m_Contexts.end());    }    // main context request interface    PluginType& x_GetContext(const string& name,                             const objects::CPluginArgSet& args,                             EContextCreateMode mode = eImplicitCreate)    {        typename TContexts::iterator iter = m_Contexts.find(name);        if (iter != m_Contexts.end()) {            return *(iter->second);        }        if (mode == eNoImplicitCreate) {            NCBI_THROW(CPluginException, eNotSupported,                       "Attempted to access non-existent context");        }        CRef<PluginType> context(new PluginType());        m_Contexts[name] = context;        return *context;    }    // overloaded context creation function    virtual void x_OnCreateContext(const string& name,                                   const objects::CPluginArgSet& args,                                   objects::CPluginReply& reply)    {        if (x_HasContext(name)) {            reply.SetStatus(objects::eMessageStatus_ignored);            return;        }        // we've requested a named context be created        x_GetContext(name, args);        reply.SetStatus(objects::eMessageStatus_success);    }    // overloaded context destruction function    virtual void x_OnDestroyContext(const string& name,                                    objects::CPluginReply& reply)    {        if ( !x_HasContext(name) ) {            reply.SetStatus(objects::eMessageStatus_ignored);            return;        }        m_Contexts.erase(m_Contexts.find(name));        reply.SetStatus(objects::eMessageStatus_success);    }};END_NCBI_SCOPE/* * =========================================================================== * $Log: context_factory.hpp,v $ * Revision 1000.0  2003/10/31 20:19:45  gouriano * PRODUCTION: IMPORTED [ORIGINAL] Dev-tree R1.7 * * Revision 1.7  2003/08/22 15:54:48  dicuccio * General clean-up:  Removed unneeded export specifiers from templates; removed * 'USING_SCOPE(objects)' * * Revision 1.6  2003/07/14 10:56:57  shomrat * Plugin messageing system related changes * * Revision 1.5  2003/06/25 16:59:41  dicuccio * Changed CPluginHandle into a pointer-to-implementation (the previous * implementation is now the pointer held).  Lots of #include file clean-ups. * * Revision 1.4  2003/06/20 14:44:36  dicuccio * Revamped handling of plugin registration.  All plugin factories now derive * from CPluginFactoryBase; CPluginFactory is a template.  There is a new * requirement for derived plugin handlers of all types (each must implement a * static function of the form 'static void GetInfo(CPluginInfo&)') * * Revision 1.3  2003/02/24 13:00:17  dicuccio * Renamed classes in plugin spec: *     CArgSeg --> CPluginArgSet *     CArgument --> CPluginArg *     CPluginArgs --> CPluginCommand *     CPluginCommands --> CPluginCommandSet * * Revision 1.2  2003/02/21 16:44:13  dicuccio * Added Win32 export specifiers for new plugin library.  Fixed compilation * issues for Win32. * * Revision 1.1  2003/02/20 19:44:06  dicuccio * Created new plugin architecture, mediated via an ASN.1 spec.  Moved GBENCH * framework over to use new plugin architecture. * * =========================================================================== */#endif  // GUI_CORE___CONTEXT_FACTORY__HPP

⌨️ 快捷键说明

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