KWWidgets
|
00001 /*========================================================================= 00002 00003 Module: $RCSfile: vtkKWRegistryHelper.h,v $ 00004 00005 Copyright (c) Kitware, Inc. 00006 All rights reserved. 00007 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00008 00009 This software is distributed WITHOUT ANY WARRANTY; without even 00010 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00011 PURPOSE. See the above copyright notice for more information. 00012 00013 =========================================================================*/ 00014 // .NAME vtkKWRegistryHelper - A registry class 00015 // .SECTION Description 00016 // This class abstracts the storing of data that can be restored 00017 // when the program executes again. On Win32 platform it is 00018 // implemented using the registry and on unix as a file in 00019 // the user's home directory. 00020 00021 #ifndef __vtkKWRegistryHelper_h 00022 #define __vtkKWRegistryHelper_h 00023 00024 #include "vtkObject.h" 00025 #include "vtkKWWidgets.h" // Needed for export symbols directives 00026 00027 class KWWidgets_EXPORT vtkKWRegistryHelper : public vtkObject 00028 { 00029 public: 00030 // Description: 00031 // Standard New and type methods 00032 static vtkKWRegistryHelper* New(); 00033 vtkTypeRevisionMacro(vtkKWRegistryHelper, vtkObject); 00034 void PrintSelf(ostream& os, vtkIndent indent); 00035 00036 // Description: 00037 // Read a value from the registry. 00038 int ReadValue(const char *subkey, 00039 const char *key, char *value); 00040 00041 // Description: 00042 // Delete a key from the registry. 00043 int DeleteKey(const char *subkey, const char *key); 00044 00045 // Description: 00046 // Delete a value from a given key. 00047 int DeleteValue(const char *subkey, const char *key); 00048 00049 // Description: 00050 // Set value in a given key. 00051 int SetValue(const char *subkey, const char *key, 00052 const char *value); 00053 00054 // Description: 00055 // Open the registry at toplevel/subkey. 00056 int Open(const char *toplevel, const char *subkey, 00057 int readonly); 00058 00059 // Description: 00060 // Close the registry. 00061 int Close(); 00062 00063 // Description: 00064 // Read from local or global scope. On Windows this mean from local machine 00065 // or local user. On unix this will read from $HOME/.Projectrc or 00066 // /etc/Project 00067 vtkSetClampMacro(GlobalScope, int, 0, 1); 00068 vtkBooleanMacro(GlobalScope, int); 00069 vtkGetMacro(GlobalScope, int); 00070 00071 // Description: 00072 // Set or get the toplevel registry key. 00073 vtkSetStringMacro(TopLevel); 00074 vtkGetStringMacro(TopLevel); 00075 00076 // Description: 00077 // Return true if registry opened 00078 vtkGetMacro(Opened, int); 00079 00080 // Description: 00081 // Should the registry be locked? 00082 vtkGetMacro(Locked, int); 00083 00084 // Description: 00085 // Set or get the configuration directory - valid on UNIX only 00086 vtkSetStringMacro(ConfigurationDirectory); 00087 vtkGetStringMacro(ConfigurationDirectory); 00088 00089 //BTX 00090 enum { 00091 ReadOnly, 00092 ReadWrite 00093 }; 00094 00095 enum 00096 { 00097 RegistryKeyValueSizeMax = 8192, 00098 RegistryKeyNameSizeMax = 100 00099 }; 00100 //ETX 00101 00102 protected: 00103 vtkKWRegistryHelper(); 00104 virtual ~vtkKWRegistryHelper(); 00105 00106 // Description: 00107 // Should the registry be locked? 00108 vtkSetClampMacro(Locked, int, 0, 1); 00109 vtkBooleanMacro(Locked, int); 00110 00111 00112 // Description: 00113 // Read a value from the registry. 00114 virtual int ReadValueInternal(const char *key, char *value) = 0; 00115 00116 // Description: 00117 // Delete a key from the registry. 00118 virtual int DeleteKeyInternal(const char *key) = 0; 00119 00120 // Description: 00121 // Delete a value from a given key. 00122 virtual int DeleteValueInternal(const char *key) = 0; 00123 00124 // Description: 00125 // Set value in a given key. 00126 virtual int SetValueInternal(const char *key, 00127 const char *value) = 0; 00128 00129 // Description: 00130 // Open the registry at toplevel/subkey. 00131 virtual int OpenInternal(const char *toplevel, const char *subkey, 00132 int readonly) = 0; 00133 00134 // Description: 00135 // Close the registry. 00136 virtual int CloseInternal() = 0; 00137 00138 // Description: 00139 // Return true if the character is space. 00140 int IsSpace(char c); 00141 00142 // Description: 00143 // Strip trailing and ending spaces. 00144 char *Strip(char *str); 00145 00146 int Opened; 00147 int Changed; 00148 int Empty; 00149 00150 private: 00151 char *TopLevel; 00152 int Locked; 00153 int GlobalScope; 00154 char* ConfigurationDirectory; 00155 00156 vtkKWRegistryHelper(const vtkKWRegistryHelper&); // Not implemented 00157 void operator=(const vtkKWRegistryHelper&); // Not implemented 00158 }; 00159 00160 #endif 00161 00162