BiodbConfig-class {biodb} | R Documentation

## A class for storing configuration values.

### Description

This class is responsible for storing configuration. You must go through the single instance of this class to create and set and get configuration values. To get the single instance of this class, call the `getConfig()` method of class `BiodbMain`.

### Methods

`define(def)`

  Defines config properties from a structured object, normally loaded from a YAML file.

  def: The list of key definitions.

  Returned value: None.

`disable(key)`

  :

  Set a boolean key to FALSE.

  key: The name of a configuration key.

  Returned value: None.

`enable(key)`

  :

  Set a boolean key to TRUE.

  key: The name of a configuration key.

  Returned value: None.

`get(key)`

  :

  Get the value of a key.

  key: The name of a configuration key.

  Returned value: The value associated with the key.

`getAssocEnvVar(key)`

  :

  Returns the environment variable associated with this configuration key.

  key: The name of a configuration key.

  Returned value: None.

`getDefaultValue(key, as.chr = FALSE)`

  :

  Get the default value of a key.

  key: The name of a configuration key.

  as.chr: If set to TRUE, returns the value as character.

  Returned value: The default value for that key.

`getDescription(key)`

  :

  Get the description of a key.

  key: The name of a configuration key.

  Returned value: The description of the key as a character value.

`getKeys(deprecated = FALSE)`

  :

  Get the list of available keys.

  deprecated: If set to TRUE returns also the deprecated keys.

  Returned value: A character vector containing the config key names.

`getTitle(key)`

  :

  Get the title of a key.

  key: The name of a configuration key.

  Returned value: The title of the key as a character value.

`hasKey(key)`

  :

  Test if a key exists.

  key: The name of a configuration key.

  Returned value: TRUE if a key with this name exists, FALSE otherwise.

`isDefined(key, fail = TRUE)`

  :

  Test if a key is defined (i.e.: if a value exists for this key).

  key: The name of a configuration key.

  fail: If set to TRUE and the configuration key does not exist, then an error will be raised.

  Returned value: TRUE if the key has a value, FALSE otherwise.

`isEnabled(key)`

  :

  Test if a boolean key is set to TRUE. This method will raise an error if the key is not a boolean key.

  key: The name of a configuration key.

  Returned value: TRUE if the boolean key has a value set to TRUE, FALSE otherwise.

`listKeys()`

  :

  Get the full list of keys as a data frame.

  Returned value: A data frame containing keys, titles, types, and default values.

`reset(key = NULL)`

  :

  Reset the value of a key.

  key: The name of a configuration key. If NULL, all keys will be reset.

  Returned value: None.

`set(key, value)`

  :

  Set the value of a key.

  key: The name of a configuration key.

  value: A value to associate with the key.

  Returned value: None.

### See Also

`BiodbMain`.

### Examples

    # Create an instance with default settings:
    mybiodb <- biodb::newInst()

    # Get the config instance:
    config <- mybiodb$getConfig()

    # Print all available keys
    config$getKeys()

    # Get a configuration value:
    value <- config$get('cache.directory')

    # Set a configuration value:
    config$set('dwnld.timeout', 600)

    # For boolean values, you can use boolean methods:
    config$get('offline')
    config$enable('offline')    # set to TRUE
    config$disable('offline')   # set to FALSE
    config$isEnabled('offline')

    # Terminate instance.
    mybiodb$terminate()

[Package biodb version 1.0.4 Index]