COVISE Core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
coConfigRoot.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 COCONFIGROOT_H
9 #define COCONFIGROOT_H
10 
11 #include <QFile>
12 #include <QHash>
13 #include <QSet>
14 
15 #include <config/coConfigEntry.h>
17 
18 #include <util/coTypes.h>
19 
20 #ifndef CO_gcc3
21 EXPORT_TEMPLATE2(template class CONFIGEXPORT QHash<QString, covise::coConfigEntry *>)
22 #endif
23 
24 namespace covise
25 {
26 
27 class coConfigGroup;
28 
30 {
31  friend class coConfigXercesRoot;
32 
33 public:
34  static coConfigRoot *createNew(const QString &name, const QString &filename, bool create = false, coConfigGroup *group = NULL);
35 
36  coConfigRoot(const QString &name, const QString &filename, bool create = false, coConfigGroup *group = NULL);
37  virtual ~coConfigRoot();
38 
39  virtual coConfigEntryStringList getScopeList(const QString &section = 0,
40  const QString &variableName = 0) const;
41  virtual coConfigEntryStringList getVariableList(const QString &section = 0) const;
42 
43  virtual coConfigEntryString getValue(const QString &variable,
44  const QString &section,
45  const QString &defaultValue) const;
46  virtual coConfigEntryString getValue(const QString &variable,
47  const QString &section) const;
48  virtual coConfigEntryString getValue(const QString &simpleVariable) const;
49 
50  virtual const char *getEntry(const char *simpleVariable) const;
51 
52  virtual bool isOn(const QString &variable, const QString &section, bool defaultValue) const;
53  virtual bool isOn(const QString &variable, const QString &section) const;
54  virtual bool isOn(const QString &simpleVariable, bool defaultValue) const;
55  virtual bool isOn(const QString &simpleVariable) const;
56 
57  virtual void setValue(const QString &variable, const QString &value,
58  const QString &section,
59  const QString &targetHost = 0, bool move = false);
60 
61  virtual bool deleteValue(const QString &variable, const QString &section,
62  const QString &targetHost = 0);
63 
64  virtual bool deleteSection(const QString &section, const QString &targetHost = 0);
65 
66  virtual QStringList getHostnameList() const;
67  virtual QString getActiveHost() const;
68  virtual bool setActiveHost(const QString &host);
69 
70  virtual const QString &getConfigName() const;
71 
72  virtual void reload();
73  virtual bool save(const QString &filename = QString::null) const;
74 
75  void setGroup(coConfigGroup *group);
76 
77  void setReadOnly(bool ro);
78  bool isReadOnly() const;
79 
80  QStringList getHosts();
81  coConfigEntry *getConfigForHost(const QString &hostname);
83  {
84  return this->globalConfig;
85  }
86 
87  // QHash<QString, coConfigEntry*> getEntryList();
88 
89  virtual coConfigRoot *clone() const = 0;
90  virtual void merge(const coConfigRoot *with) = 0;
91 
92 protected:
93  virtual void load(bool create = false) = 0;
94 
95  void init();
96 
97  QString findConfigFile(const QString &filename, bool preferGlobal = false);
98 
99  void findLocalConfig(const QString &filename, QFile &target);
100  void findGlobalConfig(const QString &filename, QFile &target);
101 
102  void clear();
103 
105 
106  QString filename;
107  QString activeHostname;
108  QStringList hostnames;
109 
110  QString configName;
111 
114 
115  QHash<QString, coConfigEntry *> hostConfigs;
116 
117  virtual void createGlobalConfig() = 0;
118  virtual void createHostConfig(const QString &hostname) = 0;
119 
120  bool create;
121  bool readOnly;
122 
123  QSet<QString> included;
124 };
125 }
126 #endif
bool readOnly
Definition: coConfigRoot.h:121
QSet< QString > included
Definition: coConfigRoot.h:123
Definition: coConfigGroup.h:25
GLuint const GLchar * name
Definition: khronos-glext.h:6722
#define CONFIGEXPORT
Definition: coExport.h:337
Definition: coConfigEntry.h:33
coConfigEntry * getGlobalConfig()
Definition: coConfigRoot.h:82
#define NULL
Definition: covise_list.h:22
bool create
Definition: coConfigRoot.h:120
#define EXPORT_TEMPLATE2(x, y)
Definition: coExport.h:34
coConfigGroup * group
Definition: coConfigRoot.h:104
Definition: coConfigRoot.h:29
coConfigEntry * hostConfig
Definition: coConfigRoot.h:113
QStringList hostnames
Definition: coConfigRoot.h:108
QHash< QString, coConfigEntry * > hostConfigs
Definition: coConfigRoot.h:115
QString activeHostname
Definition: coConfigRoot.h:107
Definition: coConfigEntryString.h:23
Definition: coConfigXercesRoot.h:35
GLenum target
Definition: khronos-glext.h:8033
QString configName
Definition: coConfigRoot.h:110
coConfigEntry * globalConfig
Definition: coConfigRoot.h:112
GLboolean GLuint group
Definition: khronos-glext.h:12389
GLenum GLenum variable
Definition: khronos-glext.h:9990
Definition: coConfigEntryString.h:53
GLsizei const GLfloat * value
Definition: khronos-glext.h:6760
QString filename
Definition: coConfigRoot.h:106