setExternalStorageClass    package:externalVector    R Documentation

_C_r_e_a_t_e _s_u_b_c_l_a_s_s _o_f _e_x_t_e_r_n_a_l_S_t_o_r_a_g_e

_D_e_s_c_r_i_p_t_i_o_n:

     Function to create a subclass of "externalStorage" and associate
     native C methods with the class.

_U_s_a_g_e:

     setExternalStorageClass(Class, methodNames, ..., contains = "externalStorage", where = topenv(parent.frame()))

_A_r_g_u_m_e_n_t_s:

   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). 

_D_e_t_a_i_l_s:

     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".

_A_d_d_i_n_g _N_a_t_i_v_e _M_e_t_h_o_d_s:

     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.

_S_e_e _A_l_s_o:

     'setClass' for possible arguments in .... 'externalStorage-class'
     for the "externalStorage" class.

_E_x_a_m_p_l_e_s:

     ## Not run: 
     setExternalStorageClass("simpleStorage", c(logicalGetElt="simpleLogicalGetElt",
                                                logicalSetElt="simpleLogicalSetElt",
                                                numericGetElt="simpleNumericGetElt",
                                                numericSetElt="simpleNumericSetElt",
                                                size="simpleSize",
                                                resize="simpleResize"
                                                alloc="simpleAlloc"),
                             contains = "externalStorage")
     ## End(Not run)

