feat_config_inherited.hpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:5k
- /*
- * ===========================================================================
- * PRODUCTION $Log: feat_config_inherited.hpp,v $
- * PRODUCTION Revision 1000.1 2004/06/01 19:46:21 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.3
- * PRODUCTION
- * ===========================================================================
- */
- #ifndef GUI_CONFIG___FEAT_CONFIG_INHERITED__HPP
- #define GUI_CONFIG___FEAT_CONFIG_INHERITED__HPP
- /* $Id: feat_config_inherited.hpp,v 1000.1 2004/06/01 19:46:21 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_config_inherited.hpp
- #include <objects/seqfeat/SeqFeatData.hpp>
- /** @addtogroup GUI_CONFIG
- *
- * @{
- */
- BEGIN_NCBI_SCOPE
- ///
- /// Template for configured values, indexed by feature type and subtype
- /// where values can inherit from master feature types.
- ///
- template <typename V>
- class CFeatConfigValues {
- public:
- CFeatConfigValues();
- explicit CFeatConfigValues(V masterdefault);
- void SetValue(int type, int subtype, V value);
- V GetValue(int type, int subtype) const;
-
- void SetInherited(int type, int subtype, bool b);
- bool GetInherited(int type, int subtype) const;
-
- void ClearValues();
-
- private:
- struct CFeatConfigValue {
- V m_Value;
- bool m_Inherited;
- };
- typedef pair<int, int> TPair;
- typedef map<TPair, CFeatConfigValue> TFeatConfigValuesCont;
-
- TFeatConfigValuesCont m_FeatConfigValues;
- };
- // methods of template classes.
- template <typename V>
- CFeatConfigValues<V>::CFeatConfigValues() {
- SetValue(objects::CSeqFeatData::e_not_set,
- objects::CSeqFeatData::eSubtype_any, V());
- }
- template <typename V>
- CFeatConfigValues<V>::CFeatConfigValues(V masterdefault) {
- SetValue(objects::CSeqFeatData::e_not_set,
- objects::CSeqFeatData::eSubtype_any, masterdefault);
- }
- template <typename V>
- void CFeatConfigValues<V>::ClearValues()
- {
- m_FeatConfigValues.clear();
- }
- template <typename V>
- void CFeatConfigValues<V>::SetValue(int type, int subtype, V value)
- {
- m_FeatConfigValues[TPair(type, subtype)].m_Value = value;
- }
- template <typename V>
- V CFeatConfigValues<V>::GetValue(int type, int subtype) const
- {
- typename TFeatConfigValuesCont::const_iterator endit
- = m_FeatConfigValues.end();
- typename TFeatConfigValuesCont::const_iterator fcit
- = m_FeatConfigValues.find(TPair(type, subtype));
- if (fcit == endit || fcit->second.m_Inherited) {
- fcit = m_FeatConfigValues.find
- (TPair(type, objects::CSeqFeatData::eSubtype_any));
- if (fcit == endit || fcit->second.m_Inherited) {
- fcit = m_FeatConfigValues.find
- (TPair(objects::CSeqFeatData::e_not_set,
- objects::CSeqFeatData::eSubtype_any));
- _ASSERT(fcit != endit && ! fcit->second.m_Inherited);
- }
- }
- return fcit->second.m_Value;
- }
- template <typename V>
- void CFeatConfigValues<V>::SetInherited(int type, int subtype, bool inherit)
- {
- m_FeatConfigValues[TPair(type, subtype)].m_Inherited = inherit;
- }
- template <typename V>
- bool CFeatConfigValues<V>::GetInherited(int type, int subtype) const
- {
- typename TFeatConfigValuesCont::const_iterator fcit
- = m_FeatConfigValues.find(TPair(type, subtype));
- // not found is inherited.
- return (fcit == m_FeatConfigValues.end()) || fcit->second.m_Inherited;
- }
- END_NCBI_SCOPE
- /* @} */
- /*
- * ===========================================================================
- *
- * $Log: feat_config_inherited.hpp,v $
- * Revision 1000.1 2004/06/01 19:46:21 gouriano
- * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.3
- *
- * Revision 1.3 2004/05/11 18:55:53 dicuccio
- * Changed doxygen modules - use GUI_CONFIG instead of PluginConfiguration
- *
- * Revision 1.2 2003/12/29 15:34:45 ucko
- * #include <SeqFeatData.hpp>
- *
- * Revision 1.1 2003/12/29 14:17:11 rsmith
- * Seperated from feat_config.hpp/cpp
- *
- *
- * ===========================================================================
- */
- #endif /* GUI_CONFIG___FEAT_CONFIG_INHERITED__HPP */