Rev 68857 | 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{Computations with Classes}\alias{removeClass}\alias{resetClass}\alias{isClass}\alias{getClasses}\alias{findClass}\alias{sealClass}\description{Functions to find and manipulate class definitions.}\usage{isClass(Class, formal=TRUE, where)getClasses(where, inherits = missing(where))findClass(Class, where, unique = "")removeClass(Class, where,resolve.msg = getOption("removeClass.msg", default=TRUE))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 modify orremove the definition. Defaults to the top-level environment of thecalling function (the global environment for ordinary computations,but the environment or namespace of a package in the source for apackage).When searching for class definitions, \code{where} defines where todo the search, and the default is to search from the top-levelenvironment or namespace of the caller to this function.}\item{formal}{\code{\link{logical}} indicating if a formal definitionis required.}\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{resolve.msg}{\code{\link{logical}} indicating if \R should\code{\link{message}()} its decision if \code{Class} is found inmultiple namespaces and one is chosen.}\item{classDef}{ For \code{resetClass}, the optional classdefinition (but usually it's better for \code{Class} to be theclass definition, and to omit \code{classDef}).}}\details{These are the functions that test and manipulate formal classdefinitions. Brief documentation is provided below. See thereferences for an introduction and for more details.\describe{\item{\code{removeClass}:}{Remove the definition of this class, from the environment\code{where} if this argument is supplied; if not,\code{removeClass} will search for a definition, starting in thetop-level environment of the call to \code{removeClass}, andremove the (first) definition found.}\item{\code{isClass}:}{Is this the name of a formally defined class? (Argument\code{formal} is for compatibility and is ignored.)}\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{inherits} argument can be used to search a particularenvironment and all its parents, but usually the default settingis what you want.}\item{\code{findClass}:}{The list of environments or positions on the search list inwhich a class definition of \code{Class} is found. If\code{where} is supplied, this is an environment (or namespace)from which the search takes place; otherwise the top-levelenvironment of the caller is used. If \code{unique} is suppliedas a character string, \code{findClass} returns a singleenvironment or position. By default, it always returns a list.The calling function should select, say, the first element as aposition or environment for functions such as \code{\link{get}}.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.}\item{\code{resetClass}:}{Reset the internal definition of a class. Causes the completedefinition of the class to be re-computed, from therepresentation and superclasses specified in the originalcall to \code{setClass}.This function is called when aspects of the class definition arechanged. You would need to call it explicitly if you changed thedefinition of a class that this class extends (but doing that inthe middle of a session is living dangerously, since it mayinvalidate existing objects).}\item{\code{sealClass}:}{ Seal the current definition of the specifiedclass, to prevent further changes. It is possible to seal a classin the call to \code{setClass}, but sometimes further changes haveto be made (e.g., by calls to \code{setIs}). If so, call\code{sealClass} after all the relevant changes have been made.}}}\references{Chambers, John M. (2008)\emph{Software for Data Analysis: Programming with R}Springer. (For the R version.)Chambers, John M. (1998)\emph{Programming with Data}Springer (For the original S4 version.)}\seealso{\code{\link{setClassUnion}},\code{\link{Methods}},\code{\link{makeClassRepresentation}}}%% should add Examples section\keyword{programming}\keyword{classes}\keyword{methods}