| Line 2... |
Line 2... |
| 2 |
% Part of the R package, https://www.R-project.org
|
2 |
% Part of the R package, https://www.R-project.org
|
| 3 |
% Copyright 2010-2014 R Core Team
|
3 |
% Copyright 2010-2014 R Core Team
|
| 4 |
% Distributed under GPL 2 or later
|
4 |
% Distributed under GPL 2 or later
|
| 5 |
|
5 |
|
| 6 |
\name{ReferenceClasses}
|
6 |
\name{ReferenceClasses}
|
| 7 |
\title{Objects With Fields Treated by Reference (OOP-style)}
|
7 |
\title{Objects With Fields Treated by Reference (\abbr{OOP}-style)}
|
| 8 |
\alias{ReferenceClasses}
|
8 |
\alias{ReferenceClasses}
|
| 9 |
\alias{setRefClass}
|
9 |
\alias{setRefClass}
|
| 10 |
\alias{getRefClass}
|
10 |
\alias{getRefClass}
|
| 11 |
\alias{initFieldArgs}
|
11 |
\alias{initFieldArgs}
|
| 12 |
\alias{initRefFields}
|
12 |
\alias{initRefFields}
|
| Line 27... |
Line 27... |
| 27 |
\alias{show,refClassRepresentation-method}
|
27 |
\alias{show,refClassRepresentation-method}
|
| 28 |
\alias{externalRefMethod}
|
28 |
\alias{externalRefMethod}
|
| 29 |
\alias{externalRefMethod-class}
|
29 |
\alias{externalRefMethod-class}
|
| 30 |
\description{
|
30 |
\description{
|
| 31 |
The software described here allows packages to define \emph{reference
|
31 |
The software described here allows packages to define \emph{reference
|
| 32 |
classes} that behave in the style of \dQuote{OOP} languages such as Java and
|
32 |
classes} that behave in the style of \dQuote{\abbr{OOP}} languages such as Java and
|
| 33 |
C++.
|
33 |
C++.
|
| 34 |
This model for OOP differs from the functional model implemented by S4
|
34 |
This model for \abbr{OOP} differs from the functional model implemented by S4
|
| 35 |
(and S3) classes and methods, in which methods are defined for generic
|
35 |
(and S3) classes and methods, in which methods are defined for generic
|
| 36 |
functions.
|
36 |
functions.
|
| 37 |
Methods for reference classes are \dQuote{encapsulated} in the class definition.
|
37 |
Methods for reference classes are \dQuote{encapsulated} in the class definition.
|
| 38 |
|
38 |
|
| 39 |
Computations with objects from reference classes invoke methods on them and
|
39 |
Computations with objects from reference classes invoke methods on them and
|
| Line 207... |
Line 207... |
| 207 |
as the whole object, and the method follows the standard rules for any
|
207 |
as the whole object, and the method follows the standard rules for any
|
| 208 |
function in a package. See the section on \dQuote{External Methods}
|
208 |
function in a package. See the section on \dQuote{External Methods}
|
| 209 |
|
209 |
|
| 210 |
The goal of the software described here is to provide a uniform
|
210 |
The goal of the software described here is to provide a uniform
|
| 211 |
programming style in \R for software dealing with reference classes, whether
|
211 |
programming style in \R for software dealing with reference classes, whether
|
| 212 |
implemented directly in \R or through an interface to one of the OOP
|
212 |
implemented directly in \R or through an interface to one of the \abbr{OOP}
|
| 213 |
languages.
|
213 |
languages.
|
| 214 |
}
|
214 |
}
|
| 215 |
|
215 |
|
| 216 |
|
216 |
|
| 217 |
\section{Writing Reference Methods}{
|
217 |
\section{Writing Reference Methods}{
|
| Line 701... |
Line 701... |
| 701 |
class for which this object is the generator.
|
701 |
class for which this object is the generator.
|
| 702 |
}
|
702 |
}
|
| 703 |
|
703 |
|
| 704 |
\item{\code{$accessors(...)}}{ %$}{
|
704 |
\item{\code{$accessors(...)}}{ %$}{
|
| 705 |
A number of
|
705 |
A number of
|
| 706 |
systems using the OOP programming paradigm recommend or enforce
|
706 |
systems using the \abbr{OOP} programming paradigm recommend or enforce
|
| 707 |
\emph{getter and setter methods}
|
707 |
\emph{getter and setter methods}
|
| 708 |
corresponding to each field, rather than direct access by name.
|
708 |
corresponding to each field, rather than direct access by name.
|
| 709 |
If you like this style and want to extract a field named \code{abc}
|
709 |
If you like this style and want to extract a field named \code{abc}
|
| 710 |
by \code{x$getAbc()} and assign it by
|
710 |
by \code{x$getAbc()} and assign it by
|
| 711 |
\code{x$setAbc(value)},
|
711 |
\code{x$setAbc(value)},
|