R/utils_counter.R

#' Counter Class
#'
#' @field value the current value of the counter, should not be accessed directly
#' @import methods
setRefClass(
  "Counter",
  fields = list("value" = "integer"),
  methods = list(
    "initialize" = function() {
      # called by CounterClass$new()
      .self$value <- 0L
    },
    "get" = function() {
      "increments the counter and return's the new value"
      (.self$value <- .self$value + 1L)
    }
  )
)
The-Strategy-Unit/723_mh_covid_surge_modelling documentation built on April 13, 2022, 8:52 a.m.