| 45824 |
jmc |
1 |
% File src/library/methods/man/findClass.Rd
|
|
|
2 |
% Part of the R package, http://www.R-project.org
|
| 59039 |
ripley |
3 |
% Copyright 1995-2007 R Core Team
|
| 45824 |
jmc |
4 |
% Distributed under GPL 2 or later
|
|
|
5 |
|
|
|
6 |
\name{findClass}
|
|
|
7 |
\alias{removeClass}
|
|
|
8 |
\alias{resetClass}
|
|
|
9 |
\alias{isClass}
|
|
|
10 |
\alias{getClasses}
|
| 56186 |
murdoch |
11 |
\alias{findClass}
|
| 45824 |
jmc |
12 |
\alias{sealClass}
|
|
|
13 |
\title{Computations with Classes}
|
|
|
14 |
\description{
|
|
|
15 |
Functions to find and manipulate class definitions.
|
|
|
16 |
}
|
|
|
17 |
\usage{
|
|
|
18 |
removeClass(Class, where)
|
|
|
19 |
|
|
|
20 |
isClass(Class, formal=TRUE, where)
|
|
|
21 |
|
|
|
22 |
getClasses(where, inherits = missing(where))
|
|
|
23 |
|
|
|
24 |
findClass(Class, where, unique = "")
|
|
|
25 |
|
|
|
26 |
resetClass(Class, classDef, where)
|
|
|
27 |
|
|
|
28 |
sealClass(Class, where)
|
|
|
29 |
|
|
|
30 |
}
|
|
|
31 |
\arguments{
|
| 45885 |
maechler |
32 |
\item{Class}{character string name for the class. The functions will
|
|
|
33 |
usually take a class definition instead of the string. To restrict
|
|
|
34 |
the class to those defined in a particular package, set the
|
|
|
35 |
\code{\link{packageSlot}} of the character string.}
|
| 56211 |
maechler |
36 |
\item{where}{the \code{\link{environment}} in which to modify or
|
|
|
37 |
remove the definition. Defaults to the top-level environment of the
|
|
|
38 |
calling function (the global environment for ordinary computations,
|
| 56382 |
murdoch |
39 |
but the environment or namespace of a package in the source for a
|
| 56211 |
maechler |
40 |
package).
|
| 45824 |
jmc |
41 |
|
| 45885 |
maechler |
42 |
When searching for class definitions, \code{where} defines where to
|
|
|
43 |
do the search, and the default is to search from the top-level
|
| 56382 |
murdoch |
44 |
environment or namespace of the caller to this function.
|
| 45824 |
jmc |
45 |
}
|
|
|
46 |
\item{unique}{if \code{findClass} expects a unique location for the
|
|
|
47 |
class, \code{unique} is a character string explaining the purpose
|
|
|
48 |
of the search (and is used in warning and error messages). By
|
|
|
49 |
default, multiple locations are possible and the function always
|
|
|
50 |
returns a list.
|
|
|
51 |
}
|
|
|
52 |
\item{inherits}{in a call to \code{getClasses}, should the value
|
|
|
53 |
returned include all parent environments of \code{where}, or that
|
|
|
54 |
environment only? Defaults to \code{TRUE} if \code{where} is
|
|
|
55 |
omitted, and to \code{FALSE} otherwise.
|
|
|
56 |
}
|
|
|
57 |
\item{formal}{ Should a formal definition be required? }
|
|
|
58 |
\item{classDef}{ For \code{removeClass}, the optional class
|
|
|
59 |
definition (but usually it's better for \code{Class} to be the
|
|
|
60 |
class definition, and to omit \code{classDef}).
|
|
|
61 |
}
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
\details{
|
|
|
65 |
These are the functions that test and manipulate formal class
|
|
|
66 |
definitions. Brief documentation is provided below. See the
|
|
|
67 |
references for an introduction and for more details.
|
|
|
68 |
|
|
|
69 |
\describe{
|
|
|
70 |
\item{\code{removeClass}:}{
|
|
|
71 |
Remove the definition of this class, from the environment
|
|
|
72 |
\code{where} if this argument is supplied; if not,
|
|
|
73 |
\code{removeClass} will search for a definition, starting in the
|
|
|
74 |
top-level environment of the call to \code{removeClass}, and
|
|
|
75 |
remove the (first) definition found.
|
|
|
76 |
}
|
|
|
77 |
\item{\code{isClass}:}{
|
|
|
78 |
Is this the name of a formally defined class? (Argument
|
|
|
79 |
\code{formal} is for compatibility and is ignored.)
|
|
|
80 |
}
|
|
|
81 |
\item{\code{getClasses}:}{
|
|
|
82 |
The names of all the classes formally defined on \code{where}. If
|
|
|
83 |
called with no argument, all the classes visible from the
|
|
|
84 |
calling function (if called from the top-level, all the classes
|
|
|
85 |
in any of the environments on the search list). The
|
|
|
86 |
\code{inherits} argument can be used to search a particular
|
|
|
87 |
environment and all its parents, but usually the default setting
|
|
|
88 |
is what you want.
|
|
|
89 |
}
|
|
|
90 |
\item{\code{findClass}:}{
|
|
|
91 |
The list of environments or positions on the search list in
|
|
|
92 |
which a class definition of \code{Class} is found. If
|
| 56382 |
murdoch |
93 |
\code{where} is supplied, this is an environment (or namespace)
|
| 45824 |
jmc |
94 |
from which the search takes place; otherwise the top-level
|
|
|
95 |
environment of the caller is used. If \code{unique} is supplied
|
|
|
96 |
as a character string, \code{findClass} returns a single
|
|
|
97 |
environment or position. By default, it always returns a list.
|
|
|
98 |
The calling function should select, say, the first element as a
|
|
|
99 |
position or environment for functions such as \code{\link{get}}.
|
|
|
100 |
|
|
|
101 |
If \code{unique} is supplied as a character string,
|
|
|
102 |
\code{findClass} will warn if there is more than one definition
|
|
|
103 |
visible (using the string to identify the purpose of the call),
|
|
|
104 |
and will generate an error if no definition can be found.
|
|
|
105 |
}
|
|
|
106 |
\item{\code{resetClass}:}{
|
|
|
107 |
Reset the internal definition of a class. Causes the complete
|
|
|
108 |
definition of the class to be re-computed, from the
|
|
|
109 |
representation and superclasses specified in the original
|
|
|
110 |
call to \code{setClass}.
|
|
|
111 |
|
|
|
112 |
This function is called when aspects of the class definition are
|
|
|
113 |
changed. You would need to call it explicitly if you changed the
|
|
|
114 |
definition of a class that this class extends (but doing that in
|
|
|
115 |
the middle of a session is living dangerously, since it may
|
|
|
116 |
invalidate existing objects).
|
|
|
117 |
}
|
|
|
118 |
\item{\code{sealClass}:}{ Seal the current definition of the specified
|
|
|
119 |
class, to prevent further changes. It is possible to seal a class
|
|
|
120 |
in the call to \code{setClass}, but sometimes further changes have
|
|
|
121 |
to be made (e.g., by calls to \code{setIs}). If so, call
|
|
|
122 |
\code{sealClass} after all the relevant changes have been made.
|
|
|
123 |
}
|
|
|
124 |
}
|
|
|
125 |
}
|
|
|
126 |
|
|
|
127 |
\references{
|
|
|
128 |
Chambers, John M. (2008)
|
|
|
129 |
\emph{Software for Data Analysis: Programming with R}
|
|
|
130 |
Springer. (For the R version.)
|
|
|
131 |
|
|
|
132 |
Chambers, John M. (1998)
|
|
|
133 |
\emph{Programming with Data}
|
| 45885 |
maechler |
134 |
Springer (For the original S4 version.)
|
| 45824 |
jmc |
135 |
}
|
|
|
136 |
\seealso{
|
|
|
137 |
\code{\link{setClassUnion}},
|
|
|
138 |
\code{\link{Methods}},
|
|
|
139 |
\code{\link{makeClassRepresentation}}
|
|
|
140 |
}
|
|
|
141 |
%% should add Examples section
|
|
|
142 |
\keyword{programming}
|
|
|
143 |
\keyword{classes}
|
|
|
144 |
\keyword{methods}
|