feat_config_list.hpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:7k
- /*
- * ===========================================================================
- * PRODUCTION $Log: feat_config_list.hpp,v $
- * PRODUCTION Revision 1000.1 2004/06/01 19:46:25 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.6
- * PRODUCTION
- * ===========================================================================
- */
- #ifndef GUI_CONFIG___FEAT_CONFIG_LIST__HPP
- #define GUI_CONFIG___FEAT_CONFIG_LIST__HPP
- /* $Id: feat_config_list.hpp,v 1000.1 2004/06/01 19:46:25 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_list.hpp
- /// Declarations for a list of "features" that can be configured.
- #include <corelib/ncbistd.hpp>
- #include <gui/gui.hpp>
- #include <objects/seqfeat/SeqFeatData.hpp>
- #include <set>
- /** @addtogroup GUI_CONFIG
- *
- * @{
- */
- BEGIN_NCBI_SCOPE
- /// CFeatConfigItem - basic configuration data for one "feature" type.
- /// "feature" expanded to include things that are not SeqFeats.
- class NCBI_GUICONFIG_EXPORT CFeatConfigItem
- {
- public:
- CFeatConfigItem() {}
- CFeatConfigItem(int type, int subtype, const char* desc, const char* key)
- : m_Type(type)
- , m_Subtype(subtype)
- , m_Description(desc)
- , m_StorageKey(key) {}
- bool operator<(const CFeatConfigItem& rhs) const;
-
- int GetType() const;
- int GetSubtype() const;
- string GetDescription() const;
- string GetStoragekey() const;
-
- private:
- int m_Type; ///< Feature type, or e_not_set for default values.
- int m_Subtype; ///< Feature subtype or eSubtype_any for default values.
- string m_Description; ///< a string for display purposes.
- string m_StorageKey; ///< a short string to use as a key or part of a key
- ///< when storing a value by key/value string pairs.
- };
- // Inline methods.
- inline
- int CFeatConfigItem::GetType() const
- { return m_Type; }
- inline
- int CFeatConfigItem::GetSubtype() const
- { return m_Subtype; }
- inline
- string CFeatConfigItem::GetDescription() const
- { return m_Description; }
- inline
- string CFeatConfigItem::GetStoragekey() const
- { return m_StorageKey; }
- /// CConfigurableItems - a static list of items that can be configured.
- ///
- /// One can iterate through all items. Iterators dereference to CFeatConfigItem.
- /// One can also get an item by type and subtype.
- class NCBI_GUICONFIG_EXPORT CFeatConfigList
- {
- private:
- typedef set<CFeatConfigItem> TFeatTypeContainer;
- public:
-
- CFeatConfigList();
-
- bool TypeValid(int type, int subtype) const;
-
- /// can get all static information for one type/subtype.
- bool GetItem(int type, int subtype, CFeatConfigItem& config_item) const;
-
- bool GetItemByDescription(const string& desc, CFeatConfigItem& config_item) const;
- bool GetItemByKey(const string& key, CFeatConfigItem& config_item) const;
-
- /// Get the displayable description of this type of feature.
- string GetDescription(int type, int subtype) const;
-
- /// Get the feature's type and subtype from its description.
- /// return true on success, false if type and subtype are not valid.
- bool GetTypeSubType(const string& desc, int& type, int& subtype) const;
- /// Get the key used to store this type of feature.
- string GetStoragekey(int type, int subtype) const;
- /// return a list of all the feature descriptions for a menu or other control.
- /// if hierarchical is true use in an Fl_Menu_ descendant to make hierarchical menus.
- void GetDescriptions(
- vector<string> &descs, ///> output, list of description strings.
- bool hierarchical = false ///> make descriptions hierachical, separated by '/'.
- ) const;
-
- // Iteratable list of key values (type/subtype).
- // can iterate through all values including defaults or with only
- // real Feature types/subtypes.
- typedef TFeatTypeContainer::const_iterator const_iterator;
-
- size_t size() const;
- const_iterator begin() const;
- const_iterator end() const;
- private:
- /// initialize our container of feature types and descriptions.
- void x_Init(void);
- TFeatTypeContainer m_FeatTypes; ///> all valid types and subtypes.
- };
- /// You can have your own copy of the FeatConfgList, but usually
- /// you will want to get a pointer to a static copy from here.
- NCBI_GUICONFIG_EXPORT
- const CFeatConfigList* GetFeatConfigList();
- /// when getting Feature descriptions use this function if you want the 'Master'
- /// items to be called something else: like this:
- /// ChangeMasterFeatDescription(feat_it->GetDescription(), "Default")
- NCBI_GUICONFIG_EXPORT
- string ChangeMasterFeatDescription(const string& oldDesc,
- const string& newMasterDesc);
- END_NCBI_SCOPE
- /* @} */
- /*
- * ===========================================================================
- *
- * $Log: feat_config_list.hpp,v $
- * Revision 1000.1 2004/06/01 19:46:25 gouriano
- * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.6
- *
- * Revision 1.6 2004/05/11 18:55:53 dicuccio
- * Changed doxygen modules - use GUI_CONFIG instead of PluginConfiguration
- *
- * Revision 1.5 2004/05/03 12:39:54 dicuccio
- * Added #include for gui/gui.hpp
- *
- * Revision 1.4 2004/01/15 14:48:08 rsmith
- * add GetTypeSubType method from CFeatConfig (deprecated).
- *
- * Revision 1.3 2004/01/14 20:29:35 rsmith
- * Add GetDescriptions method to easily get lists of feature descriptions.
- *
- * Revision 1.2 2003/12/30 14:53:46 dicuccio
- * Added export specifiers to global functions
- *
- * Revision 1.1 2003/12/29 14:17:12 rsmith
- * Seperated from feat_config.hpp/cpp
- *
- *
- * ===========================================================================
- */
- #endif /* GUI_CONFIG___FEAT_CONFIG_LIST__HPP */