Class: Hornetseye::Pointer_

Inherits:
Node show all
Defined in:
docs/multiarray/lib/multiarray/pointer.rb

Overview

Class for representing native pointer types

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#<=>, ===, #[], #[]=, #allocate, #b=, #b_with_decompose, #basetype, #between?, bool, #check_shape, #clip, coercion_bool, coercion_byte, coercion_maxint, #collect, #components, cond, #conditional, #convolve, #dilate, dimension, #dimension, #downsample, #dup, #each, #empty?, #eq_with_multiarray, #erode, #fill!, #flip, float_scalar, floating, #fmod_with_float, #g=, #g_with_decompose, #gauss_blur, #gauss_gradient, #height, #histogram, #histogram_with_rgb, #if, #if_else, #imag=, #imag_with_decompose, indgen, #inject, #inspect, #integral, #lut, #lut_with_rgb, #mask, #matched?, #max, #mean, #memorise, #min, #normalise, #orig_to_cvmat, #orig_to_type_with_frame, #prod, #r=, #r_with_decompose, #range, #real=, #real_with_decompose, #reshape, rgb?, #rgb?, #roll, #save_dfloat, #save_dfloatrgb, #save_magick, #save_openexr, #save_sfloat, #save_sfloatrgb, #save_ubyte, #save_ubytergb, #save_uint, #save_uintrgb, #save_usint, #save_usintrgb, scalar, shape, #shape, #shift, #show, #size, #sobel, #stretch, #sum, #swap_rgb_with_scalar, #to_a, #to_cvmat, #to_magick, #to_narray, to_type, #to_type, #to_type_with_frame, #to_type_with_identity, #to_type_with_rgb, #transpose, #typecode, #unmask, #unroll, #warp, #width

Constructor Details

#initialize(value = self.class.default) ⇒ Pointer_

Constructor for pointer object

Parameters:

  • value (Malloc, List) (defaults to: self.class.default)

    Initial value for pointer object.



126
127
128
# File 'docs/multiarray/lib/multiarray/pointer.rb', line 126

def initialize( value = self.class.default )
  @value = value
end

Class Attribute Details

.targetNode

Target type of pointer

Returns:

  • (Node)

    Type of object the pointer is pointing at.



28
29
30
# File 'docs/multiarray/lib/multiarray/pointer.rb', line 28

def target
  @target
end

Class Method Details

.==(other) ⇒ Boolean

Test equality of classes

Parameters:

  • other (Object)

    Object to compare with.

Returns:

  • (Boolean)

    Boolean indicating whether classes are equal.



71
72
73
74
# File 'docs/multiarray/lib/multiarray/pointer.rb', line 71

def ==( other )
  other.is_a? Class and other < Pointer_ and
    target == other.target
end

.defaultMemory, List

Get default value for elements of this type

Returns:

  • (Memory, List)

    Memory for storing one object of type target.



62
63
64
# File 'docs/multiarray/lib/multiarray/pointer.rb', line 62

def default
  target.memory_type.new target.storage_size
end

.inspectString

Display string with information about this class

Returns:

  • (String)

    String with information about this class (e.g. ‘*(UBYTE)’).



44
45
46
# File 'docs/multiarray/lib/multiarray/pointer.rb', line 44

def inspect
  "*(#{target.inspect})"
end

.typecodeClass

Get element type

Returns:

  • (Class)

    Returns the corresponding element type.



99
100
101
# File 'docs/multiarray/lib/multiarray/pointer.rb', line 99

def typecode
  target
end

Instance Method Details

#decompose(i) ⇒ Node

Decompose composite elements

This method decomposes composite elements into array.

Returns:

  • (Node)

    Result of decomposition.



243
244
245
246
247
248
249
250
# File 'docs/multiarray/lib/multiarray/pointer.rb', line 243

def decompose( i )
  if self.class.target < Composite
    pointer = Hornetseye::Pointer( self.class.target.element_type ).new @value
    pointer.lookup INT.new( i ), INT.new( 1 )
  else
    super
  end
end

#memoryMalloc, List

Get access to storage object

Returns:

  • (Malloc, List)

    The object used to store the data.



133
134
135
# File 'docs/multiarray/lib/multiarray/pointer.rb', line 133

def memory
  @value
end