KWWidgets
debian/tmp/usr/include/KWWidgets/vtkKWRegistryHelper.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Module: $RCSfile: vtkKWRegistryHelper.h,v $
4 
5  Copyright (c) Kitware, Inc.
6  All rights reserved.
7  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notice for more information.
12 
13 =========================================================================*/
14 // .NAME vtkKWRegistryHelper - A registry class
15 // .SECTION Description
16 // This class abstracts the storing of data that can be restored
17 // when the program executes again. On Win32 platform it is
18 // implemented using the registry and on unix as a file in
19 // the user's home directory.
20 
21 #ifndef __vtkKWRegistryHelper_h
22 #define __vtkKWRegistryHelper_h
23 
24 #include "vtkObject.h"
25 #include "vtkKWWidgets.h" // Needed for export symbols directives
26 
27 class KWWidgets_EXPORT vtkKWRegistryHelper : public vtkObject
28 {
29 public:
30  // Description:
31  // Standard New and type methods
32  static vtkKWRegistryHelper* New();
33  vtkTypeRevisionMacro(vtkKWRegistryHelper, vtkObject);
34  void PrintSelf(ostream& os, vtkIndent indent);
35 
36  // Description:
37  // Read a value from the registry.
38  int ReadValue(const char *subkey,
39  const char *key, char *value);
40 
41  // Description:
42  // Delete a key from the registry.
43  int DeleteKey(const char *subkey, const char *key);
44 
45  // Description:
46  // Delete a value from a given key.
47  int DeleteValue(const char *subkey, const char *key);
48 
49  // Description:
50  // Set value in a given key.
51  int SetValue(const char *subkey, const char *key,
52  const char *value);
53 
54  // Description:
55  // Open the registry at toplevel/subkey.
56  int Open(const char *toplevel, const char *subkey,
57  int readonly);
58 
59  // Description:
60  // Close the registry.
61  int Close();
62 
63  // Description:
64  // Read from local or global scope. On Windows this mean from local machine
65  // or local user. On unix this will read from $HOME/.Projectrc or
66  // /etc/Project
67  vtkSetClampMacro(GlobalScope, int, 0, 1);
68  vtkBooleanMacro(GlobalScope, int);
69  vtkGetMacro(GlobalScope, int);
70 
71  // Description:
72  // Set or get the toplevel registry key.
73  vtkSetStringMacro(TopLevel);
74  vtkGetStringMacro(TopLevel);
75 
76  // Description:
77  // Return true if registry opened
78  vtkGetMacro(Opened, int);
79 
80  // Description:
81  // Should the registry be locked?
82  vtkGetMacro(Locked, int);
83 
84  // Description:
85  // Set or get the configuration directory - valid on UNIX only
86  vtkSetStringMacro(ConfigurationDirectory);
87  vtkGetStringMacro(ConfigurationDirectory);
88 
89  //BTX
90  enum {
92  ReadWrite
93  };
94 
95  enum
96  {
97  RegistryKeyValueSizeMax = 8192,
98  RegistryKeyNameSizeMax = 100
99  };
100  //ETX
101 
102 protected:
104  virtual ~vtkKWRegistryHelper();
105 
106  // Description:
107  // Should the registry be locked?
108  vtkSetClampMacro(Locked, int, 0, 1);
109  vtkBooleanMacro(Locked, int);
110 
111 
112  // Description:
113  // Read a value from the registry.
114  virtual int ReadValueInternal(const char *key, char *value) = 0;
115 
116  // Description:
117  // Delete a key from the registry.
118  virtual int DeleteKeyInternal(const char *key) = 0;
119 
120  // Description:
121  // Delete a value from a given key.
122  virtual int DeleteValueInternal(const char *key) = 0;
123 
124  // Description:
125  // Set value in a given key.
126  virtual int SetValueInternal(const char *key,
127  const char *value) = 0;
128 
129  // Description:
130  // Open the registry at toplevel/subkey.
131  virtual int OpenInternal(const char *toplevel, const char *subkey,
132  int readonly) = 0;
133 
134  // Description:
135  // Close the registry.
136  virtual int CloseInternal() = 0;
137 
138  // Description:
139  // Return true if the character is space.
140  int IsSpace(char c);
141 
142  // Description:
143  // Strip trailing and ending spaces.
144  char *Strip(char *str);
145 
146  int Opened;
147  int Changed;
148  int Empty;
149 
150 private:
151  char *TopLevel;
152  int Locked;
153  int GlobalScope;
154  char* ConfigurationDirectory;
155 
156  vtkKWRegistryHelper(const vtkKWRegistryHelper&); // Not implemented
157  void operator=(const vtkKWRegistryHelper&); // Not implemented
158 };
159 
160 #endif
161 
162