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

📄 search_opts.hpp

📁 ncbi源码
💻 HPP
📖 第 1 页 / 共 2 页
字号:
/* * =========================================================================== * PRODUCTION $Log: search_opts.hpp,v $ * PRODUCTION Revision 1000.1  2004/04/16 17:12:31  gouriano * PRODUCTION PRODUCTION: UPGRADED [CATCHUP_003] Dev-tree R1.5 * PRODUCTION * =========================================================================== */#ifndef ALGO_BLAST_API_DEMO___SEARCH_OPTS__HPP#define ALGO_BLAST_API_DEMO___SEARCH_OPTS__HPP/*  $Id: search_opts.hpp,v 1000.1 2004/04/16 17:12:31 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. * * =========================================================================== * * Author:  Kevin Bealer * *//// @file search_opts.hpp/// Encapsulates optional netblast search parameters.////// The Netblast protocol provides a long list of optional search/// parameters.  Some of these are already supported here - more will/// be supported in the future.  This code takes responsibility for/// this aspect of the remote_blast program.  Adding a new search/// parameter should require modifications to ONLY this file.  This/// works toward the OOP goal of designing interfaces and/// encapsulation in such a way as to isolate parts of the program/// that will change.#include "optional.hpp"#include <corelib/ncbiargs.hpp>#include <algo/blast/api/remote_blast.hpp>#include <objects/blast/Blast4_cutoff.hpp>BEGIN_NCBI_SCOPEUSING_SCOPE(ncbi::blast);class CStringLit{public:    explicit CStringLit(const char * x)        : m_ptr(x)    {    }        operator const char *(void)    {        return m_ptr;    }        operator string(void)    {        return string(m_ptr);    }private:    const char * m_ptr;};class CUserOpt : public CStringLit{public:    explicit CUserOpt(const char * x)        : CStringLit(x)    {    }};class CNetName : public CStringLit{public:    explicit CNetName(const char * x)        : CStringLit(x)    {    }};class CArgKey : public CStringLit{public:    explicit CArgKey(const char * x)        : CStringLit(x)    {    }};class COptDesc : public CStringLit{public:    explicit COptDesc(const char * x)        : CStringLit(x)    {    }};/// This is base class for classes that operate on the option set.////// Functors that operate on the set of options in NetblastSearchOpts/// are derived from this class; it provides a set of handy methods/// for reading options (from the CArgs object, to the field) and/// adding options (to the CArgDescriptions, based on a field object/// and key name).  Note that the AddOpt() code does not actually modify the/// field -- it merely uses C++ overloading to select the correct/// CArgDescription parse type based on each field type.  Because of/// this mechanism, changing the type of a field (from OptInteger to/// OptDouble for example), makes all the necessary network protocol/// and CArgs interface adjustments./// @sa NetblastSearchOpts - see also.class COptionWalker{public:    /// Read a boolean field.    void ReadOpt(const CArgs & args,                 TOptBool    & field,                 const char  * key);        /// Read a double field.    void ReadOpt(const CArgs & args,                 TOptDouble  & field,                 const char  * key);        /// Read an integer field.    void ReadOpt(const CArgs & args,                 TOptInteger & field,                 const char  * key);        /// Read a string field.    void ReadOpt(const CArgs & args,                 TOptString  & field,                 const char  * key);            /// Build the CArgDescription for a boolean field.    void AddOpt(CArgDescriptions & ui,                TOptBool         & field,                const char       * name,                const char       * synop,                const char       * comment);        /// Build the CArgDescription for a double field.    void AddOpt(CArgDescriptions & ui,                TOptDouble       & field,                const char       * name,                const char       * synop,                const char       * comment);        /// Build the CArgDescription for an integer field.    void AddOpt(CArgDescriptions & ui,                TOptInteger      & field,                const char       * name,                const char       * synop,                const char       * comment);        /// Build the CArgDescription for a string field.    void AddOpt(CArgDescriptions & ui,                TOptString       & field,                const char       * name,                const char       * synop,                const char       * comment);    /// Require this boolean function    virtual bool NeedRemote(void) = 0;};/// This class stores search options for remote_blast.////// This class stores optional search parameters for remote_blast./// The heart of this class is the Apply() method, which takes an/// object as an input parameter and applies that object to each/// search option field.  There are three types of fields: Local,/// Remote(), and Same().  The Local fields represent blastcl4/// options.  The Remote() fields represent netblast (socket protocol)/// options.  The Same() fields are fields which are both Remote() and/// Local; the value is passed directly through as a netblast/// parameter.  Most fields fall into the Same() category.  The/// objects passed to Apply() are called with the appropriate one of/// the Local(), Remote(), or Same() methods for each field.  To add a/// new field, create a new TOpt* type object in the private section,/// and call Same(), Local() or Remote() with the properties of that/// field in the Apply() method./*Solution 1: Scrap all this, writing seperate code bases for N, P, TX,   etc.  Problem: this was time consuming to write, even in the   current, "good programmers try not to do something twice, insane   programmers try not to do something once" code configuration.   Solution 2: Create a traitsy solution.  The Set(...) methods will use   nucleotide, protein, and so on specialized types.  Each COptHandler   will be derived from whatever types are appropriate for its pieces.   Thus, there is a generic Set() for throwing, and a SetValue() for   setting.  The Set() is overridden to call SetValue for the right   cases.*/extern bool trace_blast_api;#define WRITE_API_IDENT(NAME)                                \    if (trace_blast_api) {                                   \        cerr << "BlastAPI call: Set" # NAME "(...)" << endl; \    }#define OPT_HANDLER_START(NAMESEG, EXPR)       \template <class BlOptTp>                       \class COptHandler_ ## NAMESEG {                \public:                                        \    template<class ValT, class OptsT>          \    void SetValue(OptsT & opts, ValT & V)      \    {                                          \        WRITE_API_IDENT(NAMESEG);              \        opts->Set ## NAMESEG (EXPR);           \    }                                          \                                               \    template<class ValT, class OptsT>          \    void Set(OptsT &, ValT &)             \    {                                          \        /*cerr << "In ["              */       \        /*     << __PRETTY_FUNCTION__ */       \        /*     << "]:\n";             */       \        throw runtime_error                    \            ("program / parm mismatch");       \    }#define OPT_HANDLER_SUPPORT(OPTIONTYPE) \    template<class ValT>                \    void Set(CRef<OPTIONTYPE> opts,     \             ValT & V)                  \    {                                   \        SetValue(opts, V);              \    }#define OPT_HANDLER_END() }// Helper and Shortcut Handler Sets#define OPT_HANDLER_SUPPORT_ALL(NAME)               \OPT_HANDLER_START(NAME, V)                          \OPT_HANDLER_SUPPORT(CBlastxOptionsHandle)           \OPT_HANDLER_SUPPORT(CTBlastnOptionsHandle)          \OPT_HANDLER_SUPPORT(CTBlastxOptionsHandle)          \OPT_HANDLER_SUPPORT(CBlastProteinOptionsHandle)     \OPT_HANDLER_SUPPORT(CBlastNucleotideOptionsHandle)  \OPT_HANDLER_END()#define OPT_HANDLER_EXPR_ALL(NAME, EXPR)            \OPT_HANDLER_START(NAME, EXPR)                       \OPT_HANDLER_SUPPORT(CBlastxOptionsHandle)           \OPT_HANDLER_SUPPORT(CTBlastnOptionsHandle)          \OPT_HANDLER_SUPPORT(CTBlastxOptionsHandle)          \OPT_HANDLER_SUPPORT(CBlastProteinOptionsHandle)     \OPT_HANDLER_SUPPORT(CBlastNucleotideOptionsHandle)  \OPT_HANDLER_END()#define OPT_HANDLER_SUPPORT_NUCL(NAME)              \OPT_HANDLER_START(NAME, V)                          \OPT_HANDLER_SUPPORT(CBlastNucleotideOptionsHandle)  \OPT_HANDLER_END()// Translated Query (blastx, tblastx)#define OPT_HANDLER_SUPPORT_TRQ(NAME)       \OPT_HANDLER_START(NAME, V)                  \OPT_HANDLER_SUPPORT(CBlastxOptionsHandle)   \OPT_HANDLER_SUPPORT(CTBlastxOptionsHandle)  \OPT_HANDLER_END()

⌨️ 快捷键说明

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