setExternalStorageClass {externalVector} | R Documentation |
Function to create a subclass of "externalStorage" and associate native C methods with the class.
setExternalStorageClass(Class, methodNames, ..., contains = "externalStorage", where = topenv(parent.frame()))
Class |
Character string, name for the class. |
methodNames |
Character vector, names of the native C functions for use as methods (see Adding Native Methods below). |
... |
Other arguments passed to setClass . |
contains |
what classes does this class extend? (These are called superclasses in some languages.) Should have at least one class name which is a subclass of "externalStorage". |
where |
The environment in which to store or remove the definition. Defaults to the top-level environment of the calling function (the global environment for ordinary computations, but the environment or namespace of a package when loading that package). |
This function does two things. It creates a subclass of "externalStorage". It also associates a set of given C methods as native methods for this subclass of "externalStorage".
To make the external vectors as efficient as possible, the interface
between the storage method classes and the
"externalVectorWithSTorage" class uses a set of C function pointers
for each subclass of "externalStorage". There are two types of
methods - those which are for a particular type of vector and those
which are not for a particular type. For a type xxx
where
xxx
is one of logical
, integer
, numeric
,
complex
or character
, the type specific functions are
xxxGetElt | get an element from vector of type xxx |
xxxSetElt | set an element in a vector of type xxx |
xxxSubset | subset a vector of type xxx |
xxxSubassign | subassign a vector of type xxx |
xxxGetMatrixElt | get an element from matrix of type xxx |
xxxSetMatrixElt | set an element in a matrix of type xxx |
xxxMatrixSubset | subset a matrix of type xxx |
xxxMatrixSubassign | subassign a matrix of type xxx |
The functions not specific to any type are
alloc | allocate a new storage object |
size | return the length of the vector in the storage object |
resize | modify the length of the vector in the storage object |
The subset and subassign functions for vectors and matrices have reasonable default implementations in terms of the element get/set functions - so they need not be implemented for each "externalStorage" subclass.
The methodNames
argument to setExternalStorageClass
must be used to register any C function for use as a particular
method. This argument must be a character vector with elements of the
form methodName=functionName
where methodName
is one of
the method names given in the tables above and function name is a C
function name which has been registered as a C function with R using
the foreign function registration mechanism. See the chapter on
“System and foreign language interfaces” in
“Writing R Extensions” in the ‘doc/manual’
subdirectory of the R source tree for more details on registering C
functions.
setClass
for possible arguments in ....
externalStorage-class
for the "externalStorage" class.
## Not run: setExternalStorageClass("simpleStorage", c(logicalGetElt="simpleLogicalGetElt", logicalSetElt="simpleLogicalSetElt", numericGetElt="simpleNumericGetElt", numericSetElt="simpleNumericSetElt", size="simpleSize", resize="simpleResize" alloc="simpleAlloc"), contains = "externalStorage") ## End(Not run)