| Line 2... |
Line 2... |
| 2 |
\alias{is}
|
2 |
\alias{is}
|
| 3 |
\alias{extends}
|
3 |
\alias{extends}
|
| 4 |
\alias{setIs}
|
4 |
\alias{setIs}
|
| 5 |
\title{Is an Object from a Class}
|
5 |
\title{Is an Object from a Class}
|
| 6 |
\description{
|
6 |
\description{
|
| 7 |
\code{is}:
|
7 |
\code{is}:
|
| 8 |
With two arguments, tests whether \code{object} can be treated as from
|
8 |
With two arguments, tests whether \code{object} can be treated as from
|
| 9 |
\code{class2}.
|
9 |
\code{class2}.
|
| 10 |
|
10 |
|
| 11 |
With one argument, returns all the super-classes of this object's class.
|
11 |
With one argument, returns all the super-classes of this object's class.
|
| 12 |
|
12 |
|
| 13 |
\code{extends}:
|
13 |
\code{extends}:
|
| 14 |
Does the first class extend the second class?
|
14 |
Does the first class extend the second class?
|
| 15 |
Returns \code{maybe} if the extension includes a test.
|
15 |
Returns \code{maybe} if the extension includes a test.
|
| 16 |
|
16 |
|
| 17 |
\code{setIs}:
|
17 |
\code{setIs}:
|
| 18 |
Defines \code{class1} to be an extension of \code{class2}.
|
18 |
Defines \code{class1} to be an extension of \code{class2}.
|
| 19 |
}
|
19 |
}
|
| 20 |
\usage{
|
20 |
\usage{
|
| 21 |
is(object, class2)
|
21 |
is(object, class2)
|
| 22 |
|
22 |
|
| 23 |
extends(class1, class2, maybe=TRUE, fullInfo = FALSE)
|
23 |
extends(class1, class2, maybe=TRUE, fullInfo = FALSE)
|
| 24 |
|
24 |
|
| 25 |
setIs(class1, class2, test=NULL, coerce=NULL, replace=NULL,
|
25 |
setIs(class1, class2, test=NULL, coerce=NULL, replace=NULL,
|
| - |
|
26 |
by = character(), where = topenv(parent.frame()), classDef =,
|
| 26 |
by = NULL, where = 1, classDef, extensionObject, doComplete = TRUE)
|
27 |
extensionObject = NULL, doComplete = TRUE)
|
| 27 |
|
- |
|
| 28 |
}
|
28 |
}
|
| 29 |
\arguments{
|
29 |
\arguments{
|
| 30 |
\item{object}{Any R object.}
|
30 |
\item{object}{any \R object.}
|
| 31 |
\item{class1, class2}{
|
31 |
\item{class1, class2}{
|
| 32 |
the names of the classes between which \code{is} relations are to be
|
32 |
the names of the classes between which \code{is} relations are to be
|
| 33 |
defined.}
|
33 |
defined.}
|
| 34 |
|
34 |
|
| 35 |
\item{maybe, fullInfo}{
|
35 |
\item{maybe, fullInfo}{
|
| Line 79... |
Line 79... |
| 79 |
\dQuote{superclasses} of that class), including the class itself. If
|
79 |
\dQuote{superclasses} of that class), including the class itself. If
|
| 80 |
the flag \code{fullInfo} is \code{TRUE}, the result is a list, each
|
80 |
the flag \code{fullInfo} is \code{TRUE}, the result is a list, each
|
| 81 |
element of which is an object describing the relationship;
|
81 |
element of which is an object describing the relationship;
|
| 82 |
otherwise, and by default, the value returned is only the names of
|
82 |
otherwise, and by default, the value returned is only the names of
|
| 83 |
the classes.}
|
83 |
the classes.}
|
| 84 |
|
84 |
|
| 85 |
\item{\code{setIs}: }{
|
85 |
\item{\code{setIs}: }{
|
| 86 |
|
86 |
|
| 87 |
This function establishes an inheritance relation between two
|
87 |
This function establishes an inheritance relation between two
|
| 88 |
classes, by some means other than having one class contain the
|
88 |
classes, by some means other than having one class contain the
|
| 89 |
other. It should \emph{not} be used for ordinary relationships:
|
89 |
other. It should \emph{not} be used for ordinary relationships:
|
| Line 99... |
Line 99... |
| 99 |
\code{coerce=} and \code{replace=} argument to \code{setIs}.
|
99 |
\code{coerce=} and \code{replace=} argument to \code{setIs}.
|
| 100 |
|
100 |
|
| 101 |
|
101 |
|
| 102 |
The \code{coerce}, \code{replace}, and \code{by} arguments behave as
|
102 |
The \code{coerce}, \code{replace}, and \code{by} arguments behave as
|
| 103 |
described for the \code{\link{setAs}} function. It's unlikely you
|
103 |
described for the \code{\link{setAs}} function. It's unlikely you
|
| 104 |
would use the \code{by} argument directly, but it is used in defining
|
104 |
would use the \code{by} argument directly, but it is used in defining
|
| 105 |
cached information about classes. The value returned (invisibly) by
|
105 |
cached information about classes. The value returned (invisibly) by
|
| 106 |
\code{setIs} is the extension information, as a list.
|
106 |
\code{setIs} is the extension information, as a list.
|
| 107 |
|
107 |
|
| 108 |
The \code{coerce} argument is a function that turns a
|
108 |
The \code{coerce} argument is a function that turns a
|
| 109 |
\code{class1} object into a \code{class2} object. The
|
109 |
\code{class1} object into a \code{class2} object. The
|
| Line 124... |
Line 124... |
| 124 |
\code{class2} object by extracting the corresponding slots from the
|
124 |
\code{class2} object by extracting the corresponding slots from the
|
| 125 |
\code{class1} object. The \code{replace} function would replace in
|
125 |
\code{class1} object. The \code{replace} function would replace in
|
| 126 |
the \code{class1} object the slots corresponding to \code{class2},
|
126 |
the \code{class1} object the slots corresponding to \code{class2},
|
| 127 |
and return the modified object as its value.
|
127 |
and return the modified object as its value.
|
| 128 |
|
128 |
|
| 129 |
|
129 |
|
| 130 |
The relationship can also be conditional, if a function is supplied as the
|
130 |
The relationship can also be conditional, if a function is supplied as the
|
| 131 |
\code{test} argument. This should be a function of one argument
|
131 |
\code{test} argument. This should be a function of one argument
|
| 132 |
that returns \code{TRUE} or \code{FALSE} according to whether the
|
132 |
that returns \code{TRUE} or \code{FALSE} according to whether the
|
| 133 |
object supplied satisfies the relation \code{is(object, class2)}.
|
133 |
object supplied satisfies the relation \code{is(object, class2)}.
|
| 134 |
If you worry about such things, conditional relations between
|
134 |
If you worry about such things, conditional relations between
|