setClass(Class, representation, prototype, validity, access, where, version)
representation
is given, it should be a class representation
(e.g., a call to the function
representation
), although the name of
a single class is a valid short form.
new
will
take this object, and set its class to
Class
. The
prototype
can be given in addition to or instead of a representation. In the latter case the
class will not have slots defined.
TRUE
if its argument is a valid object from
Class
,
or a character string describing the problem otherwise. This is called by the
validObject
function, which is called from
new()
.
Class
already
exists, this will be the default for
where
, if the database is writable;
otherwise,
where
defaults to the working data. It is not allowed to
redefine classes on a required library (library
"main"
, e.g.).
version
is
TRUE
, version information
will also be saved in the meta-data (see
); by default,
version management will be maintained if it's already started, but not started spontaneously.
Class
, but with a special class that distinguishes it in
the (very rare) situations where a string might be ambiguous, perhaps referring
to a class, perhaps to an object from a class. If you want to be really safe, you
can save this object and use it as the name of the class.
Class
is added to the known classes and to the metadata on database
where
.
## a class with two numeric slots Track = setClass("track", representation(x="numeric", y="numeric")) ## a class extending "matrix", with one new slot, and a validity method setClass("tsMatrix", representation("matrix", tsp = "numeric"), validity = function(x) nrow(x) == length(x@tsp)) ## a class extending "tsMatrix" with no additional slots setClass("tsMatrix2", "tsMatrix")