Skip to content

Commit

Permalink
return unique for inherited classes
Browse files Browse the repository at this point in the history
  • Loading branch information
grlloyd committed Nov 17, 2023
1 parent adfee78 commit f1c22af
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 35 deletions.
36 changes: 18 additions & 18 deletions R/output_class.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' @include generics.R struct_class.R
#'
#' @describeIn output_obj
#'
#' @describeIn output_obj
#' @export
setMethod(f = "output_obj",
signature = c("struct_class","character"),
Expand All @@ -10,7 +10,7 @@ setMethod(f = "output_obj",
}
)

#' @describeIn output_obj
#' @describeIn output_obj
#' @export
#' @return the modified object
setMethod(f = "output_obj<-",
Expand All @@ -24,45 +24,45 @@ setMethod(f = "output_obj<-",
}
)

#' @describeIn is_output
#' @describeIn is_output
#' @export
setMethod(f = "is_output",
signature = c("struct_class"),
definition = function(obj,name) {

# include params set for parent objects
valid = output_ids(obj)

# if valid param_id then return true
return(name %in% valid)
}
)

#' @describeIn output_ids
#' @describeIn output_ids
#' @export
setMethod(f = "output_ids",
signature = c("struct_class"),
definition = function(obj) {
# include params set for parent objects
parents = is(obj)
w=which(parents == 'struct_class')

valid=NULL
for (k in 1:w) {

# skip stato
if (parents[k]=='stato') {
next
}

valid = c(valid,new_struct(parents[k])@.outputs)
}
return(valid)

return(unique(valid))
}
)

#' @describeIn output_name
#' @describeIn output_name
#' @export
setMethod(f = "output_name",
signature = c("struct_class",'character'),
Expand All @@ -79,7 +79,7 @@ setMethod(f = "output_name",
}
)

#' @describeIn output_list
#' @describeIn output_list
#' @export
setMethod(f = 'output_list',
signature = c('struct_class'),
Expand All @@ -93,7 +93,7 @@ setMethod(f = 'output_list',
}
)

#' @describeIn output_list
#' @describeIn output_list
#' @export
setMethod(f = 'output_list<-',
signature = c('struct_class','list'),
Expand All @@ -106,12 +106,12 @@ setMethod(f = 'output_list<-',
}
)

#' @describeIn output_value
#' @describeIn output_value
#' @export
setMethod(f = "output_value",
signature = c("struct_class","character"),
definition = function(obj,name) {

p = slot(obj, name)
# if the output is an entity then set its value
if (is(p,'entity')) {
Expand All @@ -125,7 +125,7 @@ setMethod(f = "output_value",
)


#' @describeIn output_value
#' @describeIn output_value
#' @export
setMethod(f = "output_value<-",
signature = c("struct_class","character"),
Expand Down
34 changes: 17 additions & 17 deletions R/parameter_class.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ setMethod(f = "param_obj<-",
)

#' @export
#' @rdname param_obj
#' @rdname param_obj
setMethod(f = "param_obj",
signature = c("struct_class","character"),
definition = function(obj,name) {
Expand All @@ -25,11 +25,11 @@ setMethod(f = "param_obj",


#' @export
#' @describeIn is_param
#' @describeIn is_param
setMethod(f = "is_param",
signature = c("struct_class"),
definition = function(obj,name) {

# include params set for parent objects
valid = param_ids(obj)

Expand All @@ -39,33 +39,33 @@ setMethod(f = "is_param",
)

#' @export
#' @describeIn param_ids
#' @describeIn param_ids
setMethod(f = "param_ids",
signature = c("struct_class"),
definition = function(obj) {

# include params set for parent objects
parents = is(obj)
w=which(parents == 'struct_class')

valid=NULL
for (k in 1:w) {

# skip stato
if (parents[k]=='stato') {
next
}

valid = c(valid,new_struct(parents[k])@.params)
}
return(valid)

return(unique(valid))
}
)


#' @export
#' @describeIn param_name
#' @describeIn param_name
setMethod(f = "param_name",
signature = c("struct_class",'character'),
definition = function(obj,name) {
Expand All @@ -75,14 +75,14 @@ setMethod(f = "param_name",
value = p$name
return(value)
}

# otherwise just return the slot name
return(name)
}
)

#' @export
#' @describeIn param_list
#' @describeIn param_list
setMethod(f = 'param_list',
signature = c('struct_class'),
definition = function(obj) {
Expand All @@ -96,7 +96,7 @@ setMethod(f = 'param_list',
)

#' @export
#' @describeIn param_list
#' @describeIn param_list
setMethod(f = 'param_list<-',
signature = c('struct_class','list'),
definition = function(obj,value) {
Expand All @@ -109,12 +109,12 @@ setMethod(f = 'param_list<-',
)

#' @export
#' @describeIn param_value
#' @describeIn param_value
setMethod(f = "param_value",
signature = c("struct_class","character"),
definition = function(obj,name) {
p = slot(obj, name)

# if the parameter is an entity then set its entity value
if (is(p,'entity')) {
value = value(p)
Expand All @@ -128,7 +128,7 @@ setMethod(f = "param_value",
)

#' @export
#' @describeIn param_value
#' @describeIn param_value
setMethod(f = "param_value<-",
signature = c("struct_class","character","ANY"),
definition = function(obj,name,value) {
Expand Down

0 comments on commit f1c22af

Please sign in to comment.