EVOLUTION-MANAGER
Edit File: getClass.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Get Class Definition</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for getClass {methods}"><tr><td>getClass {methods}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Get Class Definition </h2> <h3>Description</h3> <p>Get the definition of a class. </p> <h3>Usage</h3> <pre> getClass (Class, .Force = FALSE, where) getClassDef(Class, where, package, inherits = TRUE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>Class</code></td> <td> <p> the character-string name of the class, often with a <code>"package"</code> attribute as noted below under <code>package</code>.</p> </td></tr> <tr valign="top"><td><code>.Force</code></td> <td> <p> if <code>TRUE</code>, return <code>NULL</code> if the class is undefined; otherwise, an undefined class results in an error.</p> </td></tr> <tr valign="top"><td><code>where</code></td> <td> <p> environment from which to begin the search for the definition; by default, start at the top-level (global) environment and proceed through the search list.</p> </td></tr> <tr valign="top"><td><code>package</code></td> <td> <p> the name or environment of the package asserted to hold the definition. If it is a non-empty string it is used instead of <code>where</code>, as the first place to look for the class. Note that the package must be loaded but need not be attached. By default, the package attribute of the <code>Class</code> argument is used, if any. There will usually be a package attribute if <code>Class</code> comes from <code>class(x)</code> for some object. </p> </td></tr> <tr valign="top"><td><code>inherits</code></td> <td> <p>logical; should the class definition be retrieved from any enclosing environment and also from the cache? If <code>FALSE</code> only a definition in the environment <code>where</code> will be returned.</p> </td></tr> </table> <h3>Details</h3> <p>Class definitions are stored in metadata objects in a package namespace or other environment where they are defined. When packages are loaded, the class definitions in the package are cached in an internal table. Therefore, most calls to <code>getClassDef</code> will find the class in the cache or fail to find it at all, unless <code>inherits</code> is <code>FALSE</code>, in which case only the environment(s) defined by <code>package</code> or <code>where</code> are searched. </p> <p>The class cache allows for multiple definitions of the same class name in separate environments, with of course the limitation that the package attribute or package name must be provided in the call to </p> <h3>Value</h3> <p>The object defining the class. If the class definition is not found, <code>getClassDef</code> returns <code>NULL</code>, while <code>getClass</code>, which calls <code>getClassDef</code>, either generates an error or, if <code>.Force</code> is <code>TRUE</code>, returns a simple definition for the class. The latter case is used internally, but is not typically sensible in user code. </p> <p>The non-null returned value is an object of class <code><a href="classRepresentation-class.html">classRepresentation</a></code>. </p> <p>Use functions such as <code><a href="setClass.html">setClass</a></code> and <code><a href="setClassUnion.html">setClassUnion</a></code> to create class definitions. </p> <h3>References</h3> <p>Chambers, John M. (2016) <em>Extending R</em>, Chapman & Hall. (Chapters 9 and 10.) </p> <h3>See Also</h3> <p><a href="classRepresentation-class.html">classRepresentation</a>, <code><a href="setClass.html">setClass</a></code>, <code><a href="findClass.html">isClass</a></code>. </p> <h3>Examples</h3> <pre> getClass("numeric") ## a built in class cld <- getClass("thisIsAnUndefinedClass", .Force = TRUE) cld ## a NULL prototype ## If you are really curious: utils::str(cld) ## Whereas these generate errors: try(getClass("thisIsAnUndefinedClass")) try(getClassDef("thisIsAnUndefinedClass")) </pre> <hr /><div style="text-align: center;">[Package <em>methods</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>