comparison MsDbChecker.R @ 0:e66bb061af06 draft

planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
author prog
date Tue, 12 Jul 2016 12:02:37 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e66bb061af06
1 if ( ! exists('MsDbChecker')) { # Do not load again if already loaded
2
3 source('MsDbObserver.R')
4
5 #####################
6 # CLASS DECLARATION #
7 #####################
8
9 MsDbChecker <- setRefClass("MsDbChecker", contains = 'MsDbObserver', fields = list(.fail = 'logical'))
10
11 ###############
12 # CONSTRUCTOR #
13 ###############
14
15 # fail If set to TRUE, will fail (i.e.: quit application with a status set to 1) on error.
16 MsDbChecker$methods( initialize = function(fail = FALSE, ...) {
17
18 .fail <<- if ( ! is.null(fail) && ! is.na(fail)) fail else FALSE
19
20 callSuper(...) # calls super-class initializer with remaining parameters
21 })
22
23 ###########
24 # WARNING #
25 ###########
26
27 MsDbChecker$methods( warning = function(msg) {
28 write(paste('WARNING: ', msg), stderr())
29 })
30
31 #########
32 # ERROR #
33 #########
34
35 MsDbChecker$methods( error = function(msg) {
36
37 write(paste('ERROR:', msg), stderr())
38
39 # Fail
40 if (.self$.fail)
41 quit(status = 1)
42 })
43
44 } # end of load safe guard