|
| 1 | +# |
| 2 | +# Copyright (c) TileDB Inc. under the MIT License |
| 3 | +# |
| 4 | + |
| 5 | +#' An S4 class for a TileDB Profile object |
| 6 | +#' |
| 7 | +#' @slot ptr An external pointer to the underlying implementation |
| 8 | +#' @exportClass tiledb_profile |
| 9 | +setClass("tiledb_profile", |
| 10 | + slots = list(ptr = "externalptr") |
| 11 | +) |
| 12 | + |
| 13 | +setMethod( |
| 14 | + "raw_dump", |
| 15 | + signature(object = "tiledb_profile"), |
| 16 | + definition = function(object) libtiledb_profile_dump(object@ptr) |
| 17 | +) |
| 18 | + |
| 19 | +#' Create a 'tiledb_profile' object |
| 20 | +#' |
| 21 | +#' @param name (optional) Name for the profile. |
| 22 | +#' @param dir (optional) Directory to create the profile in. |
| 23 | +#' @return 'tiledb_profile' object |
| 24 | +#' @export tiledb_profile |
| 25 | +tiledb_profile <- function(name = NULL, dir = NULL) { |
| 26 | + stopifnot(`The 'name' for the profile must be null or a character type` = is.null(name) || is.character(name)) |
| 27 | + stopifnot(`The 'dir' for the profile must be null or a character type` = is.null(name) || is.character(name)) |
| 28 | + ptr <- libtiledb_profile_new(name, dir) |
| 29 | + profile <- new("tiledb_profile", ptr = ptr) |
| 30 | + invisible(profile) |
| 31 | +} |
| 32 | + |
| 33 | + |
| 34 | +tiledb_profile_load <- function(name = NULL, dir = NULL) { |
| 35 | + stopifnot(`The 'name' for the profile must be null or a character type` = is.null(name) || is.character(name)) |
| 36 | + stopifnot(`The 'dir' for the profile must be null or a character type` = is.null(name) || is.character(name)) |
| 37 | + ptr <- libtiledb_profile_load(name, dir) |
| 38 | + profile <- new("tiledb_profile", ptr = ptr) |
| 39 | + invisible(profile) |
| 40 | +} |
| 41 | + |
| 42 | +tiledb_profile_remove <- function(name = NULL, dir = NULL) { |
| 43 | + stopifnot(`The 'name' for the profile must be null or a character type` = is.null(name) || is.character(name)) |
| 44 | + stopifnot(`The 'dir' for the profile must be null or a character type` = is.null(name) || is.character(name)) |
| 45 | + libtiledb_profile_remove(name, dir) |
| 46 | + return() |
| 47 | +} |
| 48 | + |
| 49 | +tiledb_profile_name <- function(profile) { |
| 50 | + stopifnot(`The 'profile' argument must be a tiledb_profile object` = is(profile, "tiledb_profile")) |
| 51 | + name <- libtiledb_profile_name(profile@ptr) |
| 52 | + return(name) |
| 53 | +} |
| 54 | + |
| 55 | +tiledb_profile_dir <- function(profile) { |
| 56 | + stopifnot(`The 'profile' argument must be a tiledb_profile object` = is(profile, "tiledb_profile")) |
| 57 | + dir <- libtiledb_profile_dir(profile@ptr) |
| 58 | + return(dir) |
| 59 | +} |
| 60 | + |
| 61 | +tiledb_profile_set_param <- function(profile, param, value) { |
| 62 | + stopifnot(`The 'profile' argument must be a tiledb_profile object` = is(profile, "tiledb_profile")) |
| 63 | + stopifnot(`The 'param' arugment must have character type` = is.character(param)) |
| 64 | + stopifnot(`The 'value' arugment must have character type` = is.character(value)) |
| 65 | + libtiledb_profile_set_param(profile@ptr, param, value) |
| 66 | + return() |
| 67 | +} |
| 68 | + |
| 69 | +tiledb_profile_get_param <- function(profile, param) { |
| 70 | + stopifnot(`The 'profile' argument must be a tiledb_profile object` = is(profile, "tiledb_profile")) |
| 71 | + stopifnot(`The 'param' arugment must have character type` = is.character(param)) |
| 72 | + value <- libtiledb_profile_get_param(profile@ptr, param) |
| 73 | + return(value) |
| 74 | +} |
| 75 | + |
| 76 | +tiledb_profile_save <- function(profile) { |
| 77 | + stopifnot(`The 'profile' argument must be a tiledb_profile object` = is(profile, "tiledb_profile")) |
| 78 | + libtiledb_profile_save(profile) |
| 79 | + return() |
| 80 | +} |
0 commit comments