Utility functions to manage a table of evaluators, indexed by the evaluator class, typically
one class per server language. All are typically hidden by functions or methods for the particular
class. rmInterface
and evaluatorNumber
are used by methods and exported so that
subclasses of interface evaluators will have access to them.
getInterface(Class, ..., .makeNew = NA, .select = NULL)rmInterface(evaluator)
evaluatorNumber(evaluator, add = length(id) > 0)
the name of the interface class for this evaluator; by default, the class of the current evaluator. Can also be the class definition object.
arguments, if any, are passed to the generator for the evaluator
can be used to force or prevent starting a new evaluator, if passed as a logical value. Can also be passed as a function that tests the suitability of a current evaluator, returning TRUE if this one won't do, and a new one should be generated instead (consistent with the ... arguments, presumably).
The default is NA, meaning that an existing evaluator is OK, but one should be generated if none exists. In contrast, FALSE means to return NULL if no matching evaluator exists.
Can be supplied as a function of one argument, which will be called for
each evaluator of this class and which should return TRUE
/FALSE
according to
whether the evaluator should be accepted. Allows applications to select, for example, a
particular evaluator corresponding to a known connection.
any evaluator object.
if this evaluator is not in the table, add it. Default TRUE
.
getInterface()
returns an interface evaluator for this class, starting one if none exists.
rmInterface
: Remove the specified evaluator from the table of available interfaces.
evaluatorNumber
: Return the sequential number for this evalutor; used in ProxyName()
method.
If not there: if add
, add the evaluator to the table; else return NA
.
Specific language interface packages usually supply a convenience function equivalent
to calling getInterface()
for their class; e.g., RPython()
in 'XRPython'
If no Class
is given, the current (i.e., last active) evaluator is returned
# NOT RUN {
## the current evaluator, or NULL if none exists
getInterface()
## this will always be NULL, because no evaluator has this class
getInterface("Interface", .makeNew = FALSE)
# }
Run the code above in your browser using DataLab