The R Project SVN R

Rev

Rev 25409 | Rev 39360 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
15357 jmc 1
\name{getClass}
2
\alias{getClass}
3
\alias{getClassDef}
15852 jmc 4
\title{Get Class Definition }
15357 jmc 5
\description{
6
  Get the definition of a class.
7
}
8
\usage{
25351 jmc 9
getClass(Class, .Force = FALSE, where)
10
getClassDef(Class, where, package)
15357 jmc 11
}
12
\arguments{
13
  \item{Class}{ the character-string name of the class.}
16559 jmc 14
  \item{.Force}{ if \code{TRUE}, return \code{NULL} if the class is
19029 hornik 15
    undefined; otherwise, an undefined class results in an error.}
25351 jmc 16
  \item{where}{ environment from which to begin the search for the definition; by default,
17
    start at the top-level (global) environment and proceed through
18
    the search list.}
19
  \item{package}{ the name of the package asserted to hold the
20
      definition.  Supplied instead of \code{where}, with the
21
      distinction that the package need not be currently attached.}
15357 jmc 22
}
23
\details{
19029 hornik 24
  A call to \code{getClass} returns the complete definition of the class
25
  supplied as a string, including all slots, etc. in classes that this
26
  class extends.  A call to \code{getClassDef} returns the definition of
19087 jmc 27
  the class from the environment \code{where}, unadorned.  It's usually \code{getClass}
19029 hornik 28
  you want.
15357 jmc 29
 
19087 jmc 30
  If you really want to know whether a class is formally
19029 hornik 31
  defined, call \code{\link{isClass}}.
15357 jmc 32
}
33
\value{
34
  The object defining the class.  This is an object of class
35
  \code{"classRepEnvironment"}.  However, \emph{do not} deal with the
36
  contents of the object directly unless you are very sure you know what
37
  you're doing.  Even then, it is nearly always better practice to use
38
  functions such as \code{\link{setClass}} and \code{\link{setIs}}.
39
  Messing up a class object will cause great confusion.
40
}
41
\references{
25409 hornik 42
  The R package \pkg{methods} implements, with a few exceptions, the
43
  programming interface for classes and methods in the book
44
  \emph{Programming with Data} (John M. Chambers, Springer, 1998), in
45
  particular sections 1.6, 2.7, 2.8, and chapters 7 and 8.
15357 jmc 46
 
25409 hornik 47
  While the programming interface for the methods package follows the
48
  reference, the R software is an original implementation, so details in
25351 jmc 49
  the reference that reflect the S4 implementation may appear
50
  differently in R.  Also, there are extensions to the programming
51
  interface developed more recently than the reference.  For a
52
  discussion of details and ongoing development, see the web page 
53
  \url{http://developer.r-project.org/methodsPackage.html} and the
54
  pointers from that page.
15357 jmc 55
}
19029 hornik 56
\seealso{
57
  \link{Classes},
58
  \code{\link{setClass}},
59
  \code{\link{isClass}}.
60
}
15357 jmc 61
\examples{
62
getClass("numeric") ## a built in class
63
 
26000 ripley 64
\dontshow{
16559 jmc 65
getClass("thisIsAnUndefinedClass", .Force = TRUE) ## returns NULL
66
try(getClass("thisIsAnUndefinedClass")) ## generates an error
15357 jmc 67
try(getClassDef("thisIsAnUndefinedClass")) ## generates an error
68
}
16559 jmc 69
}
15357 jmc 70
\keyword{programming}
71
\keyword{classes}