-
Notifications
You must be signed in to change notification settings - Fork 0
/
registerRes.R
51 lines (46 loc) · 1.43 KB
/
registerRes.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# * Author: Bangyou Zheng (Bangyou.Zheng@csiro.au)
# * Created: 21/01/2011
# *
setGeneric( "registerRes",
function( object, name, type )
{
standardGeneric( "registerRes" )
}
)
setMethod( f = "registerRes",
signature = c( object = "WeaAna", name = "character", type = "character" ),
definition = function( object, name, type )
{
old.name <- object@result[[1]]$value@name
old.type <- object@result[[1]]$value@type
if ( is.null( name ) || is.na( name ) )
{
return
}
if ( !( name %in% old.name ) )
{
object@result[[1]]$value@name <- c( old.name, name )
object@result[[1]]$value@type <- c( old.type, type )
}
}
)
setGeneric( "addResult",
function( object, an.res )
{
standardGeneric( "addResult" )
}
)
setMethod( f = "addResult",
signature = c( object = "result", an.res = "result" ),
definition = function( object, an.res )
{
old.name <- object@name
old.type <- object@type
an.name <- an.res@name
an.type <- an.res@type
pos <- ! ( an.name %in% old.name )
object@name <- c( old.name, an.name[pos] )
object@type <- c( old.type, an.type[pos] )
return( object )
}
)