Mercurial > repos > prog > lcmsmatching
view BiodbObject.R @ 5:fb9c0409d85c draft
planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
author | prog |
---|---|
date | Wed, 19 Apr 2017 10:00:05 -0400 |
parents | 20d69a062da3 |
children |
line wrap: on
line source
########################## # CLASS DECLARATION {{{1 # ########################## BiodbObject <- methods::setRefClass("BiodbObject", fields = list( .observers = "ANY" )) ######################## # ABSTRACT METHOD {{{1 # ######################## BiodbObject$methods( .abstract.method = function() { class <- class(.self) method <- sys.call(length(sys.calls()) - 1) method <- sub('^[^$]*\\$([^(]*)\\(.*$', '\\1()', method) stop(paste("Method", method, "is not implemented in", class, "class.")) }) ###################### # ADD OBSERVERS {{{1 # ###################### BiodbObject$methods( addObservers = function(obs) { # Check types of observers if ( ( ! is.list(obs) && ! inherits(obs, "BiodbObserver")) || (is.list(obs) && any( ! vapply(obs, function(o) inherits(o, "BiodbObserver"), FUN.VALUE = TRUE)))) stop("Observers must inherit from BiodbObserver class.") # Add observers to current list .observers <<- if (is.null(.self$.observers)) c(obs) else c(.self$.observers, obs) })