Re: IDLitComponent - Introspection [message #44015 is a reply to message #44013] |
Wed, 11 May 2005 16:48   |
Robert Barnett
Messages: 70 Registered: May 2004
|
Member |
|
|
I'm soon to send a feature request to RSI about it. What do you think about the following procedures?
;CallGetProperty.pro
;+
; NAME:
; CallGetProperty
;
; PURPOSE:
; To get the property of an object, when the keyword is only known at runtime.
;
; CATEGORY:
; Introspection
;
; CALLING SEQUENCE:
; CallGetProperty, obj, kwd, value
;
; INPUTS:
; obj: The object from which to obtain the property
; kwd: The keyword name of the property
;
; OUTPUTS:
; value: The value of the property
;
; SIDE EFFECTS:
; Expects to be able to make a single call "obj -> GetProperty"
;
; EXAMPLE:
;
; ; Define an object
;
; pro boringobj__define
; struct = {boringobj, boringproperty: ''}
; end
;
; pro boringobj::GetProperty, BORINGPROPERTY=boringproperty
; if (arg_present(boringproperty)) then $
; boringproperty = self.boringproperty
; end
;
; ; Get its property
;
; CallGetProperty, obj_new('boringobj'), 'BORINGPROPERTY', value
; print, value
;
;-
pro CallGetProperty, obj, kwd, value
; Unknown implementation
end
;CallSetProperty.pro
;+
; NAME:
; CallSetProperty
;
; PURPOSE:
; To set the property of an object, when the keyword is only known at runtime.
;
; CATEGORY:
; Introspection
;
; CALLING SEQUENCE:
; CallSetProperty, object, kwd, value
;
; INPUTS:
; object: The object from which to obtain the property
; kwd: The keyword name of the property
; value: The value of the property
;
; SIDE EFFECTS:
; Expects to be able to make a single call "obj -> SetProperty"
;
; EXAMPLE:
;
; ; Define an object
;
; pro boringobj__define
; struct = {boringobj, boringproperty: ''}
; end
;
; pro boringobj::SetProperty, BORINGPROPERTY=boringproperty
; if (n_elements(boringproperty) gt 0) then $
; self.boringproperty = boringproperty
; end
;
; ; Set its property
;
; CallSetProperty, obj_new('boringobj'), 'BORINGPROPERTY', 'boring value'
;
;-
pro CallSetProperty, obj, kwd, value
obj -> SetProperty, _EXTRA=create_struct(kwd, value)
end
============================================================ ===========
The actual application I had in mind was a configuration tool.
I have objects with properties which I would like to be able to
edit via a GUI at runtime. I can do this very effectively by using
widget_propertysheet.
However, I have numerous objects and do not want to bother setting up a
widget_propertysheet for each object individually. Instead, I wish to
query objects for properties which are 'IDLContainer's and
automatically generate a widget_tree based on the links between objects.
--
nrb@ Robbie Barnett
imag Research Assistant
wsahs Nuclear Medicine & Ultrasound
nsw Westmead Hospital
gov Sydney Australia
au +61 2 9845 7223
|
|
|