feat_decorate.cpp
来自「ncbi源码」· C++ 代码 · 共 203 行
CPP
203 行
/* * =========================================================================== * PRODUCTION $Log: feat_decorate.cpp,v $ * PRODUCTION Revision 1000.1 2004/06/01 20:43:16 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.3 * PRODUCTION * =========================================================================== *//* $Id: feat_decorate.cpp,v 1000.1 2004/06/01 20:43:16 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_decorate.cpp/// #include <ncbi_pch.hpp>#include <gui/config/feat_decorate.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"); const string kDecorate("decorate");}/// everything has the same decoration by default.string CFeatDecorateFactoryDefaults::Get(const string& key) const{ string key1, key2; NStr::SplitInTwo(key, "|", key1, key2); if (key == kDecorate + "|Master") { return kEmptyStr; } NCBI_THROW(CConfigException, eNoDefaultValue, "key: " + key); }// definitions for CFeatConfigDecorate/// use this cstr when declaring a CFeatConfigDecorate object.CFeatConfigDecorate::CFeatConfigDecorate(objects::CPluginConfigCache* config_cache, const string& typedesc) : CSettingsSet(config_cache, "FeatureDecorate", new CFeatDecorateFactoryDefaults(), typedesc){ LoadCurrentSettings(eLoad_Current);}/// use this cstr when initializing a CFeatConfigDecorate 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.CFeatConfigDecorate::CFeatConfigDecorate(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 CFeatConfigDecorate::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; ClearDecorates(); const CFeatConfigList& featureList = *GetFeatConfigList(); ITERATE ( CFeatConfigList, fc_it, featureList ) { int myType = fc_it->GetType(); int mySubtype = fc_it->GetSubtype(); try { featvaluestr = Get(kDecorate + GetKeyDelimiter() + fc_it->GetStoragekey(), src); SetDecorate( myType, mySubtype, CFeatDecorations(featvaluestr)); SetDecorateInherited( myType, mySubtype, false); } catch (const CConfigException&) { } } return true;}bool CFeatConfigDecorate::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_FeatDecorates.GetInherited(myType, mySubtype)) { Set(kDecorate + GetKeyDelimiter() + fc_it->GetStoragekey(), GetDecorate(myType, mySubtype).ToString() ); } else { Delete(kDecorate + GetKeyDelimiter() + fc_it->GetStoragekey()); } } return true;}CFeatDecorations CFeatConfigDecorate::GetDecorate(int type, int subtype) const{ return m_FeatDecorates.GetValue(type, subtype);}void CFeatConfigDecorate::SetDecorate(int type, int subtype, CFeatDecorations decoration){ m_FeatDecorates.SetValue(type, subtype, decoration);}void CFeatConfigDecorate::SetDecorateInherited(int type, int subtype, bool inherited){ m_FeatDecorates.SetInherited(type, subtype, inherited);}void CFeatConfigDecorate::ClearDecorates(){ m_FeatDecorates.ClearValues();}END_NCBI_SCOPE/* * =========================================================================== * $Log: feat_decorate.cpp,v $ * Revision 1000.1 2004/06/01 20:43:16 gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.3 * * Revision 1.3 2004/05/21 22:27:39 gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.2 2004/05/20 12:27:41 dicuccio * Removed unnecessary doxygen module directives - they're in the headers * * Revision 1.1 2004/02/05 16:03:36 rsmith * initial checkin * * * =========================================================================== */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?