How to investigate IDL object code

Thursday, March 24, 2016

The object classes that are included with IDL are normally very well documented which helps greatly when using IDL object classes in your code. I often get IDL object-based code from colleagues, and documentation is not always included. When this happens I use this example code to quickly investigate the methods and superclasses associated with the object classes.

 

This code example outputs an HTML table with the information for the given object class.

; Prints out information about an object class
pro ab_obj_info, obj, noresolve=noresolve, short=short, super=ksuper, $
    out_super=super, quiet=quiet
  compile_opt idl2
  ; find all superclasses
  if (size(obj, /type) eq 7) then class=obj else class=obj_class(obj)
  super=strupcase(class)
  if ~keyword_set(noresolve) then resolve_all, class=super[0], /quiet, /cont
  x=0
  y=1
  repeat begin
    for i=x,y-1 do begin
      sup=obj_class(super[i],/superclass)
      if (sup[0] ne '') then super=[super,sup]
    endfor
    x=y
    y=n_elements(super)
  endrep until (x eq y)
  if ~keyword_set(quiet) then print, 'Class: '+super[0]
  if (y gt 1) && ~keyword_set(quiet) then begin
    print, 'Superclass: '+super[1:*], format='(a)'
  endif
  if keyword_set(ksuper) then return
  ;
  print, '<table>'
  print, '<thead><td>Class::Method</td><td>Arguments</td><td>Keyword</td></thead>'
  out = list()
  func = routine_info(/function)
  sysfunc = routine_info(/function, /system)
  proc = routine_info()
  sysproc = routine_info(/system)
 
  for i=0,y-1 do begin
    ind = where(func.StartsWith(super[i]+'::'),fcount)
    for j=0,fcount-1 do begin
      f = func[ind[j]]
      param = routine_info(f, /param, /func)
      print, '<tr>'
      print, '<td>'+f+'()</td>'
      if param.num_args gt 1 then begin
        str = strjoin(param.args[1:*],',')
      endif else str = ''
      print, '<td>'+str+'</td>'
      if param.num_kw_args gt 0 then begin
        str = strjoin(param.kw_args,',')
      endif else str = ''
      print, '<td>'+str+'</td></tr>'
    endfor
 
    ind = where(sysfunc.StartsWith(super[i]+'::'), fcount)
    for j=0,fcount-1 do begin
      f = sysfunc[ind[j]]
      print, '<tr><td>'+f+'</td><td></td><td></td></tr>'
    endfor
 
    ind = where(proc.StartsWith(super[i]+'::'),fcount)
    for j=0,fcount-1 do begin
      p = proc[ind[j]]
      param = routine_info(p, /param)
      print, '<tr>'
      print, '<td>'+p+'()</td>'
      if param.num_args gt 1 then begin
        str = strjoin(param.args[1:*],',')
      endif else str = ''
      print, '<td>'+str+'</td>'
      if param.num_kw_args gt 0 then begin
        str = strjoin(param.kw_args,',')
      endif else str = ''
      print, '<td>'+str+'</td></tr>'
    endfor
 
 
    ind = where(sysproc.StartsWith(super[i]+'::'), fcount)
    for j=0,fcount-1 do begin
      p = sysproc[ind[j]]
      print, '<tr><td>'+p+'</td><td></td><td></td></tr>'
    endfor
  endfor
  print, '</table>'
 
end
 

 

Here I run the code on the IDLgrColorbar class, which is already well documented, but is a convenient example:

IDL> ab_obj_info,'idlgrcolorbar'

Class: IDLGRCOLORBAR
Superclass: IDLGRMODEL
Superclass: IDLGRCONTAINER
Superclass: IDL_CONTAINER
Superclass: IDLGRCOMPONENT
Superclass: IDLITCOMPONENT

Here is the output HTML table showing all the methods associated with the IDLgrColorbar class.

