PluginConfigCache.hpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:9k
- /*
- * ===========================================================================
- * PRODUCTION $Log: PluginConfigCache.hpp,v $
- * PRODUCTION Revision 1000.1 2003/11/21 18:18:51 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [ORIGINAL] Dev-tree R1.3
- * PRODUCTION
- * ===========================================================================
- */
- /* $Id: PluginConfigCache.hpp,v 1000.1 2003/11/21 18:18:51 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: Robert G. Smith
- *
- * File Description:
- * CPluginConfigCache is a collection of saved (or saveable) configuration values
- * for plugins. It is the parent container class streamed in and out of ASN.1 files
- * to persist these configuration values.
- *
- * Remark:
- * This code was originally generated by application DATATOOL
- * using specifications from the data definition file
- * 'plugin.asn'.
- */
- #ifndef GUI_PLUGIN_PLUGINCONFIGCACHE_HPP
- #define GUI_PLUGIN_PLUGINCONFIGCACHE_HPP
- // generated includes
- #include <gui/config/PluginConfigCache_.hpp>
- #include <gui/config/PluginConfigValues.hpp>
- // generated classes
- BEGIN_NCBI_SCOPE
- BEGIN_objects_SCOPE // namespace ncbi::objects::
- class NCBI_GUICONFIG_EXPORT CPluginConfigCache : public CPluginConfigCache_Base
- {
- typedef CPluginConfigCache_Base Tparent;
- public:
- // constructor
- CPluginConfigCache(void);
- // destructor
- ~CPluginConfigCache(void);
- // merge two PCC's together, presumably from different files.
- // the other_pcc's values over-write this one's.
- // when the type, style and key are duplicates.
- CPluginConfigCache& Merge(const CPluginConfigCache& other_pcc);
-
- // Accessing and Changing values.
- const string& GetStringByKey(
- const string& type,
- const string& style,
- const string& key,
- const string& delim = "|"
- ) const;
-
- const string& GetStringByKey(
- const CPluginConfigValues& pcv,
- const string& key,
- const string& delim = "|"
- ) const;
-
- CPluginConfigValues&
- AddKeyString(
- const string& type, // the type and style identifying the PCV we are going to store the value in.
- const string& style, // or which 'includes' directly or indirectly that PCV.
- const string& typekey, // a multipart key of type names to iterate through for include-PCVs. empty otherwise.
- const string& key, // a multipart data key entirely within one PCV
- const string& value, // the value to store.
- const string& delim = "|" // delimiter used in both typekey and key.
- );
-
- CPluginConfigValues& // return the key/value PCV we actually store stuff in.
- AddKeyString( // this will be pcv if typekey is empty.
- CPluginConfigValues& pcv, // the PCV we will start adding stuff to.
- const string& typekey, // type names for 'include' PCV(s)
- const string& key, // data key.
- const string& value, // data to store.
- const string& delim = "|" // delimiter for both typekey and key.
- );
- bool DelKeyvalue(
- const string& type,
- const string& style,
- const string& key,
- const string& delim = "|"
- );
-
- bool DelKeyvalue(
- CPluginConfigValues& pcv,
- const string& key,
- const string& delim = "|"
- );
-
- // Accessing and changing Sets of values.
- bool HasPCV(const string& type, const string& style) const;
- const CPluginConfigValues& GetPCV(const string& type, const string& style) const;
- TData GetPCVsByType(const string& type) const;
- list<string> GetStyleNamesByType(const string& type) const;
-
- CPluginConfigValues& SetPCV(const string& type, const string& style);
- CPluginConfigValues& SavePCV(const CPluginConfigValues& pcv);
- void DeletePCV(const string& type, const string& style);
- CPluginConfigValues& DupPCV(const string& type, const string& oldstyle, const string& newstyle);
-
- // return style if there is not PCV with this type and style.
- // otherwise append numbers on to the end of style until we find one that is not used.
- // so SetPCV(type, MakeUniqueStyle(type, style)) will always create a new PCV.
- string MakeUniqueStyle(const string& type, const string& style) const;
-
- private:
- // Prohibit copy constructor and assignment operator
- CPluginConfigCache(const CPluginConfigCache& value);
- CPluginConfigCache& operator=(const CPluginConfigCache& value);
-
- static TData::const_iterator s_FindPCV(const string& type, const string& style, const TData&);
- static TData::iterator s_FindPCV(const string& type, const string& style, TData&);
- };
- /////////////////// CPluginConfigCache inline methods
- // constructor
- inline
- CPluginConfigCache::CPluginConfigCache(void)
- {
- }
- inline
- const string& CPluginConfigCache::GetStringByKey(
- const string& type,
- const string& style,
- const string& key,
- const string& delim
- ) const
- {
- return GetStringByKey(GetPCV(type, style), key, delim);
- }
- inline
- CPluginConfigValues&
- CPluginConfigCache::AddKeyString(
- const string& type, // the type and style identifying the PCV we are going to store the value in.
- const string& style, // or which 'includes' directly or indirectly that PCV.
- const string& typekey, // a multipart key of type names to iterate through for include-PCVs. empty otherwise.
- const string& key, // a multipart data key entirely within one PCV
- const string& value, // the value to store.
- const string& delim // delimiter used in both typekey and key.
- )
- {
- return AddKeyString(SetPCV(type, style), typekey, key, value, delim);
- }
-
- inline
- bool CPluginConfigCache::DelKeyvalue(
- const string& type,
- const string& style,
- const string& key,
- const string& delim
- )
- {
- return DelKeyvalue(SetPCV(type, style), key, delim);
- }
- /////////////////// end of CPluginConfigCache inline methods
- END_objects_SCOPE // namespace ncbi::objects::
- END_NCBI_SCOPE
- /*
- * ===========================================================================
- *
- * $Log: PluginConfigCache.hpp,v $
- * Revision 1000.1 2003/11/21 18:18:51 gouriano
- * PRODUCTION: UPGRADED [ORIGINAL] Dev-tree R1.3
- *
- * Revision 1.3 2003/11/21 12:48:32 rsmith
- * Add ability to delete entries by key.
- *
- * Revision 1.2 2003/10/10 19:35:31 dicuccio
- * Added export specifiers
- *
- * Revision 1.1 2003/10/10 17:41:23 rsmith
- * moved from gui/plugin to gui/config
- *
- * Revision 1.5 2003/08/26 19:35:14 rsmith
- * add methods to get a list of style names for a particular type
- * and to return an unused style name, give a type and style.
- *
- * Revision 1.4 2003/08/19 18:16:45 rsmith
- * delete ExistsPCV, redundant with HasPCV.
- * new method AddKeyString.
- * Merge merges PCVs as units. Does not recursively merge their values.
- *
- * Revision 1.3 2003/08/13 20:21:43 rsmith
- * Add Merge method and get rid of FindIf
- *
- * Revision 1.2 2003/08/05 19:30:19 meric
- * Added 'inline' keyword for inlined function GetStringByKey()
- *
- * Revision 1.1 2003/08/05 17:37:38 rsmith
- * Classes to allow saving of plugins configuration values as ASN.1.
- *
- *
- * ===========================================================================
- */
- #endif // GUI_PLUGIN_PLUGINCONFIGCACHE_HPP
- /* Original file checksum: lines: 93, chars: 2515, CRC32: a681cde */