settings.hpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:7k
- /*
- * ===========================================================================
- * PRODUCTION $Log: settings.hpp,v $
- * PRODUCTION Revision 1000.0 2004/04/12 18:17:30 gouriano
- * PRODUCTION PRODUCTION: IMPORTED [CATCHUP_003] Dev-tree R1.3
- * PRODUCTION
- * ===========================================================================
- */
- #ifndef GUI_CORE___SETTINGS__HPP
- #define GUI_CORE___SETTINGS__HPP
- /* $Id: settings.hpp,v 1000.0 2004/04/12 18:17:30 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: Mike DiCuccio, Robert Smith
- *
- * File Description:
- * CSettings -- Repository for application settings.
- */
- #include <corelib/ncbireg.hpp>
- #include <gui/config/PluginConfigCache.hpp>
- BEGIN_NCBI_SCOPE
- class NCBI_GUICONFIG_EXPORT CSettings : public CObject
- {
- public:
- CSettings();
- void ShutDown(void);
-
- /// access the plugins' configurations.
- bool IsSetPluginConfig(void) const;
- bool CanGetPluginConfig(void) const;
- const objects::CPluginConfigCache& GetPluginConfig(void) const;
- objects::CPluginConfigCache& SetPluginConfig(void);
- void SetPluginConfig(objects::CPluginConfigCache& pcc);
-
- /** reading the plugin config file */
- /// Load the plugin config cache from the standard places.
- void LoadPluginConfig(void);
-
- /// Load the plugin config cache from a particular file.
- /// path resolution for <std> and <home> is done.
- void LoadPluginConfig(const string& pcfile);
-
- /// Load the plugin config cache from a number of specified files.
- /// path resolution for <std> and <home> is done.
- /// paths are separated by new lines, returns, tabs or commas.
- /// so can not contains any of those characters.
- void LoadPluginConfigs(const string& pcfiles);
-
- /** Writing the plugin config file */
- /// write the plugin config cache to the standard place.
- void SavePluginConfig(void);
- /// write the plugin config cache to a particular file.
- void SavePluginConfig(const string& pcfile);
-
- /** the file used as a default by SavePluginConfig, and Shutdown */
- string SetPluginConfigWriteFile(const string file_name);
- string GetPluginConfigWriteFile() const;
- /// Load the plugin config cache from a string in memory.
- /// assumed to be in ASN.1 text format.
- void LoadPluginConfigFromString(const string& asn1_str);
-
- /// Get the string containing our built-in config settings in ASN format.
- static string GetBuiltInPluginConfig();
-
- /// The following are Where the work is actually done.
- /// They are static so they may be used independently without linking in the CSystemPath stuff
-
- /// Serialize the given plugin config cache to the given file.
- static void WritePluginConfig(const string& pcfile,
- const objects::CPluginConfigCache& pcc);
- /// Serialize the given file into the plugin config cache.
- static bool ReadPluginConfig(const string& pcfile,
- objects::CPluginConfigCache& pcc);
- /// Serialize the string into the plugin config cache.
- static bool ReadPluginConfigFromString(const string& asn1_str,
- objects::CPluginConfigCache& config_cache);
- /// Concatenate a bunch of cstrings into one string.
- /// useful since on some platforms string literals must be of limited size
- /// <2048 on some Windows compilers.
- static string BuildString(const char* cstrings[]);
-
- private:
- /// Set the plugin config cache if it doesn't exist yet.
- /// or merge it with this pcc if it does.
- void x_LoadPluginConfig(objects::CPluginConfigCache& pcc);
-
- /// our one and only cache of plugin configurations.
- /// read from ASN.1 file(s) and strings.
- CRef<objects::CPluginConfigCache> m_PCC;
- /// the file to which we will write our PCC by default.
- string m_PluginConfigSaveFile;
-
- /// array of c-strings that make up our 'built-in' configuration definitions.
- /// last element must be a 0.
- /// see scripts/internal/
- //static const char * m_BuiltInASN[];
-
- };
- END_NCBI_SCOPE
- #endif // GUI_CORE___SETTINGS__HPP
- /*
- * ===========================================================================
- * $Log: settings.hpp,v $
- * Revision 1000.0 2004/04/12 18:17:30 gouriano
- * PRODUCTION: IMPORTED [CATCHUP_003] Dev-tree R1.3
- *
- * Revision 1.3 2004/02/20 16:12:15 rsmith
- * make GetBuiltInPluginConfig static
- *
- * Revision 1.2 2004/02/18 17:15:26 dicuccio
- * Use correct export specifier
- *
- * Revision 1.1 2004/02/17 20:35:18 rsmith
- * moved core/settings.[ch]pp and core/system_path.[ch]pp to config and utils, respectively.
- *
- * Revision 1.10 2004/01/16 21:43:14 rsmith
- * Support for built-in configuration settings.
- *
- * Revision 1.9 2004/01/06 19:53:14 rsmith
- * Add method to read PCC ASN.1 values from strings.
- * Reorganize methods with static methods so that PCC reading and writing could be done
- * without linking in all the gui framework stuff.
- *
- * Revision 1.8 2003/11/06 19:58:27 dicuccio
- * Removed USING_SCOPE(objects). Un-inlined code
- *
- * Revision 1.7 2003/10/10 18:40:32 ucko
- * PluginConfigCache.hpp is now in gui/config.
- *
- * Revision 1.6 2003/08/25 18:54:01 rsmith
- * took out all the color stuff and made this the manager of the Plugin Config Cache, including reading writing it to disk.
- *
- * Revision 1.5 2003/08/22 15:54:01 dicuccio
- * Removed config file - accessible through CNcbiApplication. Removed
- * 'USING_SCOPE(objects)'
- *
- * Revision 1.4 2003/06/25 16:59:41 dicuccio
- * Changed CPluginHandle into a pointer-to-implementation (the previous
- * implementation is now the pointer held). Lots of #include file clean-ups.
- *
- * Revision 1.3 2003/02/25 14:40:59 dicuccio
- * Expanded CSettings functionality - store config file here
- *
- * Revision 1.2 2003/01/16 18:23:46 dicuccio
- * Added export specifier to settings.hpp
- *
- * Revision 1.1 2003/01/15 20:55:58 dicuccio
- * Initial revision
- *
- * ===========================================================================
- */