R/Compartment.R

setClass("Compartment",
         representation(id = "character", name = "character", 
                        spatialDimensions = "integer", size = "numeric",
                        units = "character", outside = "character",
                        constant = "logical"), 
         prototype = list(spatialDimensions = as.integer(3), constant = TRUE), 
         contains = "SBase")

setMethod("describe", "Compartment",
          function(object) {
            desc <- id(object)
            if (length(name(object)))
              paste(desc, " (", name(object), ")", sep = "")
            desc
          })
 
setMethod("id", "Compartment", function(object) object@id)

setMethod("name", "Compartment", function(object) object@name)

 setGeneric("spatialDimensions", function(object) standardGeneric("spatialDimensions"))
setMethod("spatialDimensions", "Compartment", function(object) object@spatialDimensions)

 setGeneric("size", function(object) standardGeneric("size"))
setMethod("size", "Compartment", function(object) object@size)

 setGeneric("units", function(x) standardGeneric("units"))
setMethod("units", "Compartment", function(x) x@units)

 setGeneric("outside", function(object) standardGeneric("outside"))
setMethod("outside", "Compartment", function(object) object@outside)

 setGeneric("constant", function(object) standardGeneric("constant"))
setMethod("constant", "Compartment", function(object) object@constant)

 
 
setReplaceMethod("id", "Compartment", function(object, value) {
  object@id <- value
  object
})

setReplaceMethod("name", "Compartment", function(object, value) {
  object@name <- value
  object
})

 setGeneric("spatialDimensions<-", function(object, value) standardGeneric("spatialDimensions<-"))
setReplaceMethod("spatialDimensions", "Compartment", function(object, value) {
  value <- as.integer(value)
  if (!(value %in% c(0:3)))
    stop("spatialDimensions must be a integer within [0,3]")
  object@spatialDimensions <- value
  object
})

 setGeneric("size<-", function(object, value) standardGeneric("size<-"))
setReplaceMethod("size", "Compartment", function(object, value) {
  object@size <- value
  object
})

 setGeneric("units<-", function(x, value) standardGeneric("units<-"))
setReplaceMethod("units", "Compartment", function(x, value) {
  x@units <- value
  x
})

 setGeneric("outside<-", function(object, value) standardGeneric("outside<-"))
setReplaceMethod("outside", "Compartment", function(object, value) {
  object@outside <- value
  object
})

 setGeneric("constant<-", function(object, value) standardGeneric("constant<-"))
setReplaceMethod("constant", "Compartment", function(object, value) {
  object@constant <- value
  object
})

Try the rsbml package in your browser

Any scripts or data that you put into this service are public.

rsbml documentation built on Nov. 8, 2020, 8:09 p.m.