Rev 71366 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
% File src/library/methods/man/findClass.Rd% Part of the R package, https://www.R-project.org% Copyright 1995-2015 R Core Team% Distributed under GPL 2 or later\name{findClass}\title{Find Class Definitions}\alias{removeClass}\alias{resetClass}\alias{isClass}\alias{getClasses}\alias{findClass}\alias{sealClass}\description{Functions to find classes: \code{isClass} tests for a class;\code{findClass} returns the name(s) of packages containing theclass; \code{getClasses} returns the names of all the classes in anenvironment, typically a namespace. To examine the definition of a class, use \code{\link{getClass}}.}\usage{isClass(Class, formal=TRUE, where)getClasses(where, inherits = missing(where))findClass(Class, where, unique = "")## The remaining functions are retained for compatibility## but not generally recommendedremoveClass(Class, where)resetClass(Class, classDef, where)sealClass(Class, where)}\arguments{\item{Class}{character string name for the class. The functions willusually take a class definition instead of the string. To restrictthe class to those defined in a particular package, set the\code{\link{packageSlot}} of the character string.}\item{where}{the \code{\link{environment}} in which to search forthe class definition. Defaults to the top-level environment of thecalling function. When called from the command line, this has theeffect of using all the package environments in the search list.To restrict the search to classes in a particular package, use \code{where =asNamespace(pkg)} with \code{pkg} the package name; to restrictit tothe \emph{exported} classes, use \code{where = "package:pkg"} after thepackage is attached to the search list.}\item{formal}{\code{\link{logical}} is a formal definitionrequired? For S compatibility, and always treated as \code{TRUE}.}\item{unique}{if \code{findClass} expects a unique location for theclass, \code{unique} is a character string explaining the purposeof the search (and is used in warning and error messages). Bydefault, multiple locations are possible and the function alwaysreturns a list.}\item{inherits}{in a call to \code{getClasses}, should the valuereturned include all parent environments of \code{where}, or thatenvironment only? Defaults to \code{TRUE} if \code{where} isomitted, and to \code{FALSE} otherwise.}\item{classDef}{ For \code{resetClass}, the optional classdefinition.}}\section{Functions}{\describe{\item{\code{isClass}:}{Is this the name of a formally defined class?}\item{\code{getClasses}:}{The names of all the classes formally defined on \code{where}. Ifcalled with no argument, all the classes visible from thecalling function (if called from the top-level, all the classesin any of the environments on the search list). The\code{where} argument is used to search only in a particular package.}\item{\code{findClass}:}{The list of environments inwhich a class definition of \code{Class} is found. If\code{where} is supplied, a list is still returned, either emptyor containing the environment corresponding to \code{where}.By default when called from the \R session, the globalenvironment and all the currentlyattached packages are searched.If \code{unique} is supplied as a character string,\code{findClass} will warn if there is more than one definitionvisible (using the string to identify the purpose of the call),and will generate an error if no definition can be found.\emph{The remaining functions are retained forback-compatibility and internal use, but not generally recommended.}}\item{\code{removeClass}:}{Remove the definition of this class. This can't be used if theclass is in another package, and would rarely be needed insource code defining classes in a package.}\item{\code{resetClass}:}{Reset the internal definition of a class. Not legitimate for aclass definition not in this package and rarely needed otherwise.}\item{\code{sealClass}:}{ Seal the current definition of the specifiedclass, to prevent further changes, by setting the correspondingslot in the class definition. This is rarely used, sinceclasses in loaded packages are sealed by locking their namespace.}}}\references{Chambers, John M. (2016)\emph{Extending R},Chapman & Hall.(Chapters 9 and 10.)Chambers, John M. (2008)\emph{Software for Data Analysis: Programming with R}Springer. (Chapter 9 has some details not in the later reference.)}\seealso{\code{\link{getClass}},\code{\link{Classes_Details}},\code{\link{Methods_Details}},\code{\link{makeClassRepresentation}}}%% should add Examples section\keyword{programming}\keyword{classes}\keyword{methods}