R/hooks.R

Defines functions use_read_hook use_write_hook check_object_size

use_read_hook <- function(obj) {
  check_object_size(obj)
  (attr(obj, "csmpi.hooks")$read %||% identity)(obj)
}

use_write_hook <- function(obj) {
  check_object_size(obj)
  (attr(obj, "csmpi.hooks")$read %||% identity)(obj)
}

check_object_size <- function(obj) {
  if (utils::object.size(obj) == 0) {
    warning("In csmpi package: object is of size 0, this is probably bad", call. = TRUE)
    NULL
  }
}
abelcastilloavant/csmpi documentation built on May 24, 2019, 7:21 p.m.