COVISE Core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
coConfig.h
Go to the documentation of this file.
1 /* This file is part of COVISE.
2 
3  You can use it under the terms of the GNU Lesser General Public License
4  version 2.1 or later, see lgpl-2.1.txt.
5 
6  * License: LGPL 2+ */
7 
8 #ifndef COCONFIG_H
9 #define COCONFIG_H
10 
11 #include <QHash>
12 
13 #include "coConfigBool.h"
14 #include "coConfigConstants.h"
15 #include "coConfigFloat.h"
16 #include "coConfigGroup.h"
17 #include "coConfigInt.h"
18 #include "coConfigLong.h"
19 #include "coConfigString.h"
20 #include <util/coTypes.h>
21 
22 #ifndef CO_gcc3
23 EXPORT_TEMPLATE2(template class CONFIGEXPORT QHash<QString, covise::coConfigGroup *>)
24 #endif
25 
26 namespace covise
27 {
28 
30 {
31 
32 public:
33  coConfigEntryStringList getScopeList(const QString &section = 0,
34  const QString &variableName = 0) const;
35  coConfigEntryStringList getVariableList(const QString &section = 0) const;
36 
37  coConfigEntryString getValue(const QString &variable,
38  const QString &section,
39  const QString &defaultValue) const;
40  coConfigEntryString getValue(const QString &variable,
41  const QString &section) const;
42  coConfigEntryString getValue(const QString &simpleVariable) const;
43 
44  const char *getEntry(const char *simpleVariable) const;
45 
46  coConfigFloat getFloat(const QString &variable,
47  const QString &section,
48  float defaultValue) const;
49  coConfigFloat getFloat(const QString &simpleVariable,
50  float defaultValue) const;
51  coConfigFloat getFloat(const QString &variable,
52  const QString &section) const;
53  coConfigFloat getFloat(const QString &simpleVariable) const;
54 
55  coConfigInt getInt(const QString &variable,
56  const QString &section,
57  int defaultValue) const;
58  coConfigInt getInt(const QString &simpleVariable,
59  int defaultValue) const;
60  coConfigInt getInt(const QString &variable,
61  const QString &section) const;
62  coConfigInt getInt(const QString &simpleVariable) const;
63 
64  coConfigLong getLong(const QString &variable,
65  const QString &section,
66  long defaultValue) const;
67  coConfigLong getLong(const QString &simpleVariable,
68  long defaultValue) const;
69  coConfigLong getLong(const QString &variable,
70  const QString &section) const;
71  coConfigLong getLong(const QString &simpleVariable) const;
72 
73  coConfigBool getBool(const QString &variable,
74  const QString &section,
75  bool defaultValue) const;
76  coConfigBool getBool(const QString &simpleVariable,
77  bool defaultValue) const;
78  coConfigBool getBool(const QString &variable,
79  const QString &section) const;
80  coConfigBool getBool(const QString &variable,
81  const char *section) const;
82  coConfigBool getBool(const QString &simpleVariable) const;
83 
84  coConfigString getString(const QString &variable,
85  const QString &section,
86  const QString &defaultValue) const;
87  coConfigString getString(const QString &simpleVariable) const;
88 
89  bool isOn(const QString &variable, const QString &section, bool defaultValue) const;
90  bool isOn(const QString &variable, const QString &section) const;
91  bool isOn(const QString &variable, const char *section) const;
92  bool isOn(const QString &simpleVariable, bool defaultValue) const;
93  bool isOn(const QString &simpleVariable) const;
94 
95  void setValueForHost(const QString &variable, const QString &value,
96  const QString &section,
97  const QString &targetHost, bool move = false,
98  const QString &config = 0, const QString &configGroup = 0);
99 
100  void setValueInConfig(const QString &variable, const QString &value,
101  const QString &section,
102  const QString &configGroup,
103  const QString &config = "config",
104  bool move = false);
105 
106  void setValue(const QString &variable, const QString &value,
107  const QString &section,
108  const QString &config = 0,
109  bool move = false);
110 
111  void setValue(const QString &simpleVariable, const QString &value);
112 
113  bool deleteValueForHost(const QString &variable, const QString &section,
114  const QString &targetHost,
115  const QString &config = 0, const QString &configGroup = 0);
116 
117  bool deleteValueInConfig(const QString &variable, const QString &section,
118  const QString &configGroup, const QString &config = "config");
119 
120  bool deleteValue(const QString &variable, const QString &section, const QString &config = 0);
121 
122  bool deleteValue(const QString &simpleVariable);
123 
124  bool deleteSectionForHost(const QString &section, const QString &targetHost,
125  const QString &config = 0, const QString &configGroup = 0);
126 
127  bool deleteSectionInConfig(const QString &section, const QString &configGroup, const QString &config = "config");
128 
129  bool deleteSection(const QString &section, const QString &config = 0);
130 
131  const QStringList &getHostnameList() const;
132  const QString &getActiveHost() const;
133  bool setActiveHost(const QString &host);
134 
135  virtual void addConfig(const QString &filename, const QString &name, bool create = false);
136  virtual void addConfig(coConfigGroup *group);
137  virtual void removeConfig(const QString &name);
138 
139  //void destroyOwnInstance();
140  void reload();
141 
142  bool save() const;
143  bool save(const QString &filename) const;
144 
145  void setAdminMode(bool mode);
146  bool isAdminMode();
147 
149  {
150  DebugOff = 0x00,
151  DebugGetSets = 0x01,
152  DebugAll = 0xFF
153  };
154 
155  static bool isDebug();
156  static DebugLevel getDebugLevel();
158  {
159  debugLevel = level;
160  }
161 
162 protected:
163  coConfig();
164  ~coConfig();
165 
166  void load();
167 
168 public: /*static*/
170  {
171  if (config)
172  {
173  return config;
174  }
175  config = new coConfig();
176  config->isGlobalConfig = true;
177  return config;
178  }
179 
180  //static coConfig *getOwnInstance(const QString & filename = 0);
181 
182 protected:
184 
185 private:
186  static coConfig *config;
187  QString activeHostname;
188  QStringList hostnames;
189 
190  QHash<QString, coConfigGroup *> configGroups;
191 
192  bool adminMode;
194 };
195 }
196 #include "coConfigValue.inl"
197 #endif
Definition: coConfigGroup.h:25
GLuint const GLchar * name
Definition: khronos-glext.h:6722
static void setDebugLevel(DebugLevel level)
Definition: coConfig.h:157
static coConfig * config
Definition: coConfig.h:186
DebugLevel
Definition: coConfig.h:148
#define CONFIGEXPORT
Definition: coExport.h:337
Definition: coConfigBool.h:21
bool adminMode
Definition: coConfig.h:192
Definition: coConfigFloat.h:21
static coConfig * getInstance()
Definition: coConfig.h:169
#define EXPORT_TEMPLATE2(x, y)
Definition: coExport.h:34
GLenum mode
Definition: khronos-glext.h:6908
Definition: coConfigInt.h:21
Definition: coConfig.h:29
static DebugLevel debugLevel
Definition: coConfig.h:193
QHash< QString, coConfigGroup * > configGroups
Definition: coConfig.h:190
Definition: coConfigString.h:18
Definition: coConfigEntryString.h:23
QStringList hostnames
Definition: coConfig.h:188
GLboolean GLuint group
Definition: khronos-glext.h:12389
GLenum GLenum variable
Definition: khronos-glext.h:9990
Definition: coConfigLong.h:21
GLint level
Definition: khronos-glext.h:6344
QString activeHostname
Definition: coConfig.h:187
Definition: coConfigEntryString.h:53
GLsizei const GLfloat * value
Definition: khronos-glext.h:6760
bool isGlobalConfig
Definition: coConfig.h:183