-
Notifications
You must be signed in to change notification settings - Fork 7
/
silent.R
70 lines (65 loc) · 1.85 KB
/
silent.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Copyright (c) 2024 Apex Resource Management Solution Ltd. (ApexRMS). All rights reserved.
# MIT License
#' @include AAAClassDefinitions.R
NULL
#' Silent status of SyncroSim Session
#'
#' Checks or sets whether a SyncroSim \code{\link{Session}} is silent or not. In
#' a silent session, warnings from the console are ignored.
#'
#' @param session \code{\link{Session}} object or character (i.e. filepath to a
#' session). If \code{NULL}, \code{session()} will be used
#' @param value logical. If \code{TRUE} (default), the SyncroSim Session will be
#' silent
#'
#' @return
#' A logical: \code{TRUE} if the session is silent and \code{FALSE} otherwise.
#'
#' @examples
#' \donttest{
#' # Set up a SyncroSim Session
#' mySession <- session()
#'
#' # Check the silent status of a SyncroSim Session
#' silent(mySession)
#'
#' # Set the silent status of a SyncroSim Session
#' silent(mySession) <- FALSE
#' }
#'
#' @export
setGeneric("silent", function(session) standardGeneric("silent"))
#' @rdname silent
setMethod("silent", signature(session = "Session"), function(session) session@silent)
#' @rdname silent
setMethod("silent", signature(session = "missingOrNULLOrChar"), function(session) {
if (is(session, "character")) {
session <- .session(session)
} else {
session <- .session()
}
if ((is(session, "character")) && (is(session, SyncroSimNotFound(warn = FALSE)))) {
return(SyncroSimNotFound())
}
return(silent(session))
})
#' @rdname silent
#' @export
setGeneric("silent<-", function(session, value) standardGeneric("silent<-"))
#' @rdname silent
setReplaceMethod(
f = "silent",
signature = "character",
definition = function(session, value) {
return(session)
}
)
#' @rdname silent
setReplaceMethod(
f = "silent",
signature = "Session",
definition = function(session, value) {
session@silent <- value
return(session)
}
)