Skip to content

Commit f1c22af

Browse files
committed
return unique for inherited classes
1 parent adfee78 commit f1c22af

File tree

2 files changed

+35
-35
lines changed

2 files changed

+35
-35
lines changed

R/output_class.R

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#' @include generics.R struct_class.R
2-
#'
3-
#' @describeIn output_obj
2+
#'
3+
#' @describeIn output_obj
44
#' @export
55
setMethod(f = "output_obj",
66
signature = c("struct_class","character"),
@@ -10,7 +10,7 @@ setMethod(f = "output_obj",
1010
}
1111
)
1212

13-
#' @describeIn output_obj
13+
#' @describeIn output_obj
1414
#' @export
1515
#' @return the modified object
1616
setMethod(f = "output_obj<-",
@@ -24,45 +24,45 @@ setMethod(f = "output_obj<-",
2424
}
2525
)
2626

27-
#' @describeIn is_output
27+
#' @describeIn is_output
2828
#' @export
2929
setMethod(f = "is_output",
3030
signature = c("struct_class"),
3131
definition = function(obj,name) {
32-
32+
3333
# include params set for parent objects
3434
valid = output_ids(obj)
35-
35+
3636
# if valid param_id then return true
3737
return(name %in% valid)
3838
}
3939
)
4040

41-
#' @describeIn output_ids
41+
#' @describeIn output_ids
4242
#' @export
4343
setMethod(f = "output_ids",
4444
signature = c("struct_class"),
4545
definition = function(obj) {
4646
# include params set for parent objects
4747
parents = is(obj)
4848
w=which(parents == 'struct_class')
49-
49+
5050
valid=NULL
5151
for (k in 1:w) {
52-
52+
5353
# skip stato
5454
if (parents[k]=='stato') {
5555
next
5656
}
57-
57+
5858
valid = c(valid,new_struct(parents[k])@.outputs)
5959
}
60-
61-
return(valid)
60+
61+
return(unique(valid))
6262
}
6363
)
6464

65-
#' @describeIn output_name
65+
#' @describeIn output_name
6666
#' @export
6767
setMethod(f = "output_name",
6868
signature = c("struct_class",'character'),
@@ -79,7 +79,7 @@ setMethod(f = "output_name",
7979
}
8080
)
8181

82-
#' @describeIn output_list
82+
#' @describeIn output_list
8383
#' @export
8484
setMethod(f = 'output_list',
8585
signature = c('struct_class'),
@@ -93,7 +93,7 @@ setMethod(f = 'output_list',
9393
}
9494
)
9595

96-
#' @describeIn output_list
96+
#' @describeIn output_list
9797
#' @export
9898
setMethod(f = 'output_list<-',
9999
signature = c('struct_class','list'),
@@ -106,12 +106,12 @@ setMethod(f = 'output_list<-',
106106
}
107107
)
108108

109-
#' @describeIn output_value
109+
#' @describeIn output_value
110110
#' @export
111111
setMethod(f = "output_value",
112112
signature = c("struct_class","character"),
113113
definition = function(obj,name) {
114-
114+
115115
p = slot(obj, name)
116116
# if the output is an entity then set its value
117117
if (is(p,'entity')) {
@@ -125,7 +125,7 @@ setMethod(f = "output_value",
125125
)
126126

127127

128-
#' @describeIn output_value
128+
#' @describeIn output_value
129129
#' @export
130130
setMethod(f = "output_value<-",
131131
signature = c("struct_class","character"),

R/parameter_class.R

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ setMethod(f = "param_obj<-",
1414
)
1515

1616
#' @export
17-
#' @rdname param_obj
17+
#' @rdname param_obj
1818
setMethod(f = "param_obj",
1919
signature = c("struct_class","character"),
2020
definition = function(obj,name) {
@@ -25,11 +25,11 @@ setMethod(f = "param_obj",
2525

2626

2727
#' @export
28-
#' @describeIn is_param
28+
#' @describeIn is_param
2929
setMethod(f = "is_param",
3030
signature = c("struct_class"),
3131
definition = function(obj,name) {
32-
32+
3333
# include params set for parent objects
3434
valid = param_ids(obj)
3535

@@ -39,33 +39,33 @@ setMethod(f = "is_param",
3939
)
4040

4141
#' @export
42-
#' @describeIn param_ids
42+
#' @describeIn param_ids
4343
setMethod(f = "param_ids",
4444
signature = c("struct_class"),
4545
definition = function(obj) {
46-
46+
4747
# include params set for parent objects
4848
parents = is(obj)
4949
w=which(parents == 'struct_class')
50-
50+
5151
valid=NULL
5252
for (k in 1:w) {
53-
53+
5454
# skip stato
5555
if (parents[k]=='stato') {
5656
next
5757
}
58-
58+
5959
valid = c(valid,new_struct(parents[k])@.params)
6060
}
61-
62-
return(valid)
61+
62+
return(unique(valid))
6363
}
6464
)
6565

6666

6767
#' @export
68-
#' @describeIn param_name
68+
#' @describeIn param_name
6969
setMethod(f = "param_name",
7070
signature = c("struct_class",'character'),
7171
definition = function(obj,name) {
@@ -75,14 +75,14 @@ setMethod(f = "param_name",
7575
value = p$name
7676
return(value)
7777
}
78-
78+
7979
# otherwise just return the slot name
8080
return(name)
8181
}
8282
)
8383

8484
#' @export
85-
#' @describeIn param_list
85+
#' @describeIn param_list
8686
setMethod(f = 'param_list',
8787
signature = c('struct_class'),
8888
definition = function(obj) {
@@ -96,7 +96,7 @@ setMethod(f = 'param_list',
9696
)
9797

9898
#' @export
99-
#' @describeIn param_list
99+
#' @describeIn param_list
100100
setMethod(f = 'param_list<-',
101101
signature = c('struct_class','list'),
102102
definition = function(obj,value) {
@@ -109,12 +109,12 @@ setMethod(f = 'param_list<-',
109109
)
110110

111111
#' @export
112-
#' @describeIn param_value
112+
#' @describeIn param_value
113113
setMethod(f = "param_value",
114114
signature = c("struct_class","character"),
115115
definition = function(obj,name) {
116116
p = slot(obj, name)
117-
117+
118118
# if the parameter is an entity then set its entity value
119119
if (is(p,'entity')) {
120120
value = value(p)
@@ -128,7 +128,7 @@ setMethod(f = "param_value",
128128
)
129129

130130
#' @export
131-
#' @describeIn param_value
131+
#' @describeIn param_value
132132
setMethod(f = "param_value<-",
133133
signature = c("struct_class","character","ANY"),
134134
definition = function(obj,name,value) {

0 commit comments

Comments
 (0)