externalAllocator-class    package:externalVector    R Documentation

_C_l_a_s_s "_e_x_t_e_r_n_a_l_A_l_l_o_c_a_t_o_r", _b_a_s_e _c_l_a_s_s _f_o_r _m_e_m_o_r_y _a_l_l_o_c_a_t_o_r_s _f_o_r
_e_x_t_e_r_n_a_l _r_e_s_o_u_r_c_e_s

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

     Class '"externalAllocator"' is a virtual class with no slots. It
     represents memory allocators that allocate raw memory to be held
     in an object of class '"externalptr"'. Instead of returning the
     '"externalptr"' object directly, the allocators deal with
     subclasses of '"externalResource"' that hold an object of class
     '"externalptr"'.

_O_b_j_e_c_t_s _f_r_o_m _t_h_e _C_l_a_s_s:

     A virtual Class: No objects may be created from it.

_V_i_r_t_u_a_l _M_e_t_h_o_d_s:

     Attempt to execute these methods would result in an error unless
     they have been redefined for a subclass of '"externalAllocator"'.

     Signature components for implementation of the methods:

       resource  The class "externalResource"
       alloc     A subclass of "externalAllocator"
       size      The class "ANY"
       type      The class "ANY"
       copy      The class "logical"
       value     The class "ANY"

     Description of the virtual methods:


     _a_l_l_o_c_a_t_e(_r_e_s_o_u_r_c_e, _a_l_l_o_c, _s_i_z_e, _t_y_p_e, ...): Allocate the external
          pointer in 'resource' using the allocator 'alloc'. If 'type'
          is a basic vector object, then allocate an object of same
          mode with length 'size'. Otherwise allocate 'size' bytes of
          raw memory. This method should end with a call to
          'initializeResource' to initialize the 'resource' object. 

     _d_e_a_l_l_o_c_a_t_e(_r_e_s_o_u_r_c_e, _a_l_l_o_c): The allocator 'alloc' should try to
          dealloacte the raw memory in 'resource'. It should not modify
          the 'resource' object in any way other than modifying the
          object of class '"externalptr"' in 'resource' to reflect the
          deallocation. 

     _e_x_t_e_r_n_a_l._s_i_z_e Return the size of the allocated memory in
          'resource'. 

     _e_x_t_e_r_n_a_l._s_i_z_e<-(_r_e_s_o_u_r_c_e, _c_o_p_y, _a_l_l_o_c, _v_a_l_u_e): If 'value' is same
          as 'external.size(resource)', then no action is taken.
          Otherwise, reallocate the memory in 'resource' using the
          allocator 'alloc' with new size 'value'. If 'copy' is 'TRUE'
          (the default), then the new memory is initialized to the
          content of the old memory for the minimum of old and new
          sizes. Content of any uninitialized memory is undefined. 

     _r_e_i_n_i_t_i_a_l_i_z_e_P_o_i_n_t_e_r(_r_e_s_o_u_r_c_e, _a_l_l_o_c): If the object 'resource' was
          saved as an R image (by serialization code, by saving the R
          workspace, or by an explicit call to 'save') then the raw
          memory pointer in any '"externalptr"' object in it would be
          set to '0'. This method tries to reinitialize the raw memory
          pointer. The exact result is allocator dependant. 

_A_u_t_h_o_r(_s):

     Saikat DebRoy <saikat@stat.wisc.edu>

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

     'externalResource-class' for more on how to use an allocator with
     objects from subclasses of '"externalResource"'.

     'gcAllocator-class' for an example of a subclass of
     '"externalAllocator"'.

     'setVirtualMethod' for more on virtual methods.

