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

📄 obj_convert.hpp

📁 ncbi源码
💻 HPP
字号:
/* * =========================================================================== * PRODUCTION $Log: obj_convert.hpp,v $ * PRODUCTION Revision 1000.1  2004/04/12 18:12:36  gouriano * PRODUCTION PRODUCTION: UPGRADED [CATCHUP_003] Dev-tree R1.9 * PRODUCTION * =========================================================================== */#ifndef GUI_CORE___OBJ_CONVERT__HPP#define GUI_CORE___OBJ_CONVERT__HPP/*  $Id: obj_convert.hpp,v 1000.1 2004/04/12 18:12:36 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 <corelib/ncbiobj.hpp>#include <objmgr/scope.hpp>#include <gui/core/idocument.hpp>BEGIN_NCBI_SCOPE//// base interface for a conversion object//class IObjConverter : public CObject{public:    typedef list< CConstRef<CObject> > TObjList;    // generic handler interface    // this, in general, feeds into the interfaces below    virtual void ToObject   (objects::CScope& scope, const CObject& obj,                             const string& type_name, TObjList& objs) const = 0;    // named conversion routines    virtual void ToSeqSubmit(objects::CScope& scope, const CObject& obj,                             TObjList& objs) const = 0;    virtual void ToSeqEntry (objects::CScope& scope, const CObject& obj,                             TObjList& objs) const = 0;    virtual void ToBioseqSet(objects::CScope& scope, const CObject& obj,                             TObjList& objs) const = 0;    virtual void ToBioseq   (objects::CScope& scope, const CObject& obj,                             TObjList& objs) const = 0;    virtual void ToSeqId    (objects::CScope& scope, const CObject& obj,                             TObjList& objs) const = 0;    virtual void ToSeqLoc   (objects::CScope& scope, const CObject& obj,                             TObjList& objs) const = 0;    virtual void ToSeqFeat  (objects::CScope& scope, const CObject& obj,                             TObjList& objs) const = 0;    virtual void ToSeqAlign (objects::CScope& scope, const CObject& obj,                             TObjList& objs) const = 0;    virtual void ToSeqAnnot (objects::CScope& scope, const CObject& obj,                             TObjList& objs) const = 0;};//// common subclass for object conversion// this class defines some basic conversions that are generically handled,// as well as provides the default switching function in ToObject()//class NCBI_GUICORE_EXPORT CObjConverter : public IObjConverter{public:    // generic object conversion switch function    void ToObject(objects::CScope& scope, const CObject& obj,                      const string& type_name, TObjList& objs) const;    // generic seq-entry -> seq-submit wrapper    void ToSeqSubmit(objects::CScope& scope, const CObject& obj,                     TObjList& objs) const;    // generic seq-id -> seq-entry function    void ToSeqEntry(objects::CScope& scope, const CObject& obj,                    TObjList& objs) const;    // generic seq-id -> bioseq function    void ToBioseq(objects::CScope& scope, const CObject& obj,                  TObjList& objs) const;    // generic seq-submit -> bioseq-set function    void ToBioseqSet(objects::CScope& scope, const CObject& obj,                     TObjList& objs) const;    // generic seq-id -> seq-loc wrapper    void ToSeqLoc(objects::CScope& scope, const CObject& obj,                  TObjList& objs) const;    // generic seq-loc -> seq-annot wrapper    void ToSeqAnnot(objects::CScope& scope, const CObject& obj,                    TObjList& objs) const;    // generic seq-loc -> seq-annot wrapper    void ToSeqFeat(objects::CScope& scope, const CObject& obj,                   TObjList& objs) const;    // generic seq-loc -> seq-annot wrapper    void ToSeqAlign(objects::CScope& scope, const CObject& obj,                    TObjList& objs) const;};//// single conversion interface//class NCBI_GUICORE_EXPORT CObjectConverter{public:    typedef IObjConverter::TObjList TObjList;    //    // single callable interface    //    static void Convert(objects::CScope& scope, const CObject& obj,                        const CTypeInfo* info, TObjList& objs);    static void Convert(objects::CScope& scope, const CObject& obj,                        const string& type_name, TObjList& objs);    // register a conversion function object    static void Register(const CTypeInfo* from_type, IObjConverter& cvt);};//// CConvertCache holds a cache of converted objects// This is useful in situation in which a given object may be requested// as a given type multiple times in a row.//class NCBI_GUICORE_EXPORT CConvertCache : public CObject{public:     // re-typedef from CObjectConvert     typedef CObjectConverter::TObjList TObjList;     // convert an object using a CTypeInfo object     virtual const TObjList& Convert(objects::CScope& scope, const CObject& obj,                                     const CTypeInfo* info);     // convert an object using a string-based type name     virtual const TObjList& Convert(objects::CScope& scope, const CObject& obj,                                     const string& type_name);    // SCacheKey holds the information relevant for a single converted    // object    struct SCacheKey    {        SCacheKey(objects::CScope& scope, const CObject& obj,                   const string& type)        : m_Scope(&scope),          m_Obj(&obj),          m_Type(type)        {}        SCacheKey (const SCacheKey& key)        : m_Scope(key.m_Scope),          m_Obj(key.m_Obj),          m_Type(key.m_Type)        {}        CConstRef<objects::CScope>  m_Scope;        CConstRef<CObject> m_Obj;        string             m_Type;    };    // functor for sorting SCacheKey objects    struct SCacheKeySort    {        bool operator() (const SCacheKey& key1, const SCacheKey& key2) const;    };private:    // the cache itself    typedef map<SCacheKey, TObjList, SCacheKeySort> TCache;    TCache m_ObjCache;    // empty list of objects to be returned if no hits found    TObjList m_EmptyObjList;};END_NCBI_SCOPE/* * =========================================================================== * $Log: obj_convert.hpp,v $ * Revision 1000.1  2004/04/12 18:12:36  gouriano * PRODUCTION: UPGRADED [CATCHUP_003] Dev-tree R1.9 * * Revision 1.9  2004/01/21 12:38:17  dicuccio * redesigned CObjectCOnverter API to eliminate temporary object creation * * Revision 1.8  2004/01/20 18:09:07  dicuccio * Export CObjectConverter * * Revision 1.7  2004/01/15 18:02:34  dicuccio * API change for IObjConverter - pass-by-reference instead of return-by-value * * Revision 1.6  2003/10/10 18:07:07  friedman * SCacheKey and SCacheKeySort needs to be public for solaris compile * * Revision 1.5  2003/10/10 17:11:48  dicuccio * Code clean-up.  Added export specifiers, removed #ifdef'd code.  Privatized all * internals of CConvertCache * * Revision 1.4  2003/10/10 16:00:45  friedman * Added CConvertCache * * Revision 1.3  2003/09/30 15:19:22  dicuccio * Added default conversions for seq-entry, bioseq * * Revision 1.2  2003/09/25 12:26:34  friedman * Added: *         ToSeqAlign * * Revision 1.1  2003/09/16 14:03:05  dicuccio * Initial revision * * =========================================================================== */#endif  // GUI_CORE___OBJ_CONVERT__HPP

⌨️ 快捷键说明

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