Skip to contents

The DiseasyBaseModule module implements common functionality that all modules have available. Most notably, the base module facilitates:

  • logging: A lgr logger is configured when making any module that inherits from the base module. This logger is stored in private$lg.

  • hashing: The active binding self$hash hashes the values of public fields to provide a way to uniquely identify the configuration of modules. Care must be taken to ensure that information that makes modules distinct are also stored in public fields. That is, if an important property is stored only as a private field, the hash will not change. Module-specific tests should be written to ensure hash changes as expected.

  • caching: The methods private$cache(), private$get_hash() private$is_cached(hash) implements a simple caching system whereby the results of method calls can be cached to improve the performance of the modules.

  • module loading: Modules instances are sometimes loaded into other modules. The private$load_module(module) method provides the functionality to handle this loading (including cloning of the module and passing of the new module to already-loaded modules)

Value

A new instance of the DiseasyBaseModule

R6 class.

See also

Active bindings

hash

(character)
Computes a hash value for the module. Useful for logging and caching. Read only.

Methods


Method new()

Creates a new instance of the DiseasyBaseModule R6 class. This module is typically not constructed directly but rather through derived classes.

Usage

DiseasyBaseModule$new(
  moduleowner = class(self)[1],
  logging = diseasyoption("logging", self)
)

Arguments

moduleowner

(character)
The name of the moduleowner. Used when logging.

logging

(boolean)
Should logging be enabled?


Method set_moduleowner()

Changes the "ownership" of the module. Used when logging.

Usage

DiseasyBaseModule$set_moduleowner(moduleowner)

Arguments

moduleowner

(character)
The name of the moduleowner.

Returns

NULL


Method load_module()

Loads a copy of the provided module into the module.

Usage

DiseasyBaseModule$load_module(module, clone = TRUE)

Arguments

module

(R6::R6Class instance)
This instance is cloned to the field with the same name as the class of the module

clone

(boolean)
Toggle whether or not the module should be cloned when loading. Default TRUE.

Details

The methods allows the setting of the internal module instances after the DiseasyBaseModule instance is created.

Returns

NULL


Method finalize()

Handles the clean-up of the class

Usage

DiseasyBaseModule$finalize()


Method clone()

The objects of this class are cloneable with this method.

Usage

DiseasyBaseModule$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

  # Normally, you would not want to create this module directly, but it is possible.
  base_module <- DiseasyBaseModule$new()

  rm(base_module)