pluginarg.cpp

来自「ncbi源码」· C++ 代码 · 共 644 行 · 第 1/2 页

CPP
644
字号
/* * =========================================================================== * PRODUCTION $Log: PluginArg.cpp,v $ * PRODUCTION Revision 1000.2  2004/06/01 20:53:33  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.26 * PRODUCTION * =========================================================================== *//* $Id: PluginArg.cpp,v 1000.2 2004/06/01 20:53:33 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:  ....... * * File Description: *   ....... * * Remark: *   This code was originally generated by application DATATOOL *   using specifications from the data definition file *   'plugin.asn'. */// standard includes#include <ncbi_pch.hpp>#include <gui/core/plugin_exception.hpp>// generated includes#include <gui/plugin/PluginArg.hpp>#include <gui/plugin/PluginObject.hpp>#include <gui/plugin/PluginValue.hpp>#include <gui/plugin/PluginValueConstraint.hpp>#include <gui/plugin/PluginValueRangeConstraint.hpp>#include <objects/seq/Bioseq.hpp>#include <objects/seqalign/Seq_align.hpp>#include <objects/seq/Seq_annot.hpp>#include <objects/seqfeat/Seq_feat.hpp>#include <objects/seqloc/Seq_id.hpp>#include <objects/seqloc/Seq_loc.hpp>#include <objects/seqres/Seq_graph.hpp>#include <objects/seqset/Bioseq_set.hpp>#include <objects/seqset/Seq_entry.hpp>#include <serial/iterator.hpp>// generated classesBEGIN_NCBI_SCOPEBEGIN_objects_SCOPE // namespace ncbi::objects::// destructorCPluginArg::~CPluginArg(void){}// access the type for this argumentCPluginArg::EType CPluginArg::GetType(void) const{    CPluginValue::E_Choice choice = CPluginValue::e_not_set;    if (GetData().IsSingle()) {        choice = GetData().GetSingle().Which();    } else if (GetData().IsArray()  &&               GetData().GetArray().size() != 0) {        choice = GetData().GetArray().front()->Which();    }    switch (choice) {    case CPluginValue::e_Integer:        return eInteger;    case CPluginValue::e_Double:        return eDouble;    case CPluginValue::e_Boolean:        return eBoolean;    case CPluginValue::e_String:        return eString;    case CPluginValue::e_Document:        return eDocument;    case CPluginValue::e_Object:        return eObject;    case CPluginValue::e_File:        return eFile;    default:        return eNotSet;    }}// accessors for specific sub-componentsconst IDocument* CPluginArg::GetDocument(void) const{    if (GetData().IsSingle()) {        return GetData().GetSingle().GetDocument();    } else {        return GetData().GetArray().front()->GetDocument();    }}const CObject* CPluginArg::GetObject(void) const{    if (GetData().IsSingle()) {        return GetData().GetSingle().GetObject();    } else {        return GetData().GetArray().front()->GetObject();    }}const string& CPluginArg::GetObjectSubtype(void) const{    if (GetData().IsSingle()) {        return GetData().GetSingle().GetObjectSubtype();    } else {        return GetData().GetArray().front()->GetObjectSubtype();    }}bool CPluginArg::IsEmpty(void) const{    CTypeConstIterator<CPluginValue> iter(*this);    for ( ;  iter;  ++iter) {        if ( !iter->IsEmpty() ) {            return false;        }    }    return true;}void CPluginArg::ClearObjects(){    switch (GetType()) {    default:        break;    case eDocument:        if (GetData().IsSingle()) {            ResetData();            SetDocument();        } else {            ResetData();            SetDocument();            SetList();        }        break;    case eObject:        {{            string subtype = GetObjectSubtype();            if (GetData().IsSingle()) {                ResetData();                SetObject(subtype);            } else {                ResetData();                SetObject(subtype);                SetList();            }        }}        break;    }}//// integer handlers//void CPluginArg::SetInteger(void){    SetData().Reset();    SetData().SetSingle().SetInteger();}void CPluginArg::SetInteger(const string& arg){    SetData().Reset();    SetData().SetSingle().SetInteger(arg);}void CPluginArg::SetInteger(int arg){    SetData().Reset();    SetData().SetSingle().SetInteger(arg);}void CPluginArg::SetInteger(const list<int>& int_list){    SetData().Reset();    ITERATE (list<int>, iter, int_list) {        CRef<CPluginValue> value(new CPluginValue());        value->SetInteger(*iter);        SetData().SetArray().push_back(value);    }}int CPluginArg::AsInteger(void) const{    if ( !GetData().IsSingle() ) {        NCBI_THROW(CPluginException, eInvalidArg,                   "Attempt to cast array argument to single object");    }    return GetData().GetSingle().AsInteger();}//// double handlers//void CPluginArg::SetDouble(void){    SetData().Reset();    SetData().SetSingle().SetDouble();}void CPluginArg::SetDouble(const string& arg){    SetData().Reset();    SetData().SetSingle().SetDouble(arg);}void CPluginArg::SetDouble(double arg){    SetData().Reset();    SetData().SetSingle().SetDouble(arg);}void CPluginArg::SetDouble(const list<double>& double_list){    SetData().Reset();    ITERATE (list<double>, iter, double_list) {        CRef<CPluginValue> value(new CPluginValue());        value->SetDouble(*iter);        SetData().SetArray().push_back(value);    }}double CPluginArg::AsDouble(void) const{    if ( !GetData().IsSingle() ) {        NCBI_THROW(CPluginException, eInvalidArg,                   "Attempt to cast array argument to single object");    }    return GetData().GetSingle().AsDouble();}//// boolean handlers//void CPluginArg::SetBoolean(void){    SetData().Reset();    SetData().SetSingle().SetBoolean();}void CPluginArg::SetBoolean(bool arg){    SetData().Reset();    SetData().SetSingle().SetBoolean(arg);}void CPluginArg::SetBoolean(const list<bool>& bool_list){    SetData().Reset();    ITERATE (list<bool>, iter, bool_list) {        CRef<CPluginValue> value(new CPluginValue());        value->SetBoolean(*iter);        SetData().SetArray().push_back(value);    }}bool CPluginArg::AsBoolean(void) const{    if ( !GetData().IsSingle() ) {        NCBI_THROW(CPluginException, eInvalidArg,                   "Attempt to cast array argument to single object");    }    return GetData().GetSingle().AsBoolean();

⌨️ 快捷键说明

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