Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXRegistry.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                           R e g i s t r y   C l a s s                         *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1998,2010 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 #ifndef FXREGISTRY_H
00022 #define FXREGISTRY_H
00023 
00024 #ifndef FXSETTINGS_H
00025 #include "FXSettings.h"
00026 #endif
00027 
00028 namespace FX {
00029 
00030 
00031 /**
00032 * The registry maintains a database of persistent settings for an application.
00033 * The settings database is organized in two groups of three layers each.  The
00034 * system-wide settings group contains settings information pertaining to all
00035 * users on a system.  The per-user settings group contains settings affecting
00036 * that user only.
00037 * Each settings group contains a desktop layer, which comprises the settings
00038 * which affect all FOX programs, a vendor layer which holds settings that
00039 * affect all applications from that vendor (e.g. a application-suite), and
00040 * an application layer which holds settings only for a single application.
00041 * The vendor-key and application-key determine which files these layers come
00042 * from, while the "Desktop" key is used for all FOX applications.
00043 * Settings in the system-wide group are overwritten by the per-user group,
00044 * and settings from the "Desktop" layer are overwritten by the vendor-layer;
00045 * vendor-layer settings are overwritten by the application-layer settings.
00046 * Only the per-user, per-application settings ever gets written; the layers
00047 * in the system-group only get written during installation and configuration
00048 * of the application.
00049 * The registry is read when FXApp::init() is called, and written back to the
00050 * system when FXApp::exit() is called.
00051 */
00052 class FXAPI FXRegistry : public FXSettings {
00053   FXDECLARE(FXRegistry)
00054 protected:
00055   FXString applicationkey;  // Application key
00056   FXString vendorkey;       // Vendor key
00057   FXbool   ascii;           // ASCII file-based registry
00058 protected:
00059   FXbool readFromDir(const FXString& dirname,FXbool mark);
00060 #ifdef WIN32
00061   FXbool readFromRegistry(void* hRootKey,FXbool mark);
00062   FXbool readFromRegistryGroup(void* org,const char* groupname,FXbool mark=false);
00063   FXbool writeToRegistry(void* hRootKey);
00064   FXbool writeToRegistryGroup(void* org,const char* groupname);
00065 #endif
00066 private:
00067   FXRegistry(const FXRegistry&);
00068   FXRegistry &operator=(const FXRegistry&);
00069 public:
00070 
00071   /**
00072   * Construct registry object; akey and vkey must be string constants.
00073   * Regular applications SHOULD set a vendor key!
00074   */
00075   FXRegistry(const FXString& akey=FXString::null,const FXString& vkey=FXString::null);
00076 
00077   /// Read registry
00078   FXbool read();
00079 
00080   /// Write registry
00081   FXbool write();
00082 
00083   /// Return application key
00084   const FXString& getAppKey() const { return applicationkey; }
00085 
00086   /// Return vendor key
00087   const FXString& getVendorKey() const { return vendorkey; }
00088 
00089   /**
00090   * Set ASCII mode; under MS-Windows, this will switch the system to a
00091   * file-based registry system, instead of using the System Registry API.
00092   */
00093   void setAsciiMode(FXbool asciiMode){ ascii=asciiMode; }
00094 
00095   /// Get ASCII mode
00096   FXbool getAsciiMode() const { return ascii; }
00097   };
00098 
00099 }
00100 
00101 #endif

Copyright © 1997-2010 Jeroen van der Zijp