Class::Method Arguments Keyword
IDLGRCOLORBAR::COMPUTEDIMENSIONS() OSRCDEST PATH
IDLGRCOLORBAR::INIT() ARED,AGREEN,ABLUE BLUE_VALUES,COLOR,DIMENSIONS,GREEN_VALUES,HIDE,MAJOR,MINOR,NAME,PALETTE,RED_VALUES,SHOW_AXIS,SHOW_OUTLINE,SUBTICKLEN,THICK,THREED,TICKFORMAT,TICKFRMTDATA,TICKLEN,TICKTEXT,TICKVALUES,TITLE,UVALUE,XCOORD_CONV,YCOORD_CONV,ZCOORD_CONV,_EXTRA
IDLGRCOLORBAR::CALCSIZE() DIMENSIONS,SHOW_AXIS,THICK
IDLGRCOLORBAR::CLEANUP()
IDLGRCOLORBAR::GETPROPERTY() ALL,BLUE_VALUES,COLOR,DIMENSIONS,GREEN_VALUES,HIDE,MAJOR,MINOR,NAME,PALETTE,PARENT,RED_VALUES,SHOW_AXIS,SHOW_OUTLINE,SUBTICKLEN,THICK,THREED,TICKFORMAT,TICKFRMTDATA,TICKLEN,TICKTEXT,TICKVALUES,TITLE,TRANSFORM,UVALUE,XCOORD_CONV,XRANGE,YCOORD_CONV,YRANGE,ZCOORD_CONV,ZRANGE,_REF_EXTRA
IDLGRCOLORBAR::SETPROPERTY() BLUE_VALUES,COLOR,DIMENSIONS,GREEN_VALUES,HIDE,MAJOR,MINOR,NAME,PALETTE,RED_VALUES,SHOW_AXIS,SHOW_OUTLINE,SUBTICKLEN,THICK,THREED,TICKFORMAT,TICKFRMTDATA,TICKLEN,TICKTEXT,TICKVALUES,TITLE,UVALUE,XCOORD_CONV,YCOORD_CONV,ZCOORD_CONV,_EXTRA
IDLGRMODEL::GETCTM
IDLGRMODEL::GETXYZRANGE
IDLGRMODEL::INIT
IDLGRMODEL::ADD
IDLGRMODEL::CLEANUP
IDLGRMODEL::DRAW
IDLGRMODEL::DRAWSELF
IDLGRMODEL::GETPROPERTY
IDLGRMODEL::RESET
IDLGRMODEL::ROTATE
IDLGRMODEL::SCALE
IDLGRMODEL::SETPROPERTY
IDLGRMODEL::TRANSLATE
IDLGRCONTAINER::GETBYNAME
IDLGRCONTAINER::INIT
IDLGRCONTAINER::ADD
IDLGRCONTAINER::CLEANUP
IDLGRCONTAINER::DRAW
IDLGRCONTAINER::REMOVE
IDL_CONTAINER::COUNT
IDL_CONTAINER::EQUALS
IDL_CONTAINER::GET
IDL_CONTAINER::INIT
IDL_CONTAINER::ISCONTAINED
IDL_CONTAINER::ADD
IDL_CONTAINER::CLEANUP
IDL_CONTAINER::MOVE
IDL_CONTAINER::REMOVE
IDLGRCOMPONENT::INIT
IDLGRCOMPONENT::CLEANUP
IDLGRCOMPONENT::GETPROPERTY
IDLGRCOMPONENT::SETPROPERTY
IDLITCOMPONENT::EDITUSERDEFPROPERTY
IDLITCOMPONENT::GETFULLIDENTIFIER
IDLITCOMPONENT::GETPROPBYNAME
IDLITCOMPONENT::GETPROPERTYBYIDENTIFIER
IDLITCOMPONENT::INIT
IDLITCOMPONENT::QUERYPROPERTY
IDLITCOMPONENT::_GETALLPROPERTYDESCRIPTORS
IDLITCOMPONENT::CLEANUP
IDLITCOMPONENT::GETPROPERTY
IDLITCOMPONENT::GETPROPERTYATTRIBUTE
IDLITCOMPONENT::NOTIFYBRIDGE
IDLITCOMPONENT::REGISTERPROPERTY
IDLITCOMPONENT::RESTORE
IDLITCOMPONENT::SETPROPERTY
IDLITCOMPONENT::SETPROPERTYATTRIBUTE
IDLITCOMPONENT::SETPROPERTYBYIDENTIFIER
IDLITCOMPONENT::UNREGISTERPROPERTY
IDLITCOMPONENT::UPDATECOMPONENTVERSION

 

Rate this article:
No rating
Tags:

Number of views (1301)/Comments (0)

Please login or register to post comments.

Name:
Email:
Subject:
Message:
x

RECENT POSTS

AUTHORS

Authors



© 2017 Exelis Visual Information Solutions, Inc., a subsidiary of Harris Corporation