![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * R e g i s t r y C l a s s * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 1998,2009 by Jeroen van der Zijp. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or modify * 00009 * it under the terms of the GNU Lesser General Public License as published by * 00010 * the Free Software Foundation; either version 3 of the License, or * 00011 * (at your option) any later version. * 00012 * * 00013 * This library is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00016 * GNU Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public License * 00019 * along with this program. If not, see <http://www.gnu.org/licenses/> * 00020 ********************************************************************************* 00021 * $Id: FXRegistry.h,v 1.36 2009/01/06 13:07:26 fox Exp $ * 00022 ********************************************************************************/ 00023 #ifndef FXREGISTRY_H 00024 #define FXREGISTRY_H 00025 00026 #ifndef FXSETTINGS_H 00027 #include "FXSettings.h" 00028 #endif 00029 00030 namespace FX { 00031 00032 00033 /** 00034 * The registry maintains a database of persistent settings for an application. 00035 * The settings database is organized in two groups of three layers each. The 00036 * system-wide settings group contains settings information pertaining to all 00037 * users on a system. The per-user settings group contains settings affecting 00038 * that user only. 00039 * Each settings group contains a desktop layer, which comprises the settings 00040 * which affect all FOX programs, a vendor layer which holds settings that 00041 * affect all applications from that vendor (e.g. a application-suite), and 00042 * an application layer which holds settings only for a single application. 00043 * The vendor-key and application-key determine which files these layers come 00044 * from, while the "Desktop" key is used for all FOX applications. 00045 * Settings in the system-wide group are overwritten by the per-user group, 00046 * and settings from the "Desktop" layer are overwritten by the vendor-layer; 00047 * vendor-layer settings are overwritten by the application-layer settings. 00048 * Only the per-user, per-application settings ever gets written; the layers 00049 * in the system-group only get written during installation and configuration 00050 * of the application. 00051 * The registry is read when FXApp::init() is called, and written back to the 00052 * system when FXApp::exit() is called. 00053 */ 00054 class FXAPI FXRegistry : public FXSettings { 00055 FXDECLARE(FXRegistry) 00056 protected: 00057 FXString applicationkey; // Application key 00058 FXString vendorkey; // Vendor key 00059 FXbool ascii; // ASCII file-based registry 00060 protected: 00061 FXbool readFromDir(const FXString& dirname,FXbool mark); 00062 #ifdef WIN32 00063 FXbool readFromRegistry(void* hRootKey,FXbool mark); 00064 FXbool writeToRegistry(void* hRootKey); 00065 FXbool readFromRegistryGroup(void* org,const char* groupname,FXbool mark=false); 00066 FXbool writeToRegistryGroup(void* org,const char* groupname); 00067 #endif 00068 private: 00069 FXRegistry(const FXRegistry&); 00070 FXRegistry &operator=(const FXRegistry&); 00071 public: 00072 00073 /** 00074 * Construct registry object; akey and vkey must be string constants. 00075 * Regular applications SHOULD set a vendor key! 00076 */ 00077 FXRegistry(const FXString& akey=FXString::null,const FXString& vkey=FXString::null); 00078 00079 /// Read registry 00080 FXbool read(); 00081 00082 /// Write registry 00083 FXbool write(); 00084 00085 /// Return application key 00086 const FXString& getAppKey() const { return applicationkey; } 00087 00088 /// Return vendor key 00089 const FXString& getVendorKey() const { return vendorkey; } 00090 00091 /** 00092 * Set ASCII mode; under MS-Windows, this will switch the system to a 00093 * file-based registry system, instead of using the System Registry API. 00094 */ 00095 void setAsciiMode(FXbool asciiMode){ ascii=asciiMode; } 00096 00097 /// Get ASCII mode 00098 FXbool getAsciiMode() const { return ascii; } 00099 }; 00100 00101 } 00102 00103 #endif
![]() |