BiodbConfig | R Documentation |
A class for storing configuration values.
A class for storing configuration values.
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
.
new()
New instance initializer. No BiodbConfig object must not be created directly. Instead, access the config instance through the BiodbMain instance using the getConfig() method.
BiodbConfig$new(parent)
parent
The BiodbMain instance.
Nothing.
getKeys()
Get the list of available keys.
BiodbConfig$getKeys(deprecated = FALSE)
deprecated
If set to TRUE returns also the deprecated keys.
A character vector containing the config key names.
getTitle()
Get the title of a key.
BiodbConfig$getTitle(key)
key
The name of a configuration key.
The title of the key as a character value.
getDescription()
Get the description of a key.
BiodbConfig$getDescription(key)
key
The name of a configuration key.
The description of the key as a character value.
getDefaultValue()
Get the default value of a key.
BiodbConfig$getDefaultValue(key, as.chr = FALSE)
key
The name of a configuration key.
as.chr
If set to TRUE, returns the value as character.
The default value for that key.
hasKey()
Test if a key exists.
BiodbConfig$hasKey(key)
key
The name of a configuration key.
TRUE if a key with this name exists, FALSE otherwise.
isDefined()
Test if a key is defined (i.e.: if a value exists for this key).
BiodbConfig$isDefined(key, fail = TRUE)
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.
TRUE if the key has a value, FALSE otherwise.
isEnabled()
Test if a boolean key is set to TRUE. This method will raise an error if the key is not a boolean key.
BiodbConfig$isEnabled(key)
key
The name of a configuration key.
TRUE if the boolean key has a value set to TRUE, FALSE otherwise.
get()
Get the value of a key.
BiodbConfig$get(key)
key
The name of a configuration key.
The value associated with the key.
set()
Set the value of a key.
BiodbConfig$set(key, value)
key
The name of a configuration key.
value
A value to associate with the key.
Nothing.
reset()
Reset the value of a key.
BiodbConfig$reset(key = NULL)
key
The name of a configuration key. If NULL, all keys will be reset.
Nothing.
enable()
Set a boolean key to TRUE.
BiodbConfig$enable(key)
key
The name of a configuration key.
Nothing.
disable()
Set a boolean key to FALSE.
BiodbConfig$disable(key)
key
The name of a configuration key.
Nothing.
print()
Print list of configuration keys and their values.
BiodbConfig$print()
Nothing.
listKeys()
Get the full list of keys as a data frame.
BiodbConfig$listKeys()
A data frame containing keys, titles, types, and default values.
getAssocEnvVar()
Returns the environment variable associated with this configuration key.
BiodbConfig$getAssocEnvVar(key)
key
The name of a configuration key.
The environment variable's value.
define()
Defines config properties from a structured object, normally loaded from a YAML file.
BiodbConfig$define(def)
def
The list of key definitions.
Nothing.
notifyNewObservers()
Called by BiodbMain when a new observer is registered.
BiodbConfig$notifyNewObservers(obs)
obs
The new observers registered by the BiodbMain instance.
Nothing.
terminate()
Terminates the instance. This method will be called automatically by the BiodbMain instance when you call
BiodbConfig$terminate()
BiodbMain
:terminate().
Nothing.
clone()
The objects of this class are cloneable with this method.
BiodbConfig$clone(deep = FALSE)
deep
Whether to make a deep clone.
BiodbMain
.
# 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()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.