feat_show.cpp
来自「ncbi源码」· C++ 代码 · 共 210 行
CPP
210 行
/* * =========================================================================== * PRODUCTION $Log: feat_show.cpp,v $ * PRODUCTION Revision 1000.1 2004/06/01 20:43:18 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.6 * PRODUCTION * =========================================================================== *//* $Id: feat_show.cpp,v 1000.1 2004/06/01 20:43:18 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: Robert Smith * *//// @file feat_show.cpp/// #include <ncbi_pch.hpp>#include <gui/config/feat_show.hpp>#include <gui/config/feat_config_list.hpp>BEGIN_NCBI_SCOPE/// This returns a string in response to any key if there is nothing/// for that key in the PluginConfigCache. Hence it works closely/// with LoadCurrentSettings below.namespace { const string kTrueStr("true"); const string kFalseStr("false");}/// everything is shown by default.string CFeatShowFactoryDefaults::Get(const string& key) const{ string key1, key2; NStr::SplitInTwo(key, "|", key1, key2); if (key == "show|Master") { return kTrueStr; } NCBI_THROW(CConfigException, eNoDefaultValue, "key: " + key); }// definitions for CFeatConfigShow/// use this cstr when declaring a CFeatConfigShow object.CFeatConfigShow::CFeatConfigShow(objects::CPluginConfigCache* config_cache, const string& typedesc) : CSettingsSet(config_cache, "FeatureShow", new CFeatShowFactoryDefaults(), typedesc){ LoadCurrentSettings(eLoad_Current);}/// use this cstr when initializing a CFeatConfigShow object as a parent object/// in an inherited class, since it will probably need a different type/// and factory defaults. But the FactoryDefaultSettings object pass in to here/// should probably inherit from CFeatConfigFactoryDefaults.CFeatConfigShow::CFeatConfigShow(objects::CPluginConfigCache* config_cache, const string& type, const AutoPtr<IFactoryDefaultSettings>& fds, const string& typedesc ) : CSettingsSet(config_cache, type, fds, typedesc){ // LoadCurrentSettings(eLoad_Current); // not needed since the child class will do this.}bool CFeatConfigShow::LoadCurrentSettings(ELoadValueSource src){ // iterate through all feature types. // if the Get throws, do not set anything for // that value, for the feature type. // Else set a real value and set Inherited to false. string featvaluestr; ClearShows(); const CFeatConfigList& featureList = *GetFeatConfigList(); ITERATE ( CFeatConfigList, fc_it, featureList ) { int myType = fc_it->GetType(); int mySubtype = fc_it->GetSubtype(); try { featvaluestr = Get("show" + GetKeyDelimiter() + fc_it->GetStoragekey(), src); SetShow( myType, mySubtype, NStr::StringToBool(featvaluestr)); SetShowInherited( myType, mySubtype, false); } catch (const CConfigException&) { } } return true;}bool CFeatConfigShow::SaveCurrentSettings(void){ // iterate through all feature types. // if features color/show/etc. value is not inherited // save it as a string. // If it is inherited, or no value is defined for that feature type, // we do not save it and make sure there is not an entry with that key. const CFeatConfigList& featureList = *GetFeatConfigList(); ITERATE(CFeatConfigList, fc_it, featureList) { int myType = fc_it->GetType(); int mySubtype = fc_it->GetSubtype(); if ( ! m_FeatShows.GetInherited(myType, mySubtype)) { Set("show" + GetKeyDelimiter() + fc_it->GetStoragekey(), NStr::BoolToString(GetShow(myType, mySubtype)) ); } else { Delete("show" + GetKeyDelimiter() + fc_it->GetStoragekey()); } } return true;}bool CFeatConfigShow::GetShow(int type, int subtype) const{ return m_FeatShows.GetValue(type, subtype);}void CFeatConfigShow::SetShow(int type, int subtype, bool show){ m_FeatShows.SetValue(type, subtype, show);}void CFeatConfigShow::SetShowInherited(int type, int subtype, bool inherited){ m_FeatShows.SetInherited(type, subtype, inherited);}void CFeatConfigShow::ClearShows(){ m_FeatShows.ClearValues();}END_NCBI_SCOPE/* * =========================================================================== * $Log: feat_show.cpp,v $ * Revision 1000.1 2004/06/01 20:43:18 gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.6 * * Revision 1.6 2004/05/21 22:27:40 gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.5 2004/05/20 12:27:41 dicuccio * Removed unnecessary doxygen module directives - they're in the headers * * Revision 1.4 2004/02/05 16:04:35 rsmith * No need to LoadCurrentSettings when used as a base class. * * Revision 1.3 2004/02/02 18:44:18 rsmith * add description to CSettingsSet, constructor and descendants. * * Revision 1.2 2003/12/30 15:00:50 dicuccio * Fixed compiler errors/warnings on MSVC * * Revision 1.1 2003/12/29 14:34:38 rsmith * split out from feat_config.cpp * * * =========================================================================== */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?