PluginConfigCache.hpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:9k
源码类别:

生物技术

开发平台:

C/C++

  1. /*
  2.  * ===========================================================================
  3.  * PRODUCTION $Log: PluginConfigCache.hpp,v $
  4.  * PRODUCTION Revision 1000.1  2003/11/21 18:18:51  gouriano
  5.  * PRODUCTION PRODUCTION: UPGRADED [ORIGINAL] Dev-tree R1.3
  6.  * PRODUCTION
  7.  * ===========================================================================
  8.  */
  9. /* $Id: PluginConfigCache.hpp,v 1000.1 2003/11/21 18:18:51 gouriano Exp $
  10.  * ===========================================================================
  11.  *
  12.  *                            PUBLIC DOMAIN NOTICE
  13.  *               National Center for Biotechnology Information
  14.  *
  15.  *  This software/database is a "United States Government Work" under the
  16.  *  terms of the United States Copyright Act.  It was written as part of
  17.  *  the author's official duties as a United States Government employee and
  18.  *  thus cannot be copyrighted.  This software/database is freely available
  19.  *  to the public for use. The National Library of Medicine and the U.S.
  20.  *  Government have not placed any restriction on its use or reproduction.
  21.  *
  22.  *  Although all reasonable efforts have been taken to ensure the accuracy
  23.  *  and reliability of the software and data, the NLM and the U.S.
  24.  *  Government do not and cannot warrant the performance or results that
  25.  *  may be obtained by using this software or data. The NLM and the U.S.
  26.  *  Government disclaim all warranties, express or implied, including
  27.  *  warranties of performance, merchantability or fitness for any particular
  28.  *  purpose.
  29.  *
  30.  *  Please cite the author in any work or product based on this material.
  31.  *
  32.  * ===========================================================================
  33.  *
  34.  * Author:  Robert G. Smith
  35.  *
  36.  * File Description:
  37.  *   CPluginConfigCache is a collection of saved (or saveable) configuration values
  38.  *  for plugins.  It is the parent container class streamed in and out of ASN.1 files
  39.  *  to persist these configuration values.
  40.  *
  41.  * Remark:
  42.  *   This code was originally generated by application DATATOOL
  43.  *   using specifications from the data definition file
  44.  *   'plugin.asn'.
  45.  */
  46. #ifndef GUI_PLUGIN_PLUGINCONFIGCACHE_HPP
  47. #define GUI_PLUGIN_PLUGINCONFIGCACHE_HPP
  48. // generated includes
  49. #include <gui/config/PluginConfigCache_.hpp>
  50. #include <gui/config/PluginConfigValues.hpp>
  51. // generated classes
  52. BEGIN_NCBI_SCOPE
  53. BEGIN_objects_SCOPE // namespace ncbi::objects::
  54. class NCBI_GUICONFIG_EXPORT CPluginConfigCache : public CPluginConfigCache_Base
  55. {
  56.     typedef CPluginConfigCache_Base Tparent;
  57. public:
  58.     // constructor
  59.     CPluginConfigCache(void);
  60.     // destructor
  61.     ~CPluginConfigCache(void);
  62.     // merge two PCC's together, presumably from different files.
  63.     //  the other_pcc's values over-write this one's.
  64.     //  when the type, style and key are duplicates. 
  65.     CPluginConfigCache& Merge(const CPluginConfigCache& other_pcc);
  66.     
  67.     // Accessing and Changing values.
  68.      const string&  GetStringByKey(
  69.         const string& type, 
  70.         const string& style, 
  71.         const string& key, 
  72.         const string& delim = "|"
  73.         ) const;
  74.         
  75.     const string&  GetStringByKey(
  76.         const CPluginConfigValues& pcv,
  77.         const string& key, 
  78.         const string& delim = "|"
  79.         ) const;
  80.     
  81.     CPluginConfigValues& 
  82.     AddKeyString(
  83.         const string& type,     // the type and style identifying the PCV we are going to store the value in.
  84.         const string& style,    // or which 'includes' directly or indirectly that PCV.
  85.         const string& typekey,  // a multipart key of type names to iterate through for include-PCVs. empty otherwise.
  86.         const string& key,      // a multipart data key entirely within one PCV
  87.         const string& value,    // the value to store.
  88.         const string& delim = "|"   // delimiter used in both typekey and key.
  89.         );
  90.         
  91.     CPluginConfigValues&    // return the key/value PCV we actually store stuff in.
  92.     AddKeyString(              // this will be pcv if typekey is empty.
  93.         CPluginConfigValues& pcv,   // the PCV we will start adding stuff to.
  94.         const string& typekey,      // type names for 'include' PCV(s)
  95.         const string& key,          // data key.
  96.         const string& value,        // data to store.
  97.         const string& delim = "|"   // delimiter for both typekey and key.
  98.         );
  99.      bool  DelKeyvalue(
  100.         const string& type, 
  101.         const string& style, 
  102.         const string& key, 
  103.         const string& delim = "|"
  104.         );
  105.         
  106.     bool  DelKeyvalue(
  107.         CPluginConfigValues& pcv,
  108.         const string& key, 
  109.         const string& delim = "|"
  110.         );
  111.     
  112.     // Accessing and changing Sets of values.
  113.     bool                        HasPCV(const string& type, const string& style) const;
  114.     const CPluginConfigValues&  GetPCV(const string& type, const string& style) const;
  115.     TData                       GetPCVsByType(const string& type) const;
  116.     list<string>                GetStyleNamesByType(const string& type) const;
  117.     
  118.     CPluginConfigValues&    SetPCV(const string& type, const string& style);
  119.     CPluginConfigValues&    SavePCV(const CPluginConfigValues& pcv);
  120.     void                    DeletePCV(const string& type, const string& style);
  121.     CPluginConfigValues&    DupPCV(const string& type, const string& oldstyle, const string& newstyle);
  122.     
  123.     // return style if there is not PCV with this type and style.
  124.     // otherwise append numbers on to the end of style until we find one that is not used.
  125.     // so SetPCV(type, MakeUniqueStyle(type, style)) will always create a new PCV.
  126.     string  MakeUniqueStyle(const string& type, const string& style) const;    
  127.     
  128. private:
  129.     // Prohibit copy constructor and assignment operator
  130.     CPluginConfigCache(const CPluginConfigCache& value);
  131.     CPluginConfigCache& operator=(const CPluginConfigCache& value);
  132.     
  133.     static TData::const_iterator    s_FindPCV(const string& type, const string& style, const TData&);
  134.     static TData::iterator          s_FindPCV(const string& type, const string& style, TData&);
  135. };
  136. /////////////////// CPluginConfigCache inline methods
  137. // constructor
  138. inline
  139. CPluginConfigCache::CPluginConfigCache(void)
  140. {
  141. }
  142. inline
  143. const string& CPluginConfigCache::GetStringByKey(
  144.     const string& type, 
  145.     const string& style, 
  146.     const string& key, 
  147.     const string& delim
  148.     ) const
  149. {
  150.     return GetStringByKey(GetPCV(type, style), key, delim);
  151. }
  152. inline
  153. CPluginConfigValues& 
  154. CPluginConfigCache::AddKeyString(
  155.     const string& type,     // the type and style identifying the PCV we are going to store the value in.
  156.     const string& style,    // or which 'includes' directly or indirectly that PCV.
  157.     const string& typekey,  // a multipart key of type names to iterate through for include-PCVs. empty otherwise.
  158.     const string& key,      // a multipart data key entirely within one PCV
  159.     const string& value,    // the value to store.
  160.     const string& delim     // delimiter used in both typekey and key.
  161.     )
  162. {
  163.     return AddKeyString(SetPCV(type, style), typekey, key, value, delim);
  164. }
  165.         
  166. inline
  167. bool CPluginConfigCache::DelKeyvalue(
  168.     const string& type, 
  169.     const string& style, 
  170.     const string& key, 
  171.     const string& delim
  172.     )
  173. {
  174.     return DelKeyvalue(SetPCV(type, style), key, delim);
  175. }
  176. /////////////////// end of CPluginConfigCache inline methods
  177. END_objects_SCOPE // namespace ncbi::objects::
  178. END_NCBI_SCOPE
  179. /*
  180. * ===========================================================================
  181. *
  182. * $Log: PluginConfigCache.hpp,v $
  183. * Revision 1000.1  2003/11/21 18:18:51  gouriano
  184. * PRODUCTION: UPGRADED [ORIGINAL] Dev-tree R1.3
  185. *
  186. * Revision 1.3  2003/11/21 12:48:32  rsmith
  187. * Add ability to delete entries by key.
  188. *
  189. * Revision 1.2  2003/10/10 19:35:31  dicuccio
  190. * Added export specifiers
  191. *
  192. * Revision 1.1  2003/10/10 17:41:23  rsmith
  193. * moved from gui/plugin to gui/config
  194. *
  195. * Revision 1.5  2003/08/26 19:35:14  rsmith
  196. * add methods to get a list of style names for a particular type
  197. * and to return an unused style name, give a type and style.
  198. *
  199. * Revision 1.4  2003/08/19 18:16:45  rsmith
  200. * delete ExistsPCV, redundant with HasPCV.
  201. * new method AddKeyString.
  202. * Merge merges PCVs as units. Does not recursively merge their values.
  203. *
  204. * Revision 1.3  2003/08/13 20:21:43  rsmith
  205. * Add Merge method and get rid of FindIf
  206. *
  207. * Revision 1.2  2003/08/05 19:30:19  meric
  208. * Added 'inline' keyword for inlined function GetStringByKey()
  209. *
  210. * Revision 1.1  2003/08/05 17:37:38  rsmith
  211. * Classes to allow saving of plugins configuration values as ASN.1.
  212. *
  213. *
  214. * ===========================================================================
  215. */
  216. #endif // GUI_PLUGIN_PLUGINCONFIGCACHE_HPP
  217. /* Original file checksum: lines: 93, chars: 2515, CRC32: a681cde */