COVISE Core
|
#include <coConfig.h>
Public Types | |
enum | DebugLevel { DebugOff = 0x00, DebugGetSets = 0x01, DebugAll = 0xFF } |
Public Member Functions | |
coConfigEntryStringList | getScopeList (const QString §ion=0, const QString &variableName=0) const |
coConfigEntryStringList | getVariableList (const QString §ion=0) const |
coConfigEntryString | getValue (const QString &variable, const QString §ion, const QString &defaultValue) const |
coConfigEntryString | getValue (const QString &variable, const QString §ion) const |
coConfigEntryString | getValue (const QString &simpleVariable) const |
const char * | getEntry (const char *simpleVariable) const |
coConfigFloat | getFloat (const QString &variable, const QString §ion, float defaultValue) const |
Get a float value. More... | |
coConfigFloat | getFloat (const QString &simpleVariable, float defaultValue) const |
Get a float value. More... | |
coConfigFloat | getFloat (const QString &variable, const QString §ion) const |
Get a float value. More... | |
coConfigFloat | getFloat (const QString &simpleVariable) const |
Get a float value. More... | |
coConfigInt | getInt (const QString &variable, const QString §ion, int defaultValue) const |
coConfigInt | getInt (const QString &simpleVariable, int defaultValue) const |
coConfigInt | getInt (const QString &variable, const QString §ion) const |
coConfigInt | getInt (const QString &simpleVariable) const |
coConfigLong | getLong (const QString &variable, const QString §ion, long defaultValue) const |
coConfigLong | getLong (const QString &simpleVariable, long defaultValue) const |
coConfigLong | getLong (const QString &variable, const QString §ion) const |
coConfigLong | getLong (const QString &simpleVariable) const |
coConfigBool | getBool (const QString &variable, const QString §ion, bool defaultValue) const |
coConfigBool | getBool (const QString &simpleVariable, bool defaultValue) const |
coConfigBool | getBool (const QString &variable, const QString §ion) const |
coConfigBool | getBool (const QString &variable, const char *section) const |
coConfigBool | getBool (const QString &simpleVariable) const |
coConfigString | getString (const QString &variable, const QString §ion, const QString &defaultValue) const |
coConfigString | getString (const QString &simpleVariable) const |
bool | isOn (const QString &variable, const QString §ion, bool defaultValue) const |
Checks if a variable in the configuration is set to "on". More... | |
bool | isOn (const QString &variable, const QString §ion) const |
Checks if a variable in the configuration is set to "on". More... | |
bool | isOn (const QString &variable, const char *section) const |
bool | isOn (const QString &simpleVariable, bool defaultValue) const |
Checks if a variable in the configuration is set to "on". More... | |
bool | isOn (const QString &simpleVariable) const |
Checks if a variable in the configuration is set to "on". More... | |
void | setValueForHost (const QString &variable, const QString &value, const QString §ion, const QString &targetHost, bool move=false, const QString &config=0, const QString &configGroup=0) |
Set a value for a variable for a host. More... | |
void | setValueInConfig (const QString &variable, const QString &value, const QString §ion, const QString &configGroup, const QString &config="config", bool move=false) |
Set a value for a variable in the designated config group. More... | |
void | setValue (const QString &variable, const QString &value, const QString §ion, const QString &config=0, bool move=false) |
Set a value for a variable. More... | |
void | setValue (const QString &simpleVariable, const QString &value) |
Set a value for a simple variable in the default configuration. More... | |
bool | deleteValueForHost (const QString &variable, const QString §ion, const QString &targetHost, const QString &config=0, const QString &configGroup=0) |
Delete a value in the designated configuration group for a host only. More... | |
bool | deleteValueInConfig (const QString &variable, const QString §ion, const QString &configGroup, const QString &config="config") |
Delete a value in the designated configuration group. More... | |
bool | deleteValue (const QString &variable, const QString §ion, const QString &config=0) |
Delete a value from the configuration. More... | |
bool | deleteValue (const QString &simpleVariable) |
Delete a value from the configuration. More... | |
bool | deleteSectionForHost (const QString §ion, const QString &targetHost, const QString &config=0, const QString &configGroup=0) |
Delete a section for a host in the configuration. More... | |
bool | deleteSectionInConfig (const QString §ion, const QString &configGroup, const QString &config="config") |
Delete a section in the configuration. More... | |
bool | deleteSection (const QString §ion, const QString &config=0) |
Delete a section in the configuration. More... | |
const QStringList & | getHostnameList () const |
const QString & | getActiveHost () const |
bool | setActiveHost (const QString &host) |
const QString & | getActiveCluster () const |
bool | setActiveCluster (const QString &master) |
virtual void | addConfig (const QString &filename, const QString &name, bool create=false) |
Load a configuration from a file and add it to the global configuration. More... | |
virtual void | addConfig (coConfigGroup *group) |
Add a configuration group for access through the global config. More... | |
virtual void | removeConfig (const QString &name) |
Removes a configuration group from the global coConfig. More... | |
void | reload () |
bool | save () const |
Save all configurations to disk. More... | |
bool | save (const QString &filename) const |
Exports all configurations into a single file. More... | |
void | setAdminMode (bool mode) |
Turn administrator mode on or off. More... | |
bool | isAdminMode () |
Is the administrator mode on or off. More... | |
Static Public Member Functions | |
static bool | isDebug () |
Check if in debug mode. More... | |
static DebugLevel | getDebugLevel () |
Get the debug level. More... | |
static void | setDebugLevel (DebugLevel level) |
static coConfig * | getInstance () |
Protected Member Functions | |
coConfig () | |
~coConfig () | |
void | load () |
Protected Attributes | |
bool | isGlobalConfig |
Private Attributes | |
QString | activeHostname |
QStringList | hostnames |
QString | activeCluster |
QStringList | masternames |
QHash< QString, coConfigGroup * > | configGroups |
bool | adminMode |
Static Private Attributes | |
static coConfig * | config = 0 |
static DebugLevel | debugLevel = coConfig::DebugOff |
|
protected |
|
protected |
|
virtual |
Load a configuration from a file and add it to the global configuration.
filename | The file to load. The name is searched for in the local/global config dir and COVISE_PATH |
name | Name of the new configuration. Has to be unique. |
create | If the file does not exist, create a new, empty configuration. |
|
virtual |
Add a configuration group for access through the global config.
group | The group to add. The name of the group has to be unique. |
bool coConfig::deleteSection | ( | const QString & | section, |
const QString & | config = 0 |
||
) |
Delete a section in the configuration.
section | Section to delete. |
config | Name of the configuration to delete this section from. |
bool coConfig::deleteSectionForHost | ( | const QString & | section, |
const QString & | targetHost, | ||
const QString & | config = 0 , |
||
const QString & | configGroup = 0 |
||
) |
Delete a section for a host in the configuration.
section | Section to delete. |
targetHost | The hostname of the host to be affected. |
configGroup | Name of the configuration group to delete from. |
config | Name of the configuration to delete this section from. |
bool coConfig::deleteSectionInConfig | ( | const QString & | section, |
const QString & | configGroup, | ||
const QString & | config = "config" |
||
) |
Delete a section in the configuration.
section | Section to delete. |
configGroup | Name of the configuration group to delete from. |
config | Name of the configuration to delete this section from. |
bool coConfig::deleteValue | ( | const QString & | variable, |
const QString & | section, | ||
const QString & | config = 0 |
||
) |
Delete a value from the configuration.
variable | Variable to delete. |
section | Section, where the variable to delete is found. |
config | Configuration where to delete from. |
bool coConfig::deleteValue | ( | const QString & | simpleVariable | ) |
Delete a value from the configuration.
simpleVariable | Variable to delete. This method deletes the variable "value" |
bool coConfig::deleteValueForHost | ( | const QString & | variable, |
const QString & | section, | ||
const QString & | targetHost, | ||
const QString & | config = 0 , |
||
const QString & | configGroup = 0 |
||
) |
Delete a value in the designated configuration group for a host only.
variable | Variable to delete. |
section | Section, where the variable to delete is found. |
targetHost | The hostname of the host to be affected. |
config | Configuration where to delete from. |
configGroup | Name of the configuration group to delete from. |
bool coConfig::deleteValueInConfig | ( | const QString & | variable, |
const QString & | section, | ||
const QString & | configGroup, | ||
const QString & | config = "config" |
||
) |
Delete a value in the designated configuration group.
variable | Variable to delete. |
section | Section, where the variable to delete is found. |
configGroup | Name of the configuration group to delete from. |
config | Configuration where to delete from. |
const QString & coConfig::getActiveCluster | ( | ) | const |
const QString & coConfig::getActiveHost | ( | ) | const |
coConfigBool coConfig::getBool | ( | const QString & | variable, |
const QString & | section, | ||
bool | defaultValue | ||
) | const |
coConfigBool coConfig::getBool | ( | const QString & | simpleVariable, |
bool | defaultValue | ||
) | const |
coConfigBool coConfig::getBool | ( | const QString & | variable, |
const QString & | section | ||
) | const |
coConfigBool coConfig::getBool | ( | const QString & | variable, |
const char * | section | ||
) | const |
coConfigBool coConfig::getBool | ( | const QString & | simpleVariable | ) | const |
|
static |
Get the debug level.
The debug level is set via the environment variable COCONFIG_DEBUG. Allowed values are:
const char * coConfig::getEntry | ( | const char * | simpleVariable | ) | const |
coConfigFloat coConfig::getFloat | ( | const QString & | variable, |
const QString & | section, | ||
float | defaultValue | ||
) | const |
Get a float value.
If the variable is not found, defaultValue is returned instead.
variable | Variable to check. |
section | Section of the variable. |
defaultValue | Default value to return. |
coConfigFloat coConfig::getFloat | ( | const QString & | simpleVariable, |
float | defaultValue | ||
) | const |
Get a float value.
If the variable is not found, defaultValue is returned instead. Shortcut for getFloat("value", section, defaultValue)
simpleVariable | Section of the variable "value". |
defaultValue | Default value to return. |
coConfigFloat coConfig::getFloat | ( | const QString & | variable, |
const QString & | section | ||
) | const |
Get a float value.
variable | Variable to get. |
section | Section of the variable. |
coConfigFloat coConfig::getFloat | ( | const QString & | simpleVariable | ) | const |
Get a float value.
Shortcut for getFloat("value", section)
simpleVariable | Section of the variable "value". |
const QStringList & coConfig::getHostnameList | ( | ) | const |
|
inlinestatic |
coConfigInt coConfig::getInt | ( | const QString & | variable, |
const QString & | section, | ||
int | defaultValue | ||
) | const |
coConfigInt coConfig::getInt | ( | const QString & | simpleVariable, |
int | defaultValue | ||
) | const |
coConfigInt coConfig::getInt | ( | const QString & | variable, |
const QString & | section | ||
) | const |
coConfigInt coConfig::getInt | ( | const QString & | simpleVariable | ) | const |
coConfigLong coConfig::getLong | ( | const QString & | variable, |
const QString & | section, | ||
long | defaultValue | ||
) | const |
coConfigLong coConfig::getLong | ( | const QString & | simpleVariable, |
long | defaultValue | ||
) | const |
coConfigLong coConfig::getLong | ( | const QString & | variable, |
const QString & | section | ||
) | const |
coConfigLong coConfig::getLong | ( | const QString & | simpleVariable | ) | const |
coConfigEntryStringList coConfig::getScopeList | ( | const QString & | section = 0 , |
const QString & | variableName = 0 |
||
) | const |
coConfigString coConfig::getString | ( | const QString & | variable, |
const QString & | section, | ||
const QString & | defaultValue | ||
) | const |
coConfigString coConfig::getString | ( | const QString & | simpleVariable | ) | const |
coConfigEntryString coConfig::getValue | ( | const QString & | variable, |
const QString & | section, | ||
const QString & | defaultValue | ||
) | const |
coConfigEntryString coConfig::getValue | ( | const QString & | variable, |
const QString & | section | ||
) | const |
coConfigEntryString coConfig::getValue | ( | const QString & | simpleVariable | ) | const |
coConfigEntryStringList coConfig::getVariableList | ( | const QString & | section = 0 | ) | const |
bool coConfig::isAdminMode | ( | ) |
Is the administrator mode on or off.
If the administrative mode is on, the global configuration can be written to.
|
static |
bool coConfig::isOn | ( | const QString & | variable, |
const QString & | section, | ||
bool | defaultValue | ||
) | const |
Checks if a variable in the configuration is set to "on".
As "on" count the case insensitive values of on, true and 1.
variable | Variable to check. |
section | Section of the variable. |
defaultValue | Default value to return. |
bool coConfig::isOn | ( | const QString & | variable, |
const QString & | section | ||
) | const |
Checks if a variable in the configuration is set to "on".
As "on" count the case insensitive values of on, true and 1.
variable | Variable to check. |
section | Section of the variable. |
bool coConfig::isOn | ( | const QString & | variable, |
const char * | section | ||
) | const |
bool coConfig::isOn | ( | const QString & | simpleVariable, |
bool | defaultValue | ||
) | const |
Checks if a variable in the configuration is set to "on".
As "on" count the case insensitive values of on, true and 1. It is a shortcut for isOn("value", section, defaultValue)
simpleVariable | Section of the variable "value". |
defaultValue | Default value to return. |
bool coConfig::isOn | ( | const QString & | simpleVariable | ) | const |
Checks if a variable in the configuration is set to "on".
As "on" count the case insensitive values of on, true and 1. It is a shortcut for isOn("value", section)
simpleVariable | Section of the variable "value". |
|
protected |
void coConfig::reload | ( | ) |
|
virtual |
Removes a configuration group from the global coConfig.
name | Name of the configuration. |
bool coConfig::save | ( | ) | const |
Save all configurations to disk.
Before calling this method, all changes are just in memory.
bool coConfig::save | ( | const QString & | filename | ) | const |
Exports all configurations into a single file.
bool coConfig::setActiveCluster | ( | const QString & | master | ) |
bool coConfig::setActiveHost | ( | const QString & | host | ) |
void coConfig::setAdminMode | ( | bool | mode | ) |
Turn administrator mode on or off.
It is only possible to write to the global configuration after turning this on.
mode | New administrative mode. |
|
inlinestatic |
void coConfig::setValue | ( | const QString & | variable, |
const QString & | value, | ||
const QString & | section, | ||
const QString & | config = 0 , |
||
bool | move = false |
||
) |
Set a value for a variable.
The actual configuration used can be provided as parameter or automatically determined; in the latter case, this is the configuration the entry already resides in or config.local if it resides in the global configuration or not at all.
variable | Variable to set. |
value | Value to set to. |
section | Section of the variable to set. |
config | Configuration to set the variable in. For defaults see above |
move | Delete the value from its old location *not implemented yet* |
void coConfig::setValue | ( | const QString & | simpleVariable, |
const QString & | value | ||
) |
Set a value for a simple variable in the default configuration.
The actual configuration used is automatically determined and is the configuration the entry already resides in or config.local if it resides in the global configuration or not at all.
simpleVariable | Section of the variable to set. The variable itself is called "value" |
value | Value to set to. |
void coConfig::setValueForHost | ( | const QString & | variable, |
const QString & | value, | ||
const QString & | section, | ||
const QString & | targetHost, | ||
bool | move = false , |
||
const QString & | config = 0 , |
||
const QString & | configGroup = 0 |
||
) |
Set a value for a variable for a host.
targetHost | Host to set the value for. |
configGroup | Configuration group to set the value in. |
For other parameters, see coConfig::setValue(const QString & variable, const QString & value, const QString & section, const QString & config, bool move).
void coConfig::setValueInConfig | ( | const QString & | variable, |
const QString & | value, | ||
const QString & | section, | ||
const QString & | configGroup, | ||
const QString & | config = "config" , |
||
bool | move = false |
||
) |
Set a value for a variable in the designated config group.
configGroup | Configuration group to set the value in. |
For other parameters, see coConfig::setValue(const QString & variable, const QString & value, const QString & section, const QString & config, bool move).
|
private |
|
private |
|
private |
|
staticprivate |
|
private |
|
staticprivate |
|
private |
|
protected |
|
private